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
53ead7e74b
commit
a606a1bcb0
18
server.py
18
server.py
|
@ -134,9 +134,7 @@ def jsonrpc2_server(conn, id, method, params):
|
|||
del accepted_relay[id]
|
||||
print ("[*] relay destroyed: %s" % (id))
|
||||
else:
|
||||
rpcmethod = Extension.get_rpcmethod(method)
|
||||
if rpcmethod:
|
||||
rpcmethod.dispatch("call", id, params, conn)
|
||||
Extension.dispatch_rpcmethod(method, "call", id, params, conn)
|
||||
|
||||
def proxy_connect(webserver, conn):
|
||||
hostname = webserver.decode(client_encoding)
|
||||
|
@ -490,10 +488,22 @@ class Extension():
|
|||
@classmethod
|
||||
def get_rpcmethod(cls, method):
|
||||
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 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
|
||||
def get_connector(cls, connection_type):
|
||||
for extension in cls.extensions:
|
||||
|
|
Loading…
Reference in New Issue
Block a user