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

@ -425,6 +425,10 @@ def proxy_server(webserver, port, scheme, method, url, conn, addr, data):
print("[*] Received %s chunks. (%s bytes per chunk)" % (str(i), str(buffer_size))) print("[*] Received %s chunks. (%s bytes per chunk)" % (str(i), str(buffer_size)))
# nothing at all # nothing at all
else:
connector = Extension.get_connector(server_connection_type)
if connector:
connector.connect(conn, data, webserver, port, scheme, method, url)
else: else:
raise Exception("Unsupported connection type") raise Exception("Unsupported connection type")
@ -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: