aboutsummaryrefslogtreecommitdiff
path: root/src/gns/proxy/gnunet-gns-proxy.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/gns/proxy/gnunet-gns-proxy.py')
-rw-r--r--src/gns/proxy/gnunet-gns-proxy.py27
1 files changed, 22 insertions, 5 deletions
diff --git a/src/gns/proxy/gnunet-gns-proxy.py b/src/gns/proxy/gnunet-gns-proxy.py
index 094f5412c..f13a0adad 100644
--- a/src/gns/proxy/gnunet-gns-proxy.py
+++ b/src/gns/proxy/gnunet-gns-proxy.py
@@ -47,15 +47,21 @@ class ProxyHandler (BaseHTTPServer.BaseHTTPRequestHandler):
47 print 'calling gnunet-gns -a '+netloc[:i] 47 print 'calling gnunet-gns -a '+netloc[:i]
48 auth = os.popen("gnunet-gns -a "+netloc[:i]) 48 auth = os.popen("gnunet-gns -a "+netloc[:i])
49 lines = auth.readlines() 49 lines = auth.readlines()
50 print 'result: '+lines[0].split(" ")[-1].rstrip() 50 if (len(lines) > 0):
51 to_replace = lines[0].split(" ")[-1].rstrip() 51 print 'result: '+lines[0].split(" ")[-1].rstrip()
52 to_replace = lines[0].split(" ")[-1].rstrip()
53 else:
54 to_replace = "+"
52 self.host_port = netloc[:i], int(netloc[i+1:]) 55 self.host_port = netloc[:i], int(netloc[i+1:])
53 else: 56 else:
54 print 'calling gnunet-gns -a '+netloc 57 print 'calling gnunet-gns -a '+netloc
55 auth = os.popen("gnunet-gns -a "+netloc) 58 auth = os.popen("gnunet-gns -a "+netloc)
56 lines = auth.readlines() 59 lines = auth.readlines()
57 print 'result: '+lines[0].split(" ")[-1].rstrip() 60 if (len(lines) > 0):
58 to_replace = lines[0].split(" ")[-1].rstrip() 61 print 'result: '+lines[0].split(" ")[-1].rstrip()
62 to_replace = lines[0].split(" ")[-1].rstrip()
63 else:
64 to_replace = "+"
59 self.host_port = netloc, 80 65 self.host_port = netloc, 80
60 print "\t" "connect to %s:%d" % self.host_port 66 print "\t" "connect to %s:%d" % self.host_port
61 try: soc.connect(self.host_port) 67 try: soc.connect(self.host_port)
@@ -84,9 +90,20 @@ class ProxyHandler (BaseHTTPServer.BaseHTTPRequestHandler):
84 90
85 def shorten_zkey(self): 91 def shorten_zkey(self):
86 return lambda mo: 'a href="http://'+os.popen("gnunet-gns -s"+string.replace(mo.group(1), 'a href="http://', "")).readlines()[0].split(" ")[-1].rstrip() 92 return lambda mo: 'a href="http://'+os.popen("gnunet-gns -s"+string.replace(mo.group(1), 'a href="http://', "")).readlines()[0].split(" ")[-1].rstrip()
93
94 def test_re(self, to_repl, mo):
95 short = os.popen("gnunet-gns -s "+string.replace(mo.group(1)+to_repl, 'a href="http://', ""))
96 lines = short.readlines()
97 if (len(lines) < 1):
98 return to_repl
99 elif (len(lines.split(" ")) > 0):
100 return 'a href="http://'+lines.split(" ")[-1].rstrip()
101 else:
102 return to_repl
87 103
88 def replace_and_shorten(self, to_repl): 104 def replace_and_shorten(self, to_repl):
89 return lambda mo: 'a href="http://'+os.popen("gnunet-gns -s "+string.replace(mo.group(1)+to_repl, 'a href="http://', "")).readlines()[0].split(" ")[-1].rstrip() 105 return lambda mo: test_re(self, to_repl, mo)
106 # return lambda mo: 'a href="http://'+os.popen("gnunet-gns -s "+string.replace(mo.group(1)+to_repl, 'a href="http://', "")).readlines()[0].split(" ")[-1].rstrip()
90 #full = string.replace(mo.group(1)+to_repl, 'a href="http://', "") 107 #full = string.replace(mo.group(1)+to_repl, 'a href="http://', "")
91 #print 'calling gnunet-gns -s '+full 108 #print 'calling gnunet-gns -s '+full
92 #s = os.popen("gnunet-gns -s "+full) 109 #s = os.popen("gnunet-gns -s "+full)