mirror of
https://github.com/gnh1201/caterpillar.git
synced 2024-11-26 15:31:45 +00:00
Update server.py
This commit is contained in:
parent
c526bcb6e0
commit
4ea3653a15
16
server.py
16
server.py
|
@ -426,7 +426,11 @@ def proxy_server(webserver, port, scheme, method, url, conn, addr, data):
|
|||
|
||||
# nothing at all
|
||||
else:
|
||||
raise Exception("Unsupported connection type")
|
||||
connector = Extension.get_connector(server_connection_type)
|
||||
if connector:
|
||||
connector.connect(conn, data, webserver, port, scheme, method, url)
|
||||
else:
|
||||
raise Exception("Unsupported connection type")
|
||||
|
||||
print("[*] Request and received. Done. %s" % (str(addr[0])))
|
||||
conn.close()
|
||||
|
@ -490,6 +494,13 @@ class Extension():
|
|||
return extension
|
||||
return None
|
||||
|
||||
@classmethod
|
||||
def get_connector(cls, method):
|
||||
for extension in cls.extensions:
|
||||
if extension.type == "connector" and extension.method == method:
|
||||
return extension
|
||||
return None
|
||||
|
||||
@classmethod
|
||||
def send_accept(cls, conn, method, success = True):
|
||||
_, message = jsonrpc2_encode(f"{method}_accept", {
|
||||
|
@ -521,6 +532,9 @@ class Extension():
|
|||
def dispatch(self, type, id, params, conn = None):
|
||||
raise NotImplementedError
|
||||
|
||||
def connect(self, conn, data, webserver, port, scheme, method, url):
|
||||
raise NotImplementedError
|
||||
|
||||
if __name__== "__main__":
|
||||
# initalization
|
||||
try:
|
||||
|
|
Loading…
Reference in New Issue
Block a user