Agent: Simplify logic in SocketAddress object creation in monkey.py and network/relay/utils.py

This commit is contained in:
Shreya Malviya 2022-09-26 18:13:48 +05:30
parent 6a29702846
commit 8a609e0871
2 changed files with 3 additions and 7 deletions

View File

@ -3,7 +3,7 @@ import logging
import os
import subprocess
import sys
from ipaddress import IPv4Address, IPv4Interface
from ipaddress import IPv4Interface
from pathlib import Path, WindowsPath
from typing import List, Mapping, Optional, Tuple
@ -123,9 +123,7 @@ class InfectionMonkey:
self._cmd_island_ip, self._cmd_island_port = address_to_ip_port(server)
self._cmd_island_port = int(self._cmd_island_port)
self._island_address = SocketAddress(
IPv4Address(self._cmd_island_ip), self._cmd_island_port
)
self._island_address = SocketAddress(self._cmd_island_ip, self._cmd_island_port)
self._control_client = ControlClient(
server_address=server, island_api_client=self._island_api_client

View File

@ -1,7 +1,6 @@
import logging
import socket
from contextlib import suppress
from ipaddress import IPv4Address
from typing import Dict, Iterable, Iterator, Optional
from common.common_consts.timeouts import LONG_REQUEST_TIMEOUT
@ -90,8 +89,7 @@ def send_remove_from_waitlist_control_message_to_relays(servers: Iterable[str]):
def _send_remove_from_waitlist_control_message_to_relay(server: str):
ip, port = address_to_ip_port(server)
server_address = SocketAddress(IPv4Address(ip), int(port))
server_address = SocketAddress(*address_to_ip_port(server))
notify_disconnect(server_address)