diff options
Diffstat (limited to 'python/arti_rpc/samples')
| -rw-r--r-- | python/arti_rpc/samples/rpc_demo.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/python/arti_rpc/samples/rpc_demo.py b/python/arti_rpc/samples/rpc_demo.py new file mode 100644 index 000000000..5eb466d65 --- /dev/null +++ b/python/arti_rpc/samples/rpc_demo.py @@ -0,0 +1,24 @@ +import pprint +import os +from arti_rpc import * + +# TODO RPC: This won't work unless you've configured it in arti too. +socket_path = os.path.expanduser("~/.local/run/arti/SOCKET") +# TODO RPC: This isn't how connection strings will work in production +connect_string = f"unix:{socket_path}" + +# Connect to arti RPC. +conn = ArtiRpcConn(connect_string) + +# Demo 1: print out a complete list of supported RPC methods. +methods = conn.session().invoke("arti:x_list_all_rpc_methods") + +pprint.pprint(methods) + +# Demo 2: Open a socket to www.torproject.org port 80 over the tor network. + +# TODO RPC: This stalls (as of 24 Sep 2024); it used to work. +# I have patches in other branches to fix it. +# +sock = conn.connect("www.torproject.org", 80, isolation="rpc_demo") +print(sock) |
