summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Schanzenbach <mschanzenbach@posteo.de>2012-04-03 13:08:07 +0000
committerMartin Schanzenbach <mschanzenbach@posteo.de>2012-04-03 13:08:07 +0000
commit766391abef01aa3106c9abc447a07588cc4cae93 (patch)
tree4098fd5396e29a7b15a8c67f05b8a1848f206a14
parent598349666a7d4afd68c9b4192faf63d5ea836299 (diff)
-fix
-rw-r--r--src/gns/proxy/gnunet-gns-proxy.py27
-rw-r--r--src/gns/test_gns_defaults.conf75
2 files changed, 97 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):
print 'calling gnunet-gns -a '+netloc[:i]
auth = os.popen("gnunet-gns -a "+netloc[:i])
lines = auth.readlines()
- print 'result: '+lines[0].split(" ")[-1].rstrip()
- to_replace = lines[0].split(" ")[-1].rstrip()
+ if (len(lines) > 0):
+ print 'result: '+lines[0].split(" ")[-1].rstrip()
+ to_replace = lines[0].split(" ")[-1].rstrip()
+ else:
+ to_replace = "+"
self.host_port = netloc[:i], int(netloc[i+1:])
else:
print 'calling gnunet-gns -a '+netloc
auth = os.popen("gnunet-gns -a "+netloc)
lines = auth.readlines()
- print 'result: '+lines[0].split(" ")[-1].rstrip()
- to_replace = lines[0].split(" ")[-1].rstrip()
+ if (len(lines) > 0):
+ print 'result: '+lines[0].split(" ")[-1].rstrip()
+ to_replace = lines[0].split(" ")[-1].rstrip()
+ else:
+ to_replace = "+"
self.host_port = netloc, 80
print "\t" "connect to %s:%d" % self.host_port
try: soc.connect(self.host_port)
@@ -84,9 +90,20 @@ class ProxyHandler (BaseHTTPServer.BaseHTTPRequestHandler):
def shorten_zkey(self):
return lambda mo: 'a href="http://'+os.popen("gnunet-gns -s"+string.replace(mo.group(1), 'a href="http://', "")).readlines()[0].split(" ")[-1].rstrip()
+
+ def test_re(self, to_repl, mo):
+ short = os.popen("gnunet-gns -s "+string.replace(mo.group(1)+to_repl, 'a href="http://', ""))
+ lines = short.readlines()
+ if (len(lines) < 1):
+ return to_repl
+ elif (len(lines.split(" ")) > 0):
+ return 'a href="http://'+lines.split(" ")[-1].rstrip()
+ else:
+ return to_repl
def replace_and_shorten(self, to_repl):
- 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()
+ return lambda mo: test_re(self, to_repl, mo)
+ # 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()
#full = string.replace(mo.group(1)+to_repl, 'a href="http://', "")
#print 'calling gnunet-gns -s '+full
#s = os.popen("gnunet-gns -s "+full)
diff --git a/src/gns/test_gns_defaults.conf b/src/gns/test_gns_defaults.conf
new file mode 100644
index 000000000..762c9641b
--- /dev/null
+++ b/src/gns/test_gns_defaults.conf
@@ -0,0 +1,75 @@
+[PATHS]
+SERVICEHOME = /tmp/test-gnunet-testing/
+DEFAULTCONFIG = test_testing_defaults.conf
+
+[resolver]
+PORT = 2564
+
+[transport]
+PORT = 2565
+PLUGINS = tcp
+
+[arm]
+PORT = 2566
+DEFAULTSERVICES =
+
+[statistics]
+PORT = 2567
+
+[transport-tcp]
+PORT = 2568
+BINDTO = 127.0.0.1
+
+[peerinfo]
+PORT = 2569
+
+[core]
+PORT = 2570
+
+[testing]
+NUM_PEERS = 5
+WEAKRANDOM = YES
+F2F = YES
+HOSTKEYSFILE = ../../contrib/testing_hostkeys.dat
+
+[dht]
+AUTOSTART = NO
+
+[nat]
+DISABLEV6 = YES
+ENABLE_UPNP = NO
+BEHIND_NAT = NO
+ALLOW_NAT = NO
+INTERNAL_ADDRESS = 127.0.0.1
+EXTERNAL_ADDRESS = 127.0.0.1
+USE_LOCALADDR = NO
+
+[dns]
+AUTOSTART = NO
+
+[nse]
+AUTOSTART = NO
+
+[mesh]
+AUTOSTART = NO
+
+[datastore]
+AUTOSTART = NO
+
+[fs]
+AUTOSTART = NO
+
+[dv]
+AUTOSTART = NO
+
+[chat]
+AUTOSTART = NO
+
+[vpn]
+AUTOSTART = NO
+
+[gns]
+AUTOSTART = NO
+
+[namestore]
+AUTOSTART = NO \ No newline at end of file