Skip to content

Commit

Permalink
better info dict structure
Browse files Browse the repository at this point in the history
  • Loading branch information
joamag committed Sep 8, 2015
1 parent ddf4e3c commit 61587c3
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 12 deletions.
13 changes: 7 additions & 6 deletions src/netius/base/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -749,12 +749,13 @@ def on_connection_d(self, connection):
(len(connection.owner.connections), connection.owner.name)
)

def info_dict(self):
info = dict()
info["loaded"] = self._loaded
info["connections"] = len(self.connections)
info["state"] = self.get_state_s()
info["poll"] = self.get_poll_name()
def info_dict(self, full = False):
info = dict(
loaded = self._loaded,
connections = len(self.connections),
state = self.get_state_s(),
poll = self.get_poll_name()
)
return info

def new_connection(self, socket, address, ssl = False):
Expand Down
14 changes: 8 additions & 6 deletions src/netius/base/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,14 @@ def cleanup(self):
# and not able to be used for any kind of communication
self.socket = None

def info_dict(self):
info = Base.info_dict(self)
info["host"] = self.host
info["port"] = self.port
info["type"] = self.type
info["ssl"] = self.ssl
def info_dict(self, full = False):
info = Base.info_dict(self, full = full)
info.update(
host = self.host,
port = self.port,
type = self.type,
ssl = self.ssl
)
return info

def serve(
Expand Down
7 changes: 7 additions & 0 deletions src/netius/extra/proxy_r.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,13 @@ def __init__(
self.acquirer_m = getattr(self, "acquirer_" + self.strategy)
self.releaser_m = getattr(self, "releaser_" + self.strategy)

def info_dict(self, full = False):
info = netius.servers.ProxyServer.info_dict(self, full = full)
info.update(
strategy = self.strategy
)
return info

def on_headers(self, connection, parser):
netius.servers.ProxyServer.on_headers(self, connection, parser)

Expand Down
9 changes: 9 additions & 0 deletions src/netius/servers/proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,15 @@ def cleanup(self):
self.http_client.destroy()
self.raw_client.destroy()

def info_dict(self, full = False):
info = http.HTTPServer.info_dict(self, full = full)
info.update(
throttle = self.throttle,
max_pending = self.max_pending,
min_pending = self.min_pending
)
return info

def on_data(self, connection, data):
netius.StreamServer.on_data(self, connection, data)

Expand Down

0 comments on commit 61587c3

Please sign in to comment.