aboutsummaryrefslogtreecommitdiff
path: root/src/gns/proxy
diff options
context:
space:
mode:
authorMartin Schanzenbach <mschanzenbach@posteo.de>2012-04-03 13:59:59 +0000
committerMartin Schanzenbach <mschanzenbach@posteo.de>2012-04-03 13:59:59 +0000
commitaa6d10053e613669fe75db8b926c75f0b26419f5 (patch)
tree1f8a8583dfd17e8185351dbe6545b630e4324abd /src/gns/proxy
parent12a1d5b119265e96eb293275b8a504c19e32ad61 (diff)
downloadgnunet-aa6d10053e613669fe75db8b926c75f0b26419f5.tar.gz
gnunet-aa6d10053e613669fe75db8b926c75f0b26419f5.zip
-fix
Diffstat (limited to 'src/gns/proxy')
-rw-r--r--src/gns/proxy/gnunet-gns-proxy.py12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/gns/proxy/gnunet-gns-proxy.py b/src/gns/proxy/gnunet-gns-proxy.py
index d53776872..dd7340ab6 100644
--- a/src/gns/proxy/gnunet-gns-proxy.py
+++ b/src/gns/proxy/gnunet-gns-proxy.py
@@ -44,6 +44,8 @@ class ProxyHandler (BaseHTTPServer.BaseHTTPRequestHandler):
44 i = netloc.find(':') 44 i = netloc.find(':')
45 to_replace = "" 45 to_replace = ""
46 if i >= 0: 46 if i >= 0:
47 self.host_port = netloc[:i], int(netloc[i+1:])
48 if (re.match("(\w+\.)*gnunet$", self.host_port[0])):
47 print 'calling gnunet-gns -a '+netloc[:i] 49 print 'calling gnunet-gns -a '+netloc[:i]
48 auth = os.popen("gnunet-gns -a "+netloc[:i]) 50 auth = os.popen("gnunet-gns -a "+netloc[:i])
49 lines = auth.readlines() 51 lines = auth.readlines()
@@ -52,8 +54,9 @@ class ProxyHandler (BaseHTTPServer.BaseHTTPRequestHandler):
52 to_replace = lines[0].split(" ")[-1].rstrip() 54 to_replace = lines[0].split(" ")[-1].rstrip()
53 else: 55 else:
54 to_replace = "+" 56 to_replace = "+"
55 self.host_port = netloc[:i], int(netloc[i+1:])
56 else: 57 else:
58 self.host_port = netloc, 80
59 if (re.match("(\w+\.)*gnunet$", self.host_port[0])):
57 print 'calling gnunet-gns -a '+netloc 60 print 'calling gnunet-gns -a '+netloc
58 auth = os.popen("gnunet-gns -a "+netloc) 61 auth = os.popen("gnunet-gns -a "+netloc)
59 lines = auth.readlines() 62 lines = auth.readlines()
@@ -62,7 +65,7 @@ class ProxyHandler (BaseHTTPServer.BaseHTTPRequestHandler):
62 to_replace = lines[0].split(" ")[-1].rstrip() 65 to_replace = lines[0].split(" ")[-1].rstrip()
63 else: 66 else:
64 to_replace = "+" 67 to_replace = "+"
65 self.host_port = netloc, 80 68
66 print "\t" "connect to %s:%d" % self.host_port 69 print "\t" "connect to %s:%d" % self.host_port
67 try: soc.connect(self.host_port) 70 try: soc.connect(self.host_port)
68 except socket.error, arg: 71 except socket.error, arg:
@@ -137,7 +140,7 @@ class ProxyHandler (BaseHTTPServer.BaseHTTPRequestHandler):
137 self.command, 140 self.command,
138 urlparse.urlunparse(('', '', path, params, query, '')), 141 urlparse.urlunparse(('', '', path, params, query, '')),
139 self.request_version)) 142 self.request_version))
140 if (re.match("(\w+\.)*gnunet", self.headers['Host'])): 143 if (re.match("(\w+\.)*gnunet$", self.headers['Host'])):
141 leho = os.popen("gnunet-gns -t LEHO -u "+self.headers['Host']).readlines() 144 leho = os.popen("gnunet-gns -t LEHO -u "+self.headers['Host']).readlines()
142 if (len(leho) < 2): 145 if (len(leho) < 2):
143 print "Legacy hostname lookup failed!" 146 print "Legacy hostname lookup failed!"
@@ -181,12 +184,13 @@ class ProxyHandler (BaseHTTPServer.BaseHTTPRequestHandler):
181 data = re.sub(r'\nAccept-Ranges: \w+', r'', data) 184 data = re.sub(r'\nAccept-Ranges: \w+', r'', data)
182 data = re.sub('(a href="http://(\w+\.)*zkey)', 185 data = re.sub('(a href="http://(\w+\.)*zkey)',
183 self.shorten_zkey(), data) 186 self.shorten_zkey(), data)
184 if (re.match("(\w+\.)*gnunet", self.host_port[0])): 187 if (re.match("(\w+\.)*gnunet$", self.host_port[0])):
185 arr = self.host_port[0].split('.') 188 arr = self.host_port[0].split('.')
186 arr.pop(0) 189 arr.pop(0)
187 data = re.sub('(a href="http://(\w+\.)*)(\+)', 190 data = re.sub('(a href="http://(\w+\.)*)(\+)',
188 self.replace_and_shorten(to_repl), data) 191 self.replace_and_shorten(to_repl), data)
189 out.send(data) 192 out.send(data)
193 print data
190 count = 0 194 count = 0
191 #except: 195 #except:
192 # print "GNS exception:", sys.exc_info()[0] 196 # print "GNS exception:", sys.exc_info()[0]