File: client.py

package info (click to toggle)
pyro4 4.82-2
  • links: PTS
  • area: main
  • in suites: bookworm
  • size: 2,528 kB
  • sloc: python: 17,736; makefile: 169; sh: 113; javascript: 62
file content (29 lines) | stat: -rw-r--r-- 786 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import Pyro4
import Pyro4.errors
from diffiehellman import DiffieHellman


dh = DiffieHellman(group=14)

with Pyro4.locateNS() as ns:
    uri = ns.lookup("example.dh.secretstuff")
    print(uri)

p = Pyro4.Proxy(uri)
try:
    p.process("hey")
    raise RuntimeError("this should not be reached")
except Pyro4.errors.PyroError as x:
    print("Error occured (expected!):", x)

with Pyro4.Proxy("PYRONAME:example.dh.keyexchange") as keyex:
    print("exchange public keys...")
    other_key = keyex.exchange_key(dh.public_key)
    print("got server public key, creating shared secret key...")
    dh.make_shared_secret_and_key(other_key)
    print("setting key on proxy.")
    p._pyroHmacKey = dh.key

print("Calling proxy again...")
result = p.process("hey")
print("Got reply:", result)