mirror of
https://github.com/gnh1201/caterpillar.git
synced 2025-09-06 09:51:06 +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
|
# nothing at all
|
||||||
else:
|
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])))
|
print("[*] Request and received. Done. %s" % (str(addr[0])))
|
||||||
conn.close()
|
conn.close()
|
||||||
|
@ -490,6 +494,13 @@ class Extension():
|
||||||
return extension
|
return extension
|
||||||
return None
|
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
|
@classmethod
|
||||||
def send_accept(cls, conn, method, success = True):
|
def send_accept(cls, conn, method, success = True):
|
||||||
_, message = jsonrpc2_encode(f"{method}_accept", {
|
_, message = jsonrpc2_encode(f"{method}_accept", {
|
||||||
|
@ -521,6 +532,9 @@ class Extension():
|
||||||
def dispatch(self, type, id, params, conn = None):
|
def dispatch(self, type, id, params, conn = None):
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
|
def connect(self, conn, data, webserver, port, scheme, method, url):
|
||||||
|
raise NotImplementedError
|
||||||
|
|
||||||
if __name__== "__main__":
|
if __name__== "__main__":
|
||||||
# initalization
|
# initalization
|
||||||
try:
|
try:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user