mirror of
https://github.com/calebstewart/pwncat.git
synced 2024-11-27 19:04:15 +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)
|
||||
def _wrapper(self, *args, **kwargs):
|
||||
if not self.connected:
|
||||
raise ChannelError(self, "channel not connected")
|
||||
raise ChannelClosed(self)
|
||||
return method(self, *args, **kwargs)
|
||||
|
||||
return _wrapper
|
||||
@ -136,8 +136,10 @@ class Socket(Channel):
|
||||
self._connected = False
|
||||
raise ChannelClosed(self) from exc
|
||||
|
||||
@connect_required
|
||||
def close(self):
|
||||
if not self._connected:
|
||||
return
|
||||
|
||||
self._connected = False
|
||||
self.client.close()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user