Skip to content

Commit 7275516

Browse files
authored
Allow to set IP manually in Automaton.spawn() (#4673)
1 parent 1bdc210 commit 7275516

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

scapy/automaton.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -968,6 +968,7 @@ def parse_args(self, debug=0, store=0, **kargs):
968968
def spawn(cls,
969969
port: int,
970970
iface: Optional[_GlobInterfaceType] = None,
971+
local_ip: Optional[str] = None,
971972
bg: bool = False,
972973
**kwargs: Any) -> Optional[socket.socket]:
973974
"""
@@ -986,7 +987,8 @@ def spawn(cls,
986987
from scapy.arch import get_if_addr
987988
# create server sock and bind it
988989
ssock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
989-
local_ip = get_if_addr(iface or conf.iface)
990+
if local_ip is None:
991+
local_ip = get_if_addr(iface or conf.iface)
990992
try:
991993
ssock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
992994
except OSError:

0 commit comments

Comments
 (0)