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

[tor-commits] [flashproxy/master] Merge branch 'common-toplevel'



commit 791c298eeac444d4b982cfff8fd594813a15429b
Merge: 1f2350c 48a19be
Author: Ximin Luo <infinity0@xxxxxxx>
Date:   Tue Nov 5 22:04:11 2013 +0000

    Merge branch 'common-toplevel'
    
    Conflicts:
    	.gitignore
    	Makefile
    	flashproxy-reg-email
    	flashproxy-reg-http
    	flashproxy-reg-url

 .gitignore                |    6 +
 Makefile                  |  126 ++++++++------
 Makefile.client           |   81 +++++++++
 flashproxy-client         |   54 +-----
 flashproxy-client-test    |  402 ---------------------------------------------
 flashproxy-client-test.py |  401 ++++++++++++++++++++++++++++++++++++++++++++
 flashproxy-reg-appspot    |   97 +----------
 flashproxy-reg-email      |  117 +------------
 flashproxy-reg-http       |   52 +-----
 flashproxy-reg-url        |   64 +-------
 flashproxy/keys.py        |   54 ++++++
 flashproxy/util.py        |   52 ++++++
 setup-client-exe.py       |   20 +++
 setup-common.py           |   42 +++++
 setup.py                  |   18 --
 15 files changed, 751 insertions(+), 835 deletions(-)

diff --cc .gitignore
index 0e9120d,70f19a2..439f73d
--- a/.gitignore
+++ b/.gitignore
@@@ -1,5 -1,13 +1,11 @@@
  *.pyc
+ 
+ # built by setup*.py
+ /build
  /dist
+ /*.egg-info
  /py2exe-tmp
+ 
 -/websocket-transport/websocket-client
 -/websocket-transport/websocket-server
 -/modules/nodejs/node_modules
 -/modules/nodejs/flashproxy.js
 +/proxy/modules/nodejs/node_modules
 +/proxy/modules/nodejs/flashproxy.js
+ 
diff --cc Makefile
index 360a6f0,24ef960..3777271
--- a/Makefile
+++ b/Makefile
@@@ -1,63 -1,81 +1,81 @@@
- VERSION = 1.4
+ # Makefile for a self-contained binary distribution of flashproxy-client.
+ #
+ # This builds two zipball targets, dist and dist-exe, for POSIX and Windows
+ # respectively. Both can be extracted and run in-place by the end user.
+ # (PGP-signed forms also exist, sign and sign-exe.)
+ #
+ # If you are a distro packager, instead see the separate build scripts for each
+ # source component, all of which have an `install` target:
+ # - client: Makefile.client
+ # - common: setup-common.py
+ # - facilitator: facilitator/{configure.ac,Makefile.am}
+ #
+ # Not for the faint-hearted: it is possible to build dist-exe on GNU/Linux by
+ # using wine to install the windows versions of Python, py2exe, and m2crypto,
+ # then running `make PYTHON_W32="wine python" dist-exe`.
  
- DESTDIR =
- PREFIX = /usr/local
- BINDIR = $(PREFIX)/bin
- MANDIR = $(PREFIX)/share/man
+ PACKAGE = flashproxy-client
 -VERSION = 1.3
++VERSION = 1.4
+ DISTNAME = $(PACKAGE)-$(VERSION)
  
+ THISFILE = $(lastword $(MAKEFILE_LIST))
  PYTHON = python
- export PY2EXE_TMPDIR = py2exe-tmp
- 
- CLIENT_BIN = flashproxy-client flashproxy-reg-appspot flashproxy-reg-email flashproxy-reg-http flashproxy-reg-url
- CLIENT_MAN = doc/flashproxy-client.1 doc/flashproxy-reg-appspot.1 doc/flashproxy-reg-email.1 doc/flashproxy-reg-http.1 doc/flashproxy-reg-url.1
- CLIENT_DIST_FILES = $(CLIENT_BIN) Makefile README LICENSE ChangeLog torrc
- CLIENT_DIST_DOC_FILES = $(CLIENT_MAN)
- 
- all: $(CLIENT_DIST_FILES) $(CLIENT_MAN)
+ PYTHON_W32 = $(PYTHON)
  
- %.1: %.1.txt
- 	rm -f $@
- 	a2x --no-xmllint --xsltproc-opts "--stringparam man.th.title.max.length 24" -d manpage -f manpage $<
+ MAKE_CLIENT = $(MAKE) -f Makefile.client PYTHON="$(PYTHON)"
  
- install:
- 	mkdir -p $(DESTDIR)$(BINDIR)
- 	mkdir -p $(DESTDIR)$(MANDIR)/man1
- 	cp -f $(CLIENT_BIN) $(DESTDIR)$(BINDIR)
- 	cp -f $(CLIENT_MAN) $(DESTDIR)$(MANDIR)/man1
+ # all is N/A for a binary package, but include for completeness
+ all: dist
  
- DISTNAME = flashproxy-client-$(VERSION)
  DISTDIR = dist/$(DISTNAME)
- dist:
- 	rm -rf dist
+ $(DISTDIR): Makefile.client setup-common.py $(THISFILE)
  	mkdir -p $(DISTDIR)
- 	mkdir $(DISTDIR)/doc
- 	cp -f $(CLIENT_DIST_FILES) $(DISTDIR)
- 	cp -f $(CLIENT_DIST_DOC_FILES) $(DISTDIR)/doc
- 	cd dist && zip -q -r -9 $(DISTNAME).zip $(DISTNAME)
- 
- dist/$(DISTNAME).zip: $(CLIENT_DIST_FILES)
- 	$(MAKE) dist
- 
- sign: dist/$(DISTNAME).zip
- 	rm -f dist/$(DISTNAME).zip.asc
- 	cd dist && gpg --sign --detach-sign --armor $(DISTNAME).zip
- 	cd dist && gpg --verify $(DISTNAME).zip.asc $(DISTNAME).zip
- 
- $(PY2EXE_TMPDIR)/dist: $(CLIENT_BIN)
- 	rm -rf $(PY2EXE_TMPDIR)
- 	$(PYTHON) setup.py py2exe -q
- 
- dist-exe: DISTNAME := $(DISTNAME)-win32
- dist-exe: CLIENT_BIN := $(PY2EXE_TMPDIR)/dist/*
- # Delegate to the "dist" target using the substitutions above.
- dist-exe: $(PY2EXE_TMPDIR)/dist setup.py dist
- 
- clean:
- 	rm -f *.pyc
+ 	$(MAKE_CLIENT) DESTDIR=$(DISTDIR) bindir=/ docdir=/ man1dir=/doc/ \
+ 	  install
+ 	$(PYTHON) setup-common.py build_py -d $(DISTDIR)
+ 
+ dist/%.zip: dist/%
+ 	cd dist && zip -q -r -9 "$(@:dist/%=%)" "$(<:dist/%=%)"
+ 
+ dist/%.zip.asc: dist/%.zip
+ 	rm -f "$@"
+ 	gpg --sign --detach-sign --armor "$<"
+ 	gpg --verify "$@" "$<"
+ 
+ dist: force-dist $(DISTDIR).zip
+ 
+ sign: force-dist $(DISTDIR).zip.asc
+ 
+ PY2EXE_TMPDIR = py2exe-tmp
+ export PY2EXE_TMPDIR
+ $(PY2EXE_TMPDIR): setup-client-exe.py
+ 	$(PYTHON_W32) setup-client-exe.py py2exe -q
+ 
+ DISTDIR_W32 = $(DISTDIR)-win32
+ # below, we override DST_SCRIPT and DST_MAN1 for windows
+ $(DISTDIR_W32): $(PY2EXE_TMPDIR) $(THISFILE)
+ 	mkdir -p $(DISTDIR_W32)
+ 	$(MAKE_CLIENT) DESTDIR=$(DISTDIR_W32) bindir=/ docdir=/ man1dir=/doc/ \
+ 	  DST_SCRIPT= DST_MAN1='$$(SRC_MAN1)' \
+ 	  install
+ 	cp -t $(DISTDIR_W32) $(PY2EXE_TMPDIR)/dist/*
+ 
+ dist-exe: force-dist-exe $(DISTDIR_W32).zip
+ 
+ sign-exe: force-dist-exe $(DISTDIR_W32).zip.asc
+ 
+ # clean is N/A for a binary package, but include for completeness
+ clean: distclean
+ 
+ distclean:
+ 	$(MAKE_CLIENT) clean
+ 	$(PYTHON) setup-common.py clean --all
  	rm -rf dist $(PY2EXE_TMPDIR)
  
- test:
- 	./flashproxy-client-test
+ test: check
+ check:
+ 	$(MAKE_CLIENT) check
+ 	$(PYTHON) setup-common.py check
  	cd facilitator && ./facilitator-test
  	cd proxy && ./flashproxy-test.js
  
diff --cc Makefile.client
index 0000000,ba7f733..0cb676c
mode 000000,100644..100644
--- a/Makefile.client
+++ b/Makefile.client
@@@ -1,0 -1,81 +1,81 @@@
+ # Makefile for a source distribution of flashproxy-client.
+ #
+ # This package is not self-contained and the build products may require other
+ # dependencies to function; it is given as a reference for distro packagers.
+ 
+ PACKAGE = flashproxy-client
 -VERSION = 1.3
++VERSION = 1.4
+ DESTDIR =
+ 
+ THISFILE = $(lastword $(MAKEFILE_LIST))
+ PYTHON = python
+ 
+ # GNU command variables
+ # see http://www.gnu.org/prep/standards/html_node/Command-Variables.html
+ 
+ INSTALL = install
+ INSTALL_DATA = $(INSTALL) -m 644
+ INSTALL_PROGRAM = $(INSTALL)
+ INSTALL_SCRIPT = $(INSTALL)
+ 
+ # GNU directory variables
+ # see http://www.gnu.org/prep/standards/html_node/Directory-Variables.html
+ 
+ prefix = /usr/local
+ exec_prefix = $(prefix)
+ bindir = $(exec_prefix)/bin
+ 
+ datarootdir = $(prefix)/share
+ datadir = $(datarootdir)
+ sysconfdir = $(prefix)/etc
+ 
+ docdir = $(datarootdir)/doc/$(PACKAGE)
+ mandir = $(datarootdir)/man
+ man1dir = $(mandir)/man1
+ 
+ srcdir = .
+ 
+ SRC_MAN1 = doc/flashproxy-client.1.txt doc/flashproxy-reg-appspot.1.txt doc/flashproxy-reg-email.1.txt doc/flashproxy-reg-http.1.txt doc/flashproxy-reg-url.1.txt
+ SRC_SCRIPT = flashproxy-client flashproxy-reg-appspot flashproxy-reg-email flashproxy-reg-http flashproxy-reg-url
+ SRC_DOC = README LICENSE ChangeLog torrc
+ SRC_ALL = $(SRC_SCRIPT) $(SRC_DOC) $(SRC_MAN1)
+ 
+ DST_MAN1 = $(SRC_MAN1:%.1.txt=%.1)
+ DST_SCRIPT = $(SRC_SCRIPT)
+ DST_DOC = $(SRC_DOC)
+ DST_ALL = $(DST_SCRIPT) $(DST_DOC) $(DST_MAN1)
+ 
+ TEST_PY = flashproxy-client-test.py
+ TEST_ALL = $(TEST_PY)
+ 
+ all: $(DST_ALL) $(THISFILE)
+ 
+ %.1: %.1.txt $(THISFILE)
+ 	rm -f $@
+ 	a2x --no-xmllint --xsltproc-opts "--stringparam man.th.title.max.length 24" -d manpage -f manpage $<
+ 
+ install: all
+ 	mkdir -p $(DESTDIR)$(bindir)
+ 	for i in $(DST_SCRIPT); do $(INSTALL_SCRIPT) "$$i" $(DESTDIR)$(bindir); done
+ 	mkdir -p $(DESTDIR)$(docdir)
+ 	for i in $(DST_DOC); do $(INSTALL_DATA) "$$i" $(DESTDIR)$(docdir); done
+ 	mkdir -p $(DESTDIR)$(man1dir)
+ 	for i in $(DST_MAN1); do $(INSTALL_DATA) "$$i" $(DESTDIR)$(man1dir); done
+ 
+ uninstall:
+ 	for i in $(notdir $(DST_SCRIPT)); do rm $(DESTDIR)$(bindir)/"$$i"; done
+ 	for i in $(notdir $(DST_DOC)); do rm $(DESTDIR)$(docdir)/"$$i"; done
+ 	for i in $(notdir $(DST_MAN1)); do rm $(DESTDIR)$(man1dir)/"$$i"; done
+ 
+ clean:
+ 	rm -f *.pyc
+ 
+ distclean: clean
+ 
+ maintainer-clean: distclean
+ 	rm -f $(DST_MAN1)
+ 
+ check: $(THISFILE)
+ 	for i in $(TEST_PY); do $(PYTHON) "$$i"; done
+ 
+ .PHONY: all install uninstall clean distclean maintainer-clean dist check
diff --cc flashproxy-reg-appspot
index 0f51e4f,fc49985..c47579c
--- a/flashproxy-reg-appspot
+++ b/flashproxy-reg-appspot
@@@ -33,50 -34,10 +35,11 @@@ TARGET_DOMAIN = "fp-reg-a.appspot.com
  
  FLASHPROXY_REG_URL = "flashproxy-reg-url"
  
- # We trust no other CA certificate than this.
- #
- # To find the certificate to copy here,
- # $ strace openssl s_client -connect FRONT_DOMAIN:443 -verify 10 -CApath /etc/ssl/certs 2>&1 | grep /etc/ssl/certs
- # stat("/etc/ssl/certs/XXXXXXXX.0", {st_mode=S_IFREG|0644, st_size=YYYY, ...}) = 0
- CA_CERTS = """\
- subject=/C=US/O=Equifax/OU=Equifax Secure Certificate Authority
- issuer=/C=US/O=Equifax/OU=Equifax Secure Certificate Authority
- -----BEGIN CERTIFICATE-----
- MIIDIDCCAomgAwIBAgIENd70zzANBgkqhkiG9w0BAQUFADBOMQswCQYDVQQGEwJV
- UzEQMA4GA1UEChMHRXF1aWZheDEtMCsGA1UECxMkRXF1aWZheCBTZWN1cmUgQ2Vy
- dGlmaWNhdGUgQXV0aG9yaXR5MB4XDTk4MDgyMjE2NDE1MVoXDTE4MDgyMjE2NDE1
- MVowTjELMAkGA1UEBhMCVVMxEDAOBgNVBAoTB0VxdWlmYXgxLTArBgNVBAsTJEVx
- dWlmYXggU2VjdXJlIENlcnRpZmljYXRlIEF1dGhvcml0eTCBnzANBgkqhkiG9w0B
- AQEFAAOBjQAwgYkCgYEAwV2xWGcIYu6gmi0fCG2RFGiYCh7+2gRvE4RiIcPRfM6f
- BeC4AfBONOziipUEZKzxa1NfBbPLZ4C/QgKO/t0BCezhABRP/PvwDN1Dulsr4R+A
- cJkVV5MW8Q+XarfCaCMczE1ZMKxRHjuvK9buY0V7xdlfUNLjUA86iOe/FP3gx7kC
- AwEAAaOCAQkwggEFMHAGA1UdHwRpMGcwZaBjoGGkXzBdMQswCQYDVQQGEwJVUzEQ
- MA4GA1UEChMHRXF1aWZheDEtMCsGA1UECxMkRXF1aWZheCBTZWN1cmUgQ2VydGlm
- aWNhdGUgQXV0aG9yaXR5MQ0wCwYDVQQDEwRDUkwxMBoGA1UdEAQTMBGBDzIwMTgw
- ODIyMTY0MTUxWjALBgNVHQ8EBAMCAQYwHwYDVR0jBBgwFoAUSOZo+SvSspXXR9gj
- IBBPM5iQn9QwHQYDVR0OBBYEFEjmaPkr0rKV10fYIyAQTzOYkJ/UMAwGA1UdEwQF
- MAMBAf8wGgYJKoZIhvZ9B0EABA0wCxsFVjMuMGMDAgbAMA0GCSqGSIb3DQEBBQUA
- A4GBAFjOKer89961zgK5F7WF0bnj4JXMJTENAKaSbn+2kmOeUJXRmm/kEd5jhW6Y
- 7qj/WsjTVbJmcVfewCHrPSqnI0kBBIZCe/zuf6IWUrVnZ9NA2zsmWLIodz2uFHdh
- 1voqZiegDfqnc1zqcPGUIWVEX/r87yloqaKHee9570+sB3c4
- -----END CERTIFICATE-----
- """
- # SHA-1 digest of expected public keys. Any of these is valid. See
- # http://www.imperialviolet.org/2011/05/04/pinning.html for the reason behind
- # hashing the public key, not the entire certificate.
- PUBKEY_SHA1 = (
-     # https://src.chromium.org/viewvc/chrome/trunk/src/net/http/transport_security_state_static.h?revision=209003&view=markup
-     # kSPKIHash_Google1024
-     "\x40\xc5\x40\x1d\x6f\x8c\xba\xf0\x8b\x00\xed\xef\xb1\xee\x87\xd0\x05\xb3\xb9\xcd",
-     # kSPKIHash_GoogleG2
-     "\x43\xda\xd6\x30\xee\x53\xf8\xa9\x80\xca\x6e\xfd\x85\xf4\x6a\xa3\x79\x90\xe0\xea",
- )
- 
  class options(object):
      address_family = socket.AF_UNSPEC
 -    facilitator_pubkey_filename = None
      use_certificate_pin = True
 +    facilitator_pubkey_filename = None
 +    transport = DEFAULT_TRANSPORT
      safe_logging = True
  
  def usage(f = sys.stdout):
diff --cc flashproxy-reg-email
index 4b99de8,0cb626b..8bc8b6f
--- a/flashproxy-reg-email
+++ b/flashproxy-reg-email
@@@ -9,8 -9,9 +9,10 @@@ import socke
  import ssl
  import sys
  import tempfile
 +import urllib
  
+ from flashproxy.keys import PIN_GOOGLE_CERT, PIN_GOOGLE_PUBKEY_SHA1, DEFAULT_FACILITATOR_PUBKEY_PEM
+ from flashproxy.util import parse_addr_spec, format_addr
  from hashlib import sha1
  
  try:
@@@ -31,71 -31,14 +33,16 @@@ DEFAULT_TRANSPORT = "websocket
  EHLO_FQDN = "[127.0.0.1]"
  FROM_EMAIL_ADDRESS = "nobody@localhost"
  
- # We trust no other CA certificate than this.
- #
- # To find the certificate to copy here,
- # $ strace openssl s_client -connect gmail-smtp-in.l.google.com:25 -starttls smtp -verify 10 -CApath /etc/ssl/certs 2>&1 | grep /etc/ssl/certs
- # stat("/etc/ssl/certs/XXXXXXXX.0", {st_mode=S_IFREG|0644, st_size=YYYY, ...}) = 0
- CA_CERTS = """\
- subject=/C=US/O=Equifax/OU=Equifax Secure Certificate Authority
- issuer=/C=US/O=Equifax/OU=Equifax Secure Certificate Authority
- -----BEGIN CERTIFICATE-----
- MIIDIDCCAomgAwIBAgIENd70zzANBgkqhkiG9w0BAQUFADBOMQswCQYDVQQGEwJV
- UzEQMA4GA1UEChMHRXF1aWZheDEtMCsGA1UECxMkRXF1aWZheCBTZWN1cmUgQ2Vy
- dGlmaWNhdGUgQXV0aG9yaXR5MB4XDTk4MDgyMjE2NDE1MVoXDTE4MDgyMjE2NDE1
- MVowTjELMAkGA1UEBhMCVVMxEDAOBgNVBAoTB0VxdWlmYXgxLTArBgNVBAsTJEVx
- dWlmYXggU2VjdXJlIENlcnRpZmljYXRlIEF1dGhvcml0eTCBnzANBgkqhkiG9w0B
- AQEFAAOBjQAwgYkCgYEAwV2xWGcIYu6gmi0fCG2RFGiYCh7+2gRvE4RiIcPRfM6f
- BeC4AfBONOziipUEZKzxa1NfBbPLZ4C/QgKO/t0BCezhABRP/PvwDN1Dulsr4R+A
- cJkVV5MW8Q+XarfCaCMczE1ZMKxRHjuvK9buY0V7xdlfUNLjUA86iOe/FP3gx7kC
- AwEAAaOCAQkwggEFMHAGA1UdHwRpMGcwZaBjoGGkXzBdMQswCQYDVQQGEwJVUzEQ
- MA4GA1UEChMHRXF1aWZheDEtMCsGA1UECxMkRXF1aWZheCBTZWN1cmUgQ2VydGlm
- aWNhdGUgQXV0aG9yaXR5MQ0wCwYDVQQDEwRDUkwxMBoGA1UdEAQTMBGBDzIwMTgw
- ODIyMTY0MTUxWjALBgNVHQ8EBAMCAQYwHwYDVR0jBBgwFoAUSOZo+SvSspXXR9gj
- IBBPM5iQn9QwHQYDVR0OBBYEFEjmaPkr0rKV10fYIyAQTzOYkJ/UMAwGA1UdEwQF
- MAMBAf8wGgYJKoZIhvZ9B0EABA0wCxsFVjMuMGMDAgbAMA0GCSqGSIb3DQEBBQUA
- A4GBAFjOKer89961zgK5F7WF0bnj4JXMJTENAKaSbn+2kmOeUJXRmm/kEd5jhW6Y
- 7qj/WsjTVbJmcVfewCHrPSqnI0kBBIZCe/zuf6IWUrVnZ9NA2zsmWLIodz2uFHdh
- 1voqZiegDfqnc1zqcPGUIWVEX/r87yloqaKHee9570+sB3c4
- -----END CERTIFICATE-----
- """
- # SHA-1 digest of expected public keys. Any of these is valid. See
- # http://www.imperialviolet.org/2011/05/04/pinning.html for the reason behind
- # hashing the public key, not the entire certificate.
- PUBKEY_SHA1 = (
-     # https://src.chromium.org/viewvc/chrome/trunk/src/net/http/transport_security_state_static.h?revision=209003&view=markup
-     # kSPKIHash_Google1024
-     "\x40\xc5\x40\x1d\x6f\x8c\xba\xf0\x8b\x00\xed\xef\xb1\xee\x87\xd0\x05\xb3\xb9\xcd",
-     # kSPKIHash_GoogleG2
-     "\x43\xda\xd6\x30\xee\x53\xf8\xa9\x80\xca\x6e\xfd\x85\xf4\x6a\xa3\x79\x90\xe0\xea",
- )
- 
- # Registrations are encrypted with this public key before being emailed. Only
- # the facilitator operators should have the corresponding private key. Given a
- # private key in reg-email, get the public key like this:
- # openssl rsa -pubout < reg-email > reg-email.pub
- DEFAULT_FACILITATOR_PUBKEY_PEM = """\
- -----BEGIN PUBLIC KEY-----
- MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA44Mt8c599/4N2fgu6ppN
- oatPW1GOgZxxObljFtEy0OWM1eHB35OOn+Kn9MxNHTRxVWwCEi0HYxWNVs2qrXxV
- 84LmWBz6A65d2qBlgltgLXusiXLrpwxVmJeO+GfmbF8ur0U9JSYxA20cGW/kujNg
- XYDGQxO1Gvxq2lHK2LQmBpkfKEE1DMFASmIvlHDQgDj3XBb5lYeOsHZmg16UrGAq
- 1UH238hgJITPGLXBtwLtJkYbrATJvrEcmvI7QSm57SgYGpaB5ZdCbJL5bag5Pgt6
- M5SDDYYY4xxEPzokjFJfCQv+kcyAnzERNMQ9kR41ePTXG62bpngK5iWGeJ5XdkxG
- gwIDAQAB
- -----END PUBLIC KEY-----
- """
- 
  class options(object):
      remote_addr = None
 -    email_addr = None
 -    smtp_addr = None
 -    debug = False
 +
      address_family = socket.AF_UNSPEC
 -    facilitator_pubkey_filename = None
 +    debug = False
      use_certificate_pin = True
 +    email_addr = None
 +    facilitator_pubkey_filename = None
 +    smtp_addr = None
 +    transport = DEFAULT_TRANSPORT
      safe_logging = True
  
  def usage(f = sys.stdout):
diff --cc flashproxy-reg-http
index 8aa9397,6639e57..1b97323
--- a/flashproxy-reg-http
+++ b/flashproxy-reg-http
@@@ -49,65 -45,6 +51,15 @@@ def safe_str(s)
      else:
          return s
  
- def parse_addr_spec(spec, defhost = None, defport = None):
-     host = None
-     port = None
-     af = 0
-     m = None
-     # IPv6 syntax.
-     if not m:
-         m = re.match(ur'^\[(.+)\]:(\d*)$', spec)
-         if m:
-             host, port = m.groups()
-             af = socket.AF_INET6
-     if not m:
-         m = re.match(ur'^\[(.+)\]$', spec)
-         if m:
-             host, = m.groups()
-             af = socket.AF_INET6
-     # IPv4/hostname/port-only syntax.
-     if not m:
-         try:
-             host, port = spec.split(":", 1)
-         except ValueError:
-             host = spec
-         if re.match(ur'^[\d.]+$', host):
-             af = socket.AF_INET
-         else:
-             af = 0
-     host = host or defhost
-     port = port or defport
-     if port is not None:
-         port = int(port)
-     return host, port
- 
- def format_addr(addr):
-     host, port = addr
-     if not host:
-         return u":%d" % port
-     # Numeric IPv6 address?
-     try:
-         addrs = socket.getaddrinfo(host, port, 0, socket.SOCK_STREAM, socket.IPPROTO_TCP, socket.AI_NUMERICHOST)
-         af = addrs[0][0]
-     except socket.gaierror, e:
-         af = 0
-     if af == socket.AF_INET6:
-         result = u"[%s]" % host
-     else:
-         result = "%s" % host
-     if port is not None:
-         result += u":%d" % port
-     return result
- 
 +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)
  
diff --cc flashproxy-reg-url
index 26675a0,1c0b348..99503a0
--- a/flashproxy-reg-url
+++ b/flashproxy-reg-url
@@@ -5,9 -5,11 +5,12 @@@ import getop
  import re
  import socket
  import sys
 +import urllib
  import urlparse
  
+ from flashproxy.keys import DEFAULT_FACILITATOR_PUBKEY_PEM
+ from flashproxy.util import parse_addr_spec, format_addr
+ 
  try:
      from M2Crypto import BIO, RSA
  except ImportError:
@@@ -17,18 -19,6 +20,7 @@@
  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
- oatPW1GOgZxxObljFtEy0OWM1eHB35OOn+Kn9MxNHTRxVWwCEi0HYxWNVs2qrXxV
- 84LmWBz6A65d2qBlgltgLXusiXLrpwxVmJeO+GfmbF8ur0U9JSYxA20cGW/kujNg
- XYDGQxO1Gvxq2lHK2LQmBpkfKEE1DMFASmIvlHDQgDj3XBb5lYeOsHZmg16UrGAq
- 1UH238hgJITPGLXBtwLtJkYbrATJvrEcmvI7QSm57SgYGpaB5ZdCbJL5bag5Pgt6
- M5SDDYYY4xxEPzokjFJfCQv+kcyAnzERNMQ9kR41ePTXG62bpngK5iWGeJ5XdkxG
- gwIDAQAB
- -----END PUBLIC KEY-----
- """
  
  class options(object):
      facilitator_url = None
@@@ -54,65 -41,8 +46,15 @@@ default PORT is %(port)d
      "progname": sys.argv[0],
      "fac_url": DEFAULT_FACILITATOR_URL,
      "port": DEFAULT_REMOTE_PORT,
 +    "transport": DEFAULT_TRANSPORT,
  }
  
- def parse_addr_spec(spec, defhost = None, defport = None):
-     host = None
-     port = None
-     af = 0
-     m = None
-     # IPv6 syntax.
-     if not m:
-         m = re.match(ur'^\[(.+)\]:(\d*)$', spec)
-         if m:
-             host, port = m.groups()
-             af = socket.AF_INET6
-     if not m:
-         m = re.match(ur'^\[(.+)\]$', spec)
-         if m:
-             host, = m.groups()
-             af = socket.AF_INET6
-     # IPv4/hostname/port-only syntax.
-     if not m:
-         try:
-             host, port = spec.split(":", 1)
-         except ValueError:
-             host = spec
-         if re.match(ur'^[\d.]+$', host):
-             af = socket.AF_INET
-         else:
-             af = 0
-     host = host or defhost
-     port = port or defport
-     if port is not None:
-         port = int(port)
-     return host, port
- 
- def format_addr(addr):
-     host, port = addr
-     if not host:
-         return u":%d" % port
-     # Numeric IPv6 address?
-     try:
-         addrs = socket.getaddrinfo(host, port, 0, socket.SOCK_STREAM, socket.IPPROTO_TCP, socket.AI_NUMERICHOST)
-         af = addrs[0][0]
-     except socket.gaierror, e:
-         af = 0
-     if af == socket.AF_INET6:
-         result = u"[%s]" % host
-     else:
-         result = "%s" % host
-     if port is not None:
-         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)
diff --cc setup-common.py
index 0000000,85bb325..5d98fd9
mode 000000,100755..100755
--- a/setup-common.py
+++ b/setup-common.py
@@@ -1,0 -1,42 +1,42 @@@
+ #!/usr/bin/env python
+ """Setup file for the flashproxy-common python module.
+ 
+ To build/install a self-contained binary distribution of flashproxy-client
+ (which integrates this module within it), see Makefile.
+ """
+ # Note to future developers:
+ #
+ # We place flashproxy-common in the same directory as flashproxy-client for
+ # convenience, so that it's possible to run the client programs directly from
+ # a source checkout without needing to set PYTHONPATH. This works OK currently
+ # because flashproxy-client does not contain python modules, only programs, and
+ # therefore doesn't conflict with the flashproxy-common module.
+ #
+ # If we ever need to have a python module specific to flashproxy-client, the
+ # natural thing would be to add a setup.py for it. That is the reason why this
+ # file is called setup-common.py instead. However, there are still issues that
+ # arise from having two setup*.py files in the same directory, which is an
+ # unfortunate limitation of python's setuptools.
+ #
+ # See discussion on #6810 for more details.
+ 
+ import sys
+ 
+ from setuptools import setup, find_packages
+ 
+ setup(
+     name = "flashproxy-common",
+     author = "dcf",
+     author_email = "dcf@xxxxxxxxxxxxxx",
+     description = ("Common code for flashproxy"),
+     license = "BSD",
+     keywords = ['tor', 'flashproxy'],
+ 
+     packages = find_packages(),
+ 
 -    version = "1.3",
++    version = "1.4",
+ 
+     install_requires = [
+         'setuptools',
+         ],
+ )



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