[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [flashproxy/master] Merge branch 'master' into email



commit 480c5d1fb2ee8735fd657e659b41b13be564a727
Merge: df62b2c 9e0953c
Author: David Fifield <david@xxxxxxxxxxxxxxx>
Date:   Sun Sep 23 23:33:01 2012 -0700

    Merge branch 'master' into email
    
    Conflicts:
    	flashproxy-client

 README                           |    2 +-
 experiments/exercise/exercise.sh |    2 +-
 experiments/facilitator-graph.py |    2 +-
 facilitator/facilitator          |    1 +
 facilitator/facilitator.cgi      |   13 +--
 facilitator/init.d/facilitator   |    2 +-
 flashproxy-client                |  222 +++++++++++++++++++++++++-------------
 flashproxy-reg-http              |   32 +++---
 flashproxy-test.js               |   12 ++
 flashproxy.js                    |  117 ++++++++++++---------
 10 files changed, 255 insertions(+), 150 deletions(-)

diff --cc facilitator/facilitator.cgi
index 2ef4cfa,a453a20..f35c9a3
--- a/facilitator/facilitator.cgi
+++ b/facilitator/facilitator.cgi
@@@ -17,22 -16,71 +16,20 @@@ Status: %d\
  \r""" % status
      sys.exit()
  
 -def fac_socket():
 -    return socket.create_connection(FACILITATOR_ADDR, 1.0).makefile()
 -
 -def transact(f, command, *params):
 -    transaction = fac.render_transaction(command, *params)
 -    print >> f, transaction
 -    f.flush()
 -    line = f.readline()
 -    if not (len(line) > 0 and line[-1] == '\n'):
 -        raise ValueError("No newline at end of string returned by facilitator")
 -    return fac.parse_transaction(line[:-1])
 -
 -def put_reg(client_addr, registrant_addr):
 -    f = fac_socket()
 -    try:
 -        command, params = transact(f, "PUT", ("CLIENT", fac.format_addr(client_addr)), ("FROM", fac.format_addr(registrant_addr)))
 -    finally:
 -        f.close()
 -    if command == "OK":
 -        pass
 -    else:
 -        exit_error(500)
 -
 -def get_reg(proxy_addr):
 -    f = fac_socket()
 -    try:
 -        command, params = transact(f, "GET", ("FROM", fac.format_addr(proxy_addr)))
 -    finally:
 -        f.close()
 -    if command == "NONE":
 -        return {
 -            "client": ""
 -        }
 -    elif command == "OK":
 -        client_spec = fac.param_first("CLIENT", params)
 -        relay_spec = fac.param_first("RELAY", params)
 -        if not client_spec or not relay_spec:
 -            exit_error(500)
 -        try:
 -            # Check the syntax returned by the backend.
 -            client = fac.parse_addr_spec(client_spec)
 -            relay = fac.parse_addr_spec(relay_spec)
 -        except ValueError:
 -            exit_error(500)
 -        return {
 -            "client": fac.format_addr(client),
 -            "relay": fac.format_addr(relay),
 -        }
 -    else:
 -        exit_error(500)
 -
  method = os.environ.get("REQUEST_METHOD")
- path_info = os.environ.get("PATH_INFO")
  proxy_addr = (os.environ.get("REMOTE_ADDR"), None)
+ path_info = os.environ.get("PATH_INFO") or "/"
  
- if not method or not path_info or not proxy_addr[0]:
+ if not method or not proxy_addr[0]:
      exit_error(400)
  
  fs = cgi.FieldStorage()
  
  def do_get():
-     if path != "/":
+     if path_info != "/":
          exit_error(400)
      try:
 -        reg = get_reg(proxy_addr) or ""
 +        reg = fac.get_reg(FACILITATOR_ADDR, proxy_addr) or ""
      except:
          exit_error(500)
      # Allow XMLHttpRequest from any domain. http://www.w3.org/TR/cors/.
diff --cc flashproxy-client
index 0a830b6,692a0f0..5cc5061
--- a/flashproxy-client
+++ b/flashproxy-client
@@@ -631,15 -659,31 +659,29 @@@ def register_one()
      if not script_dir:
          # Maybe the script was read from stdin; in any case don't guess at the directory.
          return
 -    command = [os.path.join(script_dir, "flashproxy-reg-http")]
 +    command = [os.path.join(script_dir, "flashproxy-reg-email")]
-     spec = format_addr(options.remote_addr)
-     if options.facilitator_addr is None:
-         log(u"Registering \"%s\"." % spec)
+     spec = format_addr(options.register_addr)
+     log(u"Registering \"%s\"." % spec)
 -    if options.facilitator_url is not None:
 -        command += ["-f", options.facilitator_url]
      command += [spec]
      try:
-         p = subprocess.Popen(command)
+         p = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+         stdout, stderr = p.communicate()
      except OSError, e:
-         log(u"Failed to register: %s" % str(e))
+         log(u"Error running registration helper: %s" % str(e))
+         return
+     for line in stdout.splitlines():
+         log(line)
+     for line in stderr.splitlines():
+         log(line)
+     if p.returncode != 0:
+         log("Registration helper ended with status %d." % p.returncode)
+ 
+ def registration_thread_func():
+     while True:
+         register_condvar.acquire()
+         register_condvar.wait()
+         register_condvar.release()
+         register_one()
  
  def proxy_chunk_local_to_remote(local, remote, data = None):
      if data is None:



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits