Ticket #1007: 1007-http-proxy-support.patch

File 1007-http-proxy-support.patch, 2.0 KB (added by duck, at 2011-01-12T21:40:30Z)

HTTP Proxy support to Foolscap v2

  • src/allmydata/node.py

    diff --git src/allmydata/node.py src/allmydata/node.py
    index 7f5bf61..f55ba3f 100644
    class Node(service.MultiService): 
    155155            # N.B.: this is in seconds, so use "1800" to get 30min
    156156            self.tub.setOption("disconnectTimeout", int(disconnect_timeout_s))
    157157
     158        http_proxy = self.get_config("node", "http_proxy", "")
     159        if http_proxy:
     160            self.tub.setOption("http-proxy", http_proxy)
     161
    158162        self.nodeid = b32decode(self.tub.tubID.upper()) # binary format
    159163        self.write_config("my_nodeid", b32encode(self.nodeid).lower() + "\n")
    160164        self.short_nodeid = b32encode(self.nodeid).lower()[:8] # ready for printing
  • src/allmydata/scripts/create_node.py

    diff --git src/allmydata/scripts/create_node.py src/allmydata/scripts/create_node.py
    index 928add1..ff514d5 100644
    def write_node_config(c, config): 
    7979        webport = ""
    8080    c.write("web.port = %s\n" % (webport.encode('utf-8'),))
    8181    c.write("web.static = public_html\n")
     82    c.write("#http_proxy =\n")
    8283    c.write("#tub.port =\n")
    8384    c.write("#tub.location = \n")
    8485    c.write("#log_gatherer.furl =\n")
  • src/allmydata/test/test_node.py

    diff --git src/allmydata/test/test_node.py src/allmydata/test/test_node.py
    index 24ec571..08593ef 100644
    class TestCase(testutil.SignalMixin, unittest.TestCase): 
    3131        d.addCallback(flushEventualQueue)
    3232        return d
    3333
     34    def test_http_proxy(self):
     35        basedir = "test_node/test_http_proxy"
     36        fileutil.make_dirs(basedir)
     37        f = open(os.path.join(basedir, 'tahoe.cfg'), 'wt')
     38        f.write("[node]\n")
     39        f.write("http_proxy = 127.0.0.1:8888\n")
     40        f.close()
     41
     42        n = TestNode(basedir)
     43        self.failUnlessEqual(n.tub.options['http-proxy'], "127.0.0.1:8888")
     44
    3445    def test_location(self):
    3546        basedir = "test_node/test_location"
    3647        fileutil.make_dirs(basedir)