mirror of
https://github.com/gnh1201/caterpillar.git
synced 2025-09-09 03:09:09 +00:00
Update server.py
This commit is contained in:
parent
53ead7e74b
commit
a606a1bcb0
18
server.py
18
server.py
|
@ -134,9 +134,7 @@ def jsonrpc2_server(conn, id, method, params):
|
||||||
del accepted_relay[id]
|
del accepted_relay[id]
|
||||||
print ("[*] relay destroyed: %s" % (id))
|
print ("[*] relay destroyed: %s" % (id))
|
||||||
else:
|
else:
|
||||||
rpcmethod = Extension.get_rpcmethod(method)
|
Extension.dispatch_rpcmethod(method, "call", id, params, conn)
|
||||||
if rpcmethod:
|
|
||||||
rpcmethod.dispatch("call", id, params, conn)
|
|
||||||
|
|
||||||
def proxy_connect(webserver, conn):
|
def proxy_connect(webserver, conn):
|
||||||
hostname = webserver.decode(client_encoding)
|
hostname = webserver.decode(client_encoding)
|
||||||
|
@ -490,10 +488,22 @@ class Extension():
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_rpcmethod(cls, method):
|
def get_rpcmethod(cls, method):
|
||||||
for extension in cls.extensions:
|
for extension in cls.extensions:
|
||||||
if extension.type == "rpcmethod" and ( (method == extension.method) or (method in extension.methods) ):
|
is_exported_method = (method == extension.method) or (method in extension.methods)
|
||||||
|
if extension.type == "rpcmethod" and is_exported_method:
|
||||||
return extension
|
return extension
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def dispatch_rpcmethod(cls, method, type, id, params, conn):
|
||||||
|
rpcmethod = cls.get_rpcmethod(method)
|
||||||
|
if rpcmethod:
|
||||||
|
if rpcmethod.method == method:
|
||||||
|
rpcmethod.dispatch(type, id, params, conn)
|
||||||
|
else:
|
||||||
|
f = getattr(rpcmethod, method, None)
|
||||||
|
if f:
|
||||||
|
f(type, id, params, conn)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_connector(cls, connection_type):
|
def get_connector(cls, connection_type):
|
||||||
for extension in cls.extensions:
|
for extension in cls.extensions:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user