[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [flashproxy/master] Send client-transport=websocket in registrations.
commit 5750c751df97b4226ee5820b150cd032686a5b75
Author: David Fifield <david@xxxxxxxxxxxxxxx>
Date: Wed Oct 9 22:38:09 2013 -0700
Send client-transport=websocket in registrations.
---
flashproxy-client | 2 ++
flashproxy-reg-appspot | 2 ++
flashproxy-reg-email | 11 ++++++++++-
flashproxy-reg-http | 12 ++++++++++--
flashproxy-reg-url | 11 ++++++++++-
5 files changed, 34 insertions(+), 4 deletions(-)
diff --git a/flashproxy-client b/flashproxy-client
index 127bfa9..a36f209 100755
--- a/flashproxy-client
+++ b/flashproxy-client
@@ -38,6 +38,7 @@ DEFAULT_LOCAL_PORT_EXTERNAL = 9001
DEFAULT_REMOTE_PORT = 9000
DEFAULT_REGISTER_METHODS = ["appspot", "email", "http"]
DEFAULT_PORT_FORWARDING_HELPER = "tor-fw-helper"
+DEFAULT_TRANSPORT = "websocket"
# We will re-register if we have fewer than this many waiting proxies. The
# facilitator may choose to ignore our requests.
@@ -68,6 +69,7 @@ class options(object):
port_forwarding_external = None
register = False
register_commands = []
+ transport = DEFAULT_TRANSPORT
safe_logging = True
def usage(f = sys.stdout):
diff --git a/flashproxy-reg-appspot b/flashproxy-reg-appspot
index 139cd1e..163ec24 100755
--- a/flashproxy-reg-appspot
+++ b/flashproxy-reg-appspot
@@ -24,6 +24,7 @@ except ImportError:
DEFAULT_REMOTE_ADDRESS = None
DEFAULT_REMOTE_PORT = 9000
+DEFAULT_TRANSPORT = "websocket"
# The domain to which requests appear to go.
FRONT_DOMAIN = "www.google.com"
@@ -75,6 +76,7 @@ class options(object):
address_family = socket.AF_UNSPEC
use_certificate_pin = True
facilitator_pubkey_filename = None
+ transport = DEFAULT_TRANSPORT
safe_logging = True
def usage(f = sys.stdout):
diff --git a/flashproxy-reg-email b/flashproxy-reg-email
index 3fdaf90..add5e97 100755
--- a/flashproxy-reg-email
+++ b/flashproxy-reg-email
@@ -9,6 +9,7 @@ import socket
import ssl
import sys
import tempfile
+import urllib
from hashlib import sha1
@@ -24,6 +25,7 @@ DEFAULT_EMAIL_ADDRESS = "flashproxyreg.a@xxxxxxxxx"
# dig MX gmail.com
DEFAULT_SMTP_HOST = "gmail-smtp-in.l.google.com"
DEFAULT_SMTP_PORT = 25
+DEFAULT_TRANSPORT = "websocket"
# Use this to prevent Python smtplib from guessing and leaking our hostname.
EHLO_FQDN = "[127.0.0.1]"
@@ -93,6 +95,7 @@ class options(object):
email_addr = None
facilitator_pubkey_filename = None
smtp_addr = None
+ transport = DEFAULT_TRANSPORT
safe_logging = True
def usage(f = sys.stdout):
@@ -187,6 +190,12 @@ def format_addr(addr):
def safe_format_addr(addr):
return safe_str(format_addr(addr))
+def build_reg(addr, transport):
+ return urllib.urlencode((
+ ("client", format_addr(addr)),
+ ("client-transport", transport),
+ ))
+
def get_state_dir():
"""Get a directory where we can put temporary files. Returns None if any
suitable temporary directory will do."""
@@ -320,7 +329,7 @@ try:
spec = "[" + spec + "]"
options.remote_addr = parse_addr_spec(spec, *options.remote_addr)
- body_plain = (u"client=%s" % format_addr(options.remote_addr)).encode("utf-8")
+ body_plain = build_reg(options.remote_addr, options.transport)
rsa = get_facilitator_pubkey()
body_crypt = rsa.public_encrypt(body_plain, RSA.pkcs1_oaep_padding)
body = body_crypt.encode("base64")
diff --git a/flashproxy-reg-http b/flashproxy-reg-http
index 2c2f274..4c776c3 100755
--- a/flashproxy-reg-http
+++ b/flashproxy-reg-http
@@ -11,12 +11,14 @@ import urllib2
DEFAULT_REMOTE_ADDRESS = ""
DEFAULT_REMOTE_PORT = 9000
DEFAULT_FACILITATOR_URL = "https://fp-facilitator.org/"
+DEFAULT_TRANSPORT = "websocket"
class options(object):
remote_addr = None
address_family = socket.AF_UNSPEC
facilitator_url = None
+ transport = DEFAULT_TRANSPORT
safe_logging = True
def usage(f = sys.stdout):
@@ -97,6 +99,12 @@ def format_addr(addr):
def safe_format_addr(addr):
return safe_str(format_addr(addr))
+def build_reg(addr, transport):
+ return urllib.urlencode((
+ ("client", format_addr(addr)),
+ ("client-transport", transport),
+ ))
+
options.facilitator_url = DEFAULT_FACILITATOR_URL
options.remote_addr = (DEFAULT_REMOTE_ADDRESS, DEFAULT_REMOTE_PORT)
@@ -128,9 +136,9 @@ if options.address_family != socket.AF_UNSPEC:
return getaddrinfo(host, port, options.address_family, *args, **kwargs)
socket.getaddrinfo = getaddrinfo_replacement
-spec = format_addr(options.remote_addr)
+body = build_reg(options.remote_addr, options.transport)
try:
- http = urllib2.urlopen(options.facilitator_url, urllib.urlencode({"client": spec}), 10)
+ http = urllib2.urlopen(options.facilitator_url, body, 10)
except urllib2.HTTPError, e:
print >> sys.stderr, "Status code was %d, not 200" % e.code
sys.exit(1)
diff --git a/flashproxy-reg-url b/flashproxy-reg-url
index 8fdd2f1..e947650 100755
--- a/flashproxy-reg-url
+++ b/flashproxy-reg-url
@@ -5,6 +5,7 @@ import getopt
import re
import socket
import sys
+import urllib
import urlparse
try:
@@ -16,6 +17,7 @@ except ImportError:
DEFAULT_REMOTE_ADDRESS = None
DEFAULT_REMOTE_PORT = 9000
DEFAULT_FACILITATOR_URL = "https://fp-facilitator.org/"
+DEFAULT_TRANSPORT = "websocket"
DEFAULT_FACILITATOR_PUBKEY_PEM = """\
-----BEGIN PUBLIC KEY-----
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA44Mt8c599/4N2fgu6ppN
@@ -31,6 +33,7 @@ gwIDAQAB
class options(object):
facilitator_url = None
facilitator_pubkey_filename = None
+ transport = DEFAULT_TRANSPORT
def usage(f = sys.stdout):
print >> f, """\
@@ -101,6 +104,12 @@ def format_addr(addr):
result += u":%d" % port
return result
+def build_reg(addr, transport):
+ return urllib.urlencode((
+ ("client", format_addr(addr)),
+ ("client-transport", transport),
+ ))
+
def get_facilitator_pubkey():
if options.facilitator_pubkey_filename is not None:
return RSA.load_pub_key(options.facilitator_pubkey_filename)
@@ -139,7 +148,7 @@ On Debian-like systems, use the command "apt-get install python-m2crypto".\
"""
sys.exit(1)
-reg_plain = (u"client=%s" % format_addr(remote_addr)).encode("utf-8")
+reg_plain = build_reg(remote_addr, options.transport)
rsa = get_facilitator_pubkey()
reg_crypt = rsa.public_encrypt(reg_plain, RSA.pkcs1_oaep_padding)
reg = base64.urlsafe_b64encode(reg_crypt)
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits