-fix
authorMartin Schanzenbach <mschanzenbach@posteo.de>
Tue, 3 Apr 2012 13:08:07 +0000 (13:08 +0000)
committerMartin Schanzenbach <mschanzenbach@posteo.de>
Tue, 3 Apr 2012 13:08:07 +0000 (13:08 +0000)
src/gns/proxy/gnunet-gns-proxy.py
src/gns/test_gns_defaults.conf [new file with mode: 0644]

index 094f5412ca649d92e0bb6038534695170298c836..f13a0adadcce0e9c8744cb5728720422137c9126 100644 (file)
@@ -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 (file)
index 0000000..762c964
--- /dev/null
@@ -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