[tor-commits] [flashproxy/master] rename relays to facilitator-relays and integrate it into the install process

infinity0 at torproject.org infinity0 at torproject.org
Thu Nov 21 13:18:46 UTC 2013


commit 3fc93f88e8cd22c12861034b5389348f8a5c4db3
Author: Ximin Luo <infinity0 at gmx.com>
Date:   Mon Nov 18 14:37:32 2013 +0000

    rename relays to facilitator-relays and integrate it into the install process
---
 facilitator/Makefile.am                 |    3 ++-
 facilitator/examples/facilitator-relays |    7 +++++++
 facilitator/facilitator                 |   12 ++++++++++--
 facilitator/init.d/facilitator.in       |    2 +-
 facilitator/relays                      |    4 ----
 5 files changed, 20 insertions(+), 8 deletions(-)

diff --git a/facilitator/Makefile.am b/facilitator/Makefile.am
index 7e117ba..2b3ac8e 100644
--- a/facilitator/Makefile.am
+++ b/facilitator/Makefile.am
@@ -24,7 +24,8 @@ dist_initconf_DATA = default/facilitator default/facilitator-email-poller defaul
 endif
 
 dist_doc_DATA = doc/appspot-howto.txt doc/facilitator-design.txt doc/email-howto.txt doc/http-howto.txt doc/server-howto.txt README
-dist_example_DATA = examples/fp-facilitator.conf examples/reg-email.pass
+dist_example_DATA = examples/fp-facilitator.conf examples/reg-email.pass examples/facilitator-relays
+pkgconf_DATA = examples/facilitator-relays
 dist_appengine_DATA = appengine/app.yaml appengine/config.go appengine/fp-reg.go appengine/README
 appengineconf_DATA = appengine/config.go
 CLEANFILES = examples/fp-facilitator.conf
diff --git a/facilitator/examples/facilitator-relays b/facilitator/examples/facilitator-relays
new file mode 100644
index 0000000..0753387
--- /dev/null
+++ b/facilitator/examples/facilitator-relays
@@ -0,0 +1,7 @@
+# List some relays that the facilitator will match proxies with.
+# Each line contains a transport and an address, separated by space.
+# See doc/design.txt for details of the transport syntax.
+#obfs3|websocket 173.255.221.44:9500
+#websocket 173.255.221.44:9901
+#obfs3|websocket [2600:3c01::f03c:91ff:fe93:6cd2]:9500
+#websocket [2600:3c01::f03c:91ff:fe93:6cd2]:9901
diff --git a/facilitator/facilitator b/facilitator/facilitator
index 3bc8f92..9d90833 100755
--- a/facilitator/facilitator
+++ b/facilitator/facilitator
@@ -412,8 +412,12 @@ def parse_relay_file(servers, fp):
     Throws ValueError on a parsing error. Each line contains a transport chain
     and an address, for example
         obfs2|websocket 1.4.6.1:4123
+    :returns: number of relays added
     """
+    n = 0
     for line in fp.readlines():
+        line = line.strip("\n")
+        if not line or line.startswith('#'): continue
         try:
             transport_spec, addr_spec = line.strip().split()
         except ValueError, e:
@@ -424,6 +428,8 @@ def parse_relay_file(servers, fp):
             raise ValueError(u"Unrecognized transport: %s" % transport)
         af = addr_af(addr[0])
         servers[af].addEndpoint(addr, transport)
+        n += 1
+    return n
 
 def main():
     opts, args = getopt.gnu_getopt(sys.argv[1:], "dhl:p:r:", [
@@ -470,9 +476,11 @@ obfs2|websocket 1.4.6.1:4123\
 
     try:
         with open(options.relay_filename) as fp:
-            parse_relay_file(RELAYS, fp)
+            n = parse_relay_file(RELAYS, fp)
+            if not n:
+                raise ValueError("file contained no relays")
     except ValueError as e:
-        print >> sys.stderr, u"Could not parse file '%s': %s" % (repr(a), str(e))
+        print >> sys.stderr, u"Could not parse file %s: %s" % (repr(options.relay_filename), str(e))
         sys.exit(1)
 
     # Setup log file
diff --git a/facilitator/init.d/facilitator.in b/facilitator/init.d/facilitator.in
index 1a1899b..8ba923f 100755
--- a/facilitator/init.d/facilitator.in
+++ b/facilitator/init.d/facilitator.in
@@ -23,7 +23,7 @@ exec_prefix=@exec_prefix@
 PIDFILE=@localstatedir@/run/$NAME.pid
 LOGFILE=@localstatedir@/log/$NAME.log
 CONFDIR=@sysconfdir@/flashproxy
-RELAYFILE=$CONFDIR/relays
+RELAYFILE=$CONFDIR/facilitator-relays
 PRIVDROP_USER=@fpfacilitatoruser@
 DAEMON=@bindir@/$NAME
 DAEMON_ARGS="--relay-file $RELAYFILE --log $LOGFILE --pidfile $PIDFILE --privdrop-user $PRIVDROP_USER"
diff --git a/facilitator/relays b/facilitator/relays
deleted file mode 100644
index 20ecc25..0000000
--- a/facilitator/relays
+++ /dev/null
@@ -1,4 +0,0 @@
-obfs3|websocket 173.255.221.44:9500
-websocket 173.255.221.44:9901
-obfs3|websocket [2600:3c01::f03c:91ff:fe93:6cd2]:9500
-websocket [2600:3c01::f03c:91ff:fe93:6cd2]:9901





More information about the tor-commits mailing list