"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "ospd/server.py" between
ospd-2.0.0.tar.gz and ospd-2.0.1.tar.gz

About: OSPd is a base class for scanner wrappers which share the same communication protocol: OSP (OpenVAS Scanner Protocol).

server.py  (ospd-2.0.0):server.py  (ospd-2.0.1)
skipping to change at line 51 skipping to change at line 51
def __init__(self, sock: socket.socket, stream_timeout: int): def __init__(self, sock: socket.socket, stream_timeout: int):
self.socket = sock self.socket = sock
self.socket.settimeout(stream_timeout) self.socket.settimeout(stream_timeout)
def close(self): def close(self):
""" Close the stream """ Close the stream
""" """
try: try:
self.socket.shutdown(socket.SHUT_RDWR) self.socket.shutdown(socket.SHUT_RDWR)
except OSError as e: except OSError as e:
logger.debug("Ignoring error while shutting down the connection. %s" logger.debug(
, e) "Ignoring error while shutting down the connection. %s", e
)
self.socket.close() self.socket.close()
def read(self, bufsize: Optional[int] = DEFAULT_BUFSIZE) -> bytes: def read(self, bufsize: Optional[int] = DEFAULT_BUFSIZE) -> bytes:
""" Read at maximum bufsize data from the stream """ Read at maximum bufsize data from the stream
""" """
data = self.socket.recv(bufsize) data = self.socket.recv(bufsize)
if not data: if not data:
logger.debug('Client closed the connection') logger.debug('Client closed the connection')
skipping to change at line 195 skipping to change at line 197
def _create_parent_dirs(self): def _create_parent_dirs(self):
# create all parent directories for the socket path # create all parent directories for the socket path
parent = self.socket_path.parent parent = self.socket_path.parent
parent.mkdir(parents=True, exist_ok=True) parent.mkdir(parents=True, exist_ok=True)
def start(self, stream_callback: StreamCallbackType): def start(self, stream_callback: StreamCallbackType):
self._cleanup_socket() self._cleanup_socket()
self._create_parent_dirs() self._create_parent_dirs()
if self.socket_path.exists():
os.chmod(str(self.socket_path), self.socket_mode)
try: try:
self.stream_callback = stream_callback self.stream_callback = stream_callback
self.server = ThreadedUnixSocketServer(self, str(self.socket_path)) self.server = ThreadedUnixSocketServer(self, str(self.socket_path))
self._start_threading_server() self._start_threading_server()
except OSError as e: except OSError as e:
logger.error("Couldn't bind socket on %s", str(self.socket_path)) logger.error("Couldn't bind socket on %s", str(self.socket_path))
raise OspdError( raise OspdError(
"Couldn't bind socket on {}. {}".format( "Couldn't bind socket on {}. {}".format(
str(self.socket_path), e str(self.socket_path), e
) )
) )
if self.socket_path.exists():
self.socket_path.chmod(self.socket_mode)
def close(self): def close(self):
super().close() super().close()
self._cleanup_socket() self._cleanup_socket()
def handle_request(self, request, client_address): def handle_request(self, request, client_address):
logger.debug("New connection from %s", str(self.socket_path)) logger.debug("New connection from %s", str(self.socket_path))
stream = Stream(request, self.stream_timeout) stream = Stream(request, self.stream_timeout)
self.stream_callback(stream) self.stream_callback(stream)
 End of changes. 3 change blocks. 
5 lines changed or deleted 6 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)