tcalmant / jsonrpclib

A Python (2 & 3) JSON-RPC over HTTP that mirrors the syntax of xmlrpclib (aka jsonrpclib-pelix)
https://jsonrpclib-pelix.readthedocs.io/
Apache License 2.0
53 stars 24 forks source link

Get ip of caller? #24

Closed vimalloc closed 9 years ago

vimalloc commented 9 years ago

Is it possible to get the ip address of someone making an rpc call in the registered function?

ex:

def add(a, b):
    print("IP of caller")
    return a + b

if __name__ == '__main__':
    server = PooledJSONRPCServer(("0.0.0.0", 1234))
    server.register_function(add)
    server.serve_forever()
tcalmant commented 9 years ago

You have to give the ip from a custom request handler. Take a look at issue #16 to have some ideas on how to implement it :-)

vimalloc commented 9 years ago

perfect, thanks! :)