bridges-obfs4 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. # By default, Authorities are not configured as exits
  2. Authority = Node(tag="a", authority=1, relay=1, torrc="authority.tmpl")
  3. ExitRelay = Node(tag="r", relay=1, exit=1, torrc="relay.tmpl")
  4. Client = Node(tag="c", client=1, torrc="client.tmpl")
  5. BridgeAuthority = Node(tag="ba", authority=1, bridgeauthority=1,
  6. relay=1, torrc="bridgeauthority.tmpl")
  7. Bridge = Node(tag="br", bridge=1, pt_bridge=1, relay=1, pt_transport="obfs4",
  8. torrc="bridge-obfs4.tmpl")
  9. def obfs4_extra_args(env):
  10. import os, re
  11. # find the obfs4_bridgeline file.
  12. location = os.path.join(env['dir'],
  13. "pt_state",
  14. "obfs4_bridgeline.txt")
  15. if not os.path.exists(location):
  16. return ""
  17. # read the file and find the actual line
  18. with open(location, 'r') as f:
  19. for line in f:
  20. if line.startswith("#"):
  21. continue
  22. if line.isspace():
  23. continue
  24. m = re.match(r'(.*<FINGERPRINT>) (cert.*)', line)
  25. if m:
  26. return m.group(2)
  27. return ""
  28. Bridge.set_runtime("pt_extra", obfs4_extra_args)
  29. BridgeClient = Node(tag="bc", client=1, bridgeclient=1,
  30. torrc="bridgeclient-obfs4.tmpl", config_phase=2, launch_phase=2)
  31. NODES = Authority.getN(3) + BridgeAuthority.getN(1) + ExitRelay.getN(4) + \
  32. Bridge.getN(1) + Client.getN(1) + BridgeClient.getN(1)
  33. ConfigureNodes(NODES)