forked from p15670423/monkey
Agent: Remove unnecessary control_channel_server() from IControlChannel
This commit is contained in:
parent
eaf27a7b92
commit
1944040328
|
@ -2,13 +2,6 @@ import abc
|
||||||
|
|
||||||
|
|
||||||
class IControlChannel(metaclass=abc.ABCMeta):
|
class IControlChannel(metaclass=abc.ABCMeta):
|
||||||
@property
|
|
||||||
@abc.abstractmethod
|
|
||||||
def control_channel_server(self):
|
|
||||||
"""
|
|
||||||
:return: Worm configuration server
|
|
||||||
"""
|
|
||||||
|
|
||||||
@abc.abstractmethod
|
@abc.abstractmethod
|
||||||
def should_agent_stop(self) -> bool:
|
def should_agent_stop(self) -> bool:
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -14,15 +14,16 @@ logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class ControlChannel(IControlChannel):
|
class ControlChannel(IControlChannel):
|
||||||
control_channel_server = WormConfiguration.current_server
|
def __init__(self, server: str):
|
||||||
|
self._control_channel_server = server
|
||||||
|
|
||||||
def should_agent_stop(self) -> bool:
|
def should_agent_stop(self) -> bool:
|
||||||
if not self.control_channel_server:
|
if not self._control_channel_server:
|
||||||
return
|
return
|
||||||
|
|
||||||
try:
|
try:
|
||||||
response = requests.get( # noqa: DUO123
|
response = requests.get( # noqa: DUO123
|
||||||
f"{self.control_channel_server}/api/monkey_control/{GUID}",
|
f"{self._control_channel_server}/api/monkey_control/{GUID}",
|
||||||
verify=False,
|
verify=False,
|
||||||
timeout=SHORT_REQUEST_TIMEOUT,
|
timeout=SHORT_REQUEST_TIMEOUT,
|
||||||
)
|
)
|
||||||
|
@ -37,12 +38,12 @@ class ControlChannel(IControlChannel):
|
||||||
return WormConfiguration.as_dict()
|
return WormConfiguration.as_dict()
|
||||||
|
|
||||||
def get_credentials_for_propagation(self) -> dict:
|
def get_credentials_for_propagation(self) -> dict:
|
||||||
if not self.control_channel_server:
|
if not self._control_channel_server:
|
||||||
return
|
return
|
||||||
|
|
||||||
try:
|
try:
|
||||||
response = requests.get( # noqa: DUO123
|
response = requests.get( # noqa: DUO123
|
||||||
f"{self.control_channel_server}/api/propagationCredentials",
|
f"{self._control_channel_server}/api/propagationCredentials",
|
||||||
verify=False,
|
verify=False,
|
||||||
timeout=SHORT_REQUEST_TIMEOUT,
|
timeout=SHORT_REQUEST_TIMEOUT,
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue