mirror of
https://github.com/gnh1201/caterpillar.git
synced 2025-09-05 17:31:03 +00:00
Update server.py
This commit is contained in:
parent
65be31ef59
commit
73538cc6be
40
server.py
40
server.py
|
@ -158,14 +158,19 @@ def conn_string(conn, data, addr):
|
||||||
# check is it JSON-RPC 2.0 request
|
# check is it JSON-RPC 2.0 request
|
||||||
if data.find(b'{') == 0:
|
if data.find(b'{') == 0:
|
||||||
type, id, method, rpcdata = jsonrpc2_decode(data.decode(client_encoding))
|
type, id, method, rpcdata = jsonrpc2_decode(data.decode(client_encoding))
|
||||||
if type == "call" and method == "relay_accept":
|
if type == "call":
|
||||||
accepted_relay[id] = conn
|
if method == "relay_accept":
|
||||||
connection_speed = rpcdata['connection_speed']
|
accepted_relay[id] = conn
|
||||||
print ("[*] connection speed: %s miliseconds" % (str(connection_speed)))
|
connection_speed = rpcdata['connection_speed']
|
||||||
while conn.fileno() > -1:
|
print ("[*] connection speed: %s miliseconds" % (str(connection_speed)))
|
||||||
time.sleep(1)
|
while conn.fileno() > -1:
|
||||||
del accepted_relay[id]
|
time.sleep(1)
|
||||||
print ("[*] relay destroyed: %s" % (id))
|
del accepted_relay[id]
|
||||||
|
print ("[*] relay destroyed: %s" % (id))
|
||||||
|
else:
|
||||||
|
rpchandler = Extension.get_rpcmethod(method)
|
||||||
|
if rpchandler:
|
||||||
|
rpchandler.dispatch(type, id, method, rpcdata)
|
||||||
return
|
return
|
||||||
|
|
||||||
# parse first data (header)
|
# parse first data (header)
|
||||||
|
@ -528,19 +533,22 @@ class Extension():
|
||||||
return filters
|
return filters
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_rpcmethods(cls):
|
def get_rpcmethod(cls, method):
|
||||||
rpcmethods = []
|
|
||||||
for extension in cls.extension:
|
for extension in cls.extension:
|
||||||
if extension.type == "rpcmethod":
|
if extension.method == method:
|
||||||
rpcmethods.append(extension)
|
return extension
|
||||||
return rpcmethods
|
return None
|
||||||
|
|
||||||
def __init__():
|
def __init__(self):
|
||||||
self.type = "unknown"
|
self.type = ""
|
||||||
|
self.method = ""
|
||||||
|
|
||||||
def test(self, filtered, data, webserver, port, scheme, method, url):
|
def test(self, filtered, data, webserver, port, scheme, method, url):
|
||||||
print ("[*] Not implemented")
|
print ("[*] Not implemented")
|
||||||
|
|
||||||
|
def dispatch(type, id, method, rpcdata):
|
||||||
|
print ("[*] Not implemented")
|
||||||
|
|
||||||
class RPCMethod():
|
class RPCMethod():
|
||||||
methods = []
|
methods = []
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user