Python errno.ENETRESET Examples
The following are 12
code examples of errno.ENETRESET().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
errno
, or try the search function
.
Example #1
Source File: utils.py From django-eth-events with MIT License | 5 votes |
def is_network_error(exception) -> bool: """ :param exception: an exception error instance :return: True if exception detected as a network error, False otherwise """ network_errors = [errno.ECONNABORTED, errno.ECONNREFUSED, errno.ENETRESET, errno.ECONNRESET, errno.ENETUNREACH, errno.ENETDOWN] if isinstance(exception, HTTPError) or isinstance(exception, RequestException) or \ hasattr(exception, 'errno') and exception.errno in network_errors: return True return False
Example #2
Source File: telnet_connection.py From fuzzowski with GNU General Public License v2.0 | 5 votes |
def recv(self, max_bytes): """ Receive up to max_bytes data from the target. Args: max_bytes (int): Maximum number of bytes to receive. Returns: Received data. """ try: # return self._client.read_eager() return self._client.read_until(b'>', timeout=self.timeout) # TODO: Implementation Dependant except socket.timeout: self._active_session = False data = b'' # raise exception.FuzzowskiTargetRecvTimeout() except socket.error as e: self._active_session = False if e.errno == errno.ECONNABORTED: # raise(exception.FuzzowskiTargetConnectionAborted(socket_errno=e.errno, socket_errmsg=e.strerror), None, sys.exc_info()[2]) raise exception.FuzzowskiTargetConnectionAborted(socket_errno=e.errno, socket_errmsg=e.strerror) # .with_traceback(sys.exc_info()[2]) elif (e.errno == errno.ECONNRESET) or \ (e.errno == errno.ENETRESET) or \ (e.errno == errno.ETIMEDOUT): # raise(exception.FuzzowskiTargetConnectionReset, None, sys.exc_info()[2]) raise exception.FuzzowskiTargetConnectionReset # .with_traceback(sys.exc_info()[2]) elif e.errno == errno.EWOULDBLOCK or e.errno == errno.EAGAIN: # timeout condition if using SO_RCVTIMEO or SO_SNDTIMEO # raise exception.FuzzowskiTargetRecvTimeout() data = b'' else: raise return data
Example #3
Source File: telnet_connection.py From fuzzowski with GNU General Public License v2.0 | 5 votes |
def send(self, data): """ Send data to the target. Only valid after calling open! Some protocols will truncate; see self.MAX_PAYLOADS. Args: data: Data to send. Returns: int: Number of bytes actually sent. """ # try: # data = data[:self.MAX_PAYLOADS[self.proto]] # except KeyError: # pass # data = data try: self._client.write(data) num_sent = len(data) except socket.error as e: self._active_session = False if e.errno == errno.ECONNABORTED: raise(exception.FuzzowskiTargetConnectionAborted(socket_errno=e.errno, socket_errmsg=e.strerror), None, sys.exc_info()[2]) elif (e.errno == errno.ECONNRESET) or \ (e.errno == errno.ENETRESET) or \ (e.errno == errno.ETIMEDOUT) or \ (e.errno == errno.EPIPE): raise(exception.FuzzowskiTargetConnectionReset(None, sys.exc_info()[2])) # raise(exception.FuzzowskiTargetConnectionReset, None, sys.exc_info()[2]) else: raise # TODO: OSError: except (Exception, OSError) as e: self._active_session = False raise(exception.FuzzowskiTargetConnectionAborted(socket_errno=e.errno, socket_errmsg=e.strerror), None, sys.exc_info()[2]) return num_sent
Example #4
Source File: raw_l3_socket_connection.py From boofuzz with GNU General Public License v2.0 | 5 votes |
def recv(self, max_bytes): """ Receives a packet from the raw socket. If max_bytes < packet_size, only the first max_bytes are returned and the rest of the packet is discarded. Otherwise, return the whole packet. Args: max_bytes (int): Maximum number of bytes to return. 0 to return the whole packet. Returns: Received data """ data = b"" try: data = self._sock.recv(self.packet_size) if 0 < max_bytes < self.packet_size: data = data[: self._packet_size] except socket.timeout: data = b"" except socket.error as e: if e.errno == errno.ECONNABORTED: raise_( exception.BoofuzzTargetConnectionAborted(socket_errno=e.errno, socket_errmsg=e.strerror), None, sys.exc_info()[2], ) elif e.errno in [errno.ECONNRESET, errno.ENETRESET, errno.ETIMEDOUT]: raise_(exception.BoofuzzTargetConnectionReset(), None, sys.exc_info()[2]) elif e.errno == errno.EWOULDBLOCK: data = b"" else: raise return data
Example #5
Source File: raw_l3_socket_connection.py From boofuzz with GNU General Public License v2.0 | 5 votes |
def send(self, data): """ Send data to the target. Only valid after calling open! Data will be trunctated to self.packet_size (Default: 1500 bytes). Args: data: Data to send. Returns: int: Number of bytes actually sent. """ num_sent = 0 data = data[: self.packet_size] try: num_sent = self._sock.sendto(data, (self.interface, self.ethernet_proto, 0, 0, self.l2_dst)) except socket.error as e: if e.errno == errno.ECONNABORTED: raise_( exception.BoofuzzTargetConnectionAborted(socket_errno=e.errno, socket_errmsg=e.strerror), None, sys.exc_info()[2], ) elif e.errno in [errno.ECONNRESET, errno.ENETRESET, errno.ETIMEDOUT, errno.EPIPE]: raise_(exception.BoofuzzTargetConnectionReset(), None, sys.exc_info()[2]) else: raise return num_sent
Example #6
Source File: udp_socket_connection.py From boofuzz with GNU General Public License v2.0 | 5 votes |
def recv(self, max_bytes): """Receive up to max_bytes data from the target. Args: max_bytes(int): Maximum number of bytes to receive. Returns: Received data. """ data = b"" try: if self.bind or self.server: data, self._udp_client_port = self._sock.recvfrom(max_bytes) else: raise exception.SullyRuntimeError( "UDPSocketConnection.recv() requires a bind address/port." " Current value: {}".format(self.bind) ) except socket.timeout: data = b"" except socket.error as e: if e.errno == errno.ECONNABORTED: raise_( exception.BoofuzzTargetConnectionAborted(socket_errno=e.errno, socket_errmsg=e.strerror), None, sys.exc_info()[2], ) elif e.errno in [errno.ECONNRESET, errno.ENETRESET, errno.ETIMEDOUT]: raise_(exception.BoofuzzTargetConnectionReset(), None, sys.exc_info()[2]) elif e.errno == errno.EWOULDBLOCK: data = b"" else: raise return data
Example #7
Source File: udp_socket_connection.py From boofuzz with GNU General Public License v2.0 | 5 votes |
def send(self, data): """ Send data to the target. Only valid after calling open! Some protocols will truncate; see self.MAX_PAYLOADS. Args: data: Data to send. Returns: int: Number of bytes actually sent. """ num_sent = 0 try: if self.server: if self._udp_client_port is None: raise exception.BoofuzzError("recv() must be called before send with udp fuzzing servers.") num_sent = self._sock.sendto(data, self._udp_client_port) else: num_sent = self._sock.sendto(data, (self.host, self.port)) except socket.error as e: if e.errno == errno.ECONNABORTED: raise_( exception.BoofuzzTargetConnectionAborted(socket_errno=e.errno, socket_errmsg=e.strerror), None, sys.exc_info()[2], ) elif e.errno in [errno.ECONNRESET, errno.ENETRESET, errno.ETIMEDOUT, errno.EPIPE]: raise_(exception.BoofuzzTargetConnectionReset(), None, sys.exc_info()[2]) else: raise return num_sent
Example #8
Source File: raw_l2_socket_connection.py From boofuzz with GNU General Public License v2.0 | 5 votes |
def recv(self, max_bytes): """ Receives a packet from the raw socket. If max_bytes < mtu, only the first max_bytes are returned and the rest of the packet is discarded. Otherwise, return the whole packet. Args: max_bytes (int): Maximum number of bytes to return. 0 to return the whole packet. Returns: Received data """ if self.ethernet_proto is None: raise Exception( "Receiving on Raw Layer 2 sockets is only supported if the socket " "is bound to an interface and protocol." ) data = b"" try: data = self._sock.recv(self.mtu) if 0 < len(data) < max_bytes: data = data[:max_bytes] except socket.timeout: data = b"" except socket.error as e: if e.errno == errno.ECONNABORTED: raise_( exception.BoofuzzTargetConnectionAborted(socket_errno=e.errno, socket_errmsg=e.strerror), None, sys.exc_info()[2], ) elif e.errno in [errno.ECONNRESET, errno.ENETRESET, errno.ETIMEDOUT]: raise_(exception.BoofuzzTargetConnectionReset(), None, sys.exc_info()[2]) elif e.errno == errno.EWOULDBLOCK: data = b"" else: raise return data
Example #9
Source File: tcp_socket_connection.py From boofuzz with GNU General Public License v2.0 | 5 votes |
def recv(self, max_bytes): """ Receive up to max_bytes data from the target. Args: max_bytes (int): Maximum number of bytes to receive. Returns: Received data. """ data = b"" try: data = self._sock.recv(max_bytes) except socket.timeout: data = b"" except socket.error as e: if e.errno == errno.ECONNABORTED: raise_( exception.BoofuzzTargetConnectionAborted(socket_errno=e.errno, socket_errmsg=e.strerror), None, sys.exc_info()[2], ) elif (e.errno == errno.ECONNRESET) or (e.errno == errno.ENETRESET) or (e.errno == errno.ETIMEDOUT): raise_(exception.BoofuzzTargetConnectionReset(), None, sys.exc_info()[2]) elif e.errno == errno.EWOULDBLOCK: # timeout condition if using SO_RCVTIMEO or SO_SNDTIMEO data = b"" else: raise return data
Example #10
Source File: tcp_socket_connection.py From boofuzz with GNU General Public License v2.0 | 5 votes |
def send(self, data): """ Send data to the target. Only valid after calling open! Args: data: Data to send. Returns: int: Number of bytes actually sent. """ num_sent = 0 try: num_sent = self._sock.send(data) except socket.error as e: if e.errno == errno.ECONNABORTED: raise_( exception.BoofuzzTargetConnectionAborted(socket_errno=e.errno, socket_errmsg=e.strerror), None, sys.exc_info()[2], ) elif e.errno in [errno.ECONNRESET, errno.ENETRESET, errno.ETIMEDOUT, errno.EPIPE]: raise_(exception.BoofuzzTargetConnectionReset(), None, sys.exc_info()[2]) else: raise return num_sent
Example #11
Source File: socket_connection.py From fuzzowski with GNU General Public License v2.0 | 4 votes |
def recv(self, max_bytes): """ Receive up to max_bytes data from the target. Args: max_bytes (int): Maximum number of bytes to receive. Returns: Received data. """ try: if self.proto in ['tcp', 'ssl']: data = self._sock.recv(max_bytes) elif self.proto == 'udp': # Not necessary to bind to a port to use this, right? # if self.bind: data, _ = self._sock.recvfrom(max_bytes) # else: # raise exception.FuzzowskiRuntimeError( # "SocketConnection.recv() for UDP requires a bind address/port." # " Current value: {}".format(self.bind)) elif self.proto in ['raw-l2', 'raw-l3']: # receive on raw is not supported. Since there is no specific protocol for raw, we would just have to # dump everything off the interface anyway, which is probably not what the user wants. data = b'' else: raise exception.FuzzowskiRuntimeError("INVALID PROTOCOL SPECIFIED: %s" % self.proto) except socket.timeout: data = b'' # raise exception.FuzzowskiTargetRecvTimeout() except socket.error as e: if e.errno == errno.ECONNABORTED: # raise(exception.FuzzowskiTargetConnectionAborted(socket_errno=e.errno, socket_errmsg=e.strerror), None, sys.exc_info()[2]) raise exception.FuzzowskiTargetConnectionAborted(socket_errno=e.errno, socket_errmsg=e.strerror) # .with_traceback(sys.exc_info()[2]) elif (e.errno == errno.ECONNRESET) or \ (e.errno == errno.ENETRESET) or \ (e.errno == errno.ETIMEDOUT): # raise(exception.FuzzowskiTargetConnectionReset, None, sys.exc_info()[2]) raise exception.FuzzowskiTargetConnectionReset # .with_traceback(sys.exc_info()[2]) elif e.errno == errno.EWOULDBLOCK or e.errno == errno.EAGAIN: # timeout condition if using SO_RCVTIMEO or SO_SNDTIMEO # raise exception.FuzzowskiTargetRecvTimeout() data = b'' else: raise return data
Example #12
Source File: socket_connection.py From fuzzowski with GNU General Public License v2.0 | 4 votes |
def send(self, data): """ Send data to the target. Only valid after calling open! Some protocols will truncate; see self.MAX_PAYLOADS. Args: data: Data to send. Returns: int: Number of bytes actually sent. """ try: data = data[:self.MAX_PAYLOADS[self.proto]] except KeyError: pass # data = data try: if self.proto in ["tcp", "ssl"]: num_sent = self._sock.send(data) elif self.proto == "udp": num_sent = self._sock.sendto(data, (self.host, self.port)) elif self.proto == "raw-l2": num_sent = self._sock.sendto(data, (self.host, 0)) elif self.proto == "raw-l3": # Address tuple: (interface string, # Ethernet protocol number, # packet type (recv only), # hatype (recv only), # Ethernet address) # See man 7 packet for more details. num_sent = self._sock.sendto(data, (self.host, self.ethernet_proto, 0, 0, self.l2_dst)) else: raise exception.FuzzowskiRuntimeError("INVALID PROTOCOL SPECIFIED: %s" % self.proto) except socket.error as e: if e.errno == errno.ECONNABORTED: raise(exception.FuzzowskiTargetConnectionAborted(socket_errno=e.errno, socket_errmsg=e.strerror), None, sys.exc_info()[2]) elif (e.errno == errno.ECONNRESET) or \ (e.errno == errno.ENETRESET) or \ (e.errno == errno.ETIMEDOUT) or \ (e.errno == errno.EPIPE): raise(exception.FuzzowskiTargetConnectionReset(None, sys.exc_info()[2])) # raise(exception.FuzzowskiTargetConnectionReset, None, sys.exc_info()[2]) else: raise # TODO: OSError: except (Exception, OSError) as e: raise(exception.FuzzowskiTargetConnectionAborted(socket_errno=e.errno, socket_errmsg=e.strerror), None, sys.exc_info()[2]) return num_sent