Update server.py

This commit is contained in:
Namhyeon Go 2024-03-06 13:46:29 +09:00 committed by GitHub
parent c526bcb6e0
commit 4ea3653a15
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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: