@@ -464,9 +464,9 @@ def honeypot_configuration_builder(selected_modules):
464464 return honeypot_configuration
465465
466466
467- def port_is_reserved (real_machine_port ):
467+ def port_is_free (real_machine_port ):
468468 """
469- check if port is reserved
469+ check if port is free
470470
471471 Args:
472472 real_machine_port: port number
@@ -478,14 +478,14 @@ def port_is_reserved(real_machine_port):
478478 tcp = socket .socket (socket .AF_INET , socket .SOCK_STREAM )
479479 tcp .bind (
480480 (
481- network_configuration ()[ "real_machine_ip_address" ] ,
481+ "0.0.0.0" ,
482482 real_machine_port
483483 )
484484 )
485485 tcp .close ()
486- return False
487- except Exception :
488486 return True
487+ except Exception :
488+ return False
489489
490490
491491def reserve_tcp_port (real_machine_port , module_name , configuration ):
@@ -502,16 +502,15 @@ def reserve_tcp_port(real_machine_port, module_name, configuration):
502502 """
503503 while True :
504504 try :
505- if not port_is_reserved (real_machine_port ):
505+ if port_is_free (real_machine_port ):
506506 # unique_port = True
507507 configuration [module_name ]["real_machine_port_number" ] = real_machine_port
508508 duplicated_ports = []
509509 for selected_module in configuration :
510510 duplicated_ports .append (
511511 configuration [selected_module ]["real_machine_port_number" ])
512512 if duplicated_ports .count (real_machine_port ) == 1 :
513- info ("port {0} selected for {1}" .format (
514- real_machine_port , module_name ))
513+ info ("port {0} selected for {1}" .format (real_machine_port , module_name ))
515514 return real_machine_port
516515 except Exception :
517516 pass
0 commit comments