mirror of
https://github.com/calebstewart/pwncat.git
synced 2024-11-30 12:24:14 +01:00
Changed ChannelError to ChannelClosed in Socket
Socket-based channels now raise ChannelClosed if no connection is active and a recv/send method is called. Also, the close method no longer raises an exception if the channel is not active. It is silently ignored as a NOOP.
This commit is contained in:
parent
a59857a2fc
commit
89ad889977
@ -32,7 +32,7 @@ def connect_required(method):
|
|||||||
@functools.wraps(method)
|
@functools.wraps(method)
|
||||||
def _wrapper(self, *args, **kwargs):
|
def _wrapper(self, *args, **kwargs):
|
||||||
if not self.connected:
|
if not self.connected:
|
||||||
raise ChannelError(self, "channel not connected")
|
raise ChannelClosed(self)
|
||||||
return method(self, *args, **kwargs)
|
return method(self, *args, **kwargs)
|
||||||
|
|
||||||
return _wrapper
|
return _wrapper
|
||||||
@ -136,8 +136,10 @@ class Socket(Channel):
|
|||||||
self._connected = False
|
self._connected = False
|
||||||
raise ChannelClosed(self) from exc
|
raise ChannelClosed(self) from exc
|
||||||
|
|
||||||
@connect_required
|
|
||||||
def close(self):
|
def close(self):
|
||||||
|
if not self._connected:
|
||||||
|
return
|
||||||
|
|
||||||
self._connected = False
|
self._connected = False
|
||||||
self.client.close()
|
self.client.close()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user