Author: dbkr
Date: 2006-02-23 01:08:09 +0000 (Thu, 23 Feb 2006)
New Revision: 8126

Modified:
   trunk/freenet/src/freenet/clients/http/FproxyToadlet.java
   trunk/freenet/src/freenet/clients/http/SimpleToadletServer.java
Log:
Support for configuring which IP address fproxy should bind to, as in the FCP 
server.


Modified: trunk/freenet/src/freenet/clients/http/FproxyToadlet.java
===================================================================
--- trunk/freenet/src/freenet/clients/http/FproxyToadlet.java   2006-02-23 
00:45:54 UTC (rev 8125)
+++ trunk/freenet/src/freenet/clients/http/FproxyToadlet.java   2006-02-23 
01:08:09 UTC (rev 8126)
@@ -12,6 +12,7 @@
 import freenet.config.BooleanCallback;
 import freenet.config.Config;
 import freenet.config.IntCallback;
+import freenet.config.StringCallback;
 import freenet.config.InvalidConfigValueException;
 import freenet.config.SubConfig;
 import freenet.keys.FreenetURI;
@@ -111,6 +112,26 @@
                }
        }

+       static class FproxyBindtoCallback implements StringCallback {
+               
+               final Node node;
+               
+               FproxyBindtoCallback(Node n) {
+                       this.node = n;
+               }
+               
+               public String get() {
+                       SimpleToadletServer f = node.getToadletContainer();
+                       if(f == null) return "127.0.0.1";
+                       return f.bindto;
+               }
+               
+               public void set(String bindto) throws 
InvalidConfigValueException {
+                       if(bindto != get())
+                               throw new InvalidConfigValueException("Cannot 
change fproxy bind address on the fly");
+               }
+       }
+       
        public static void maybeCreateFproxyEtc(Node node, Config config) 
throws IOException {

                SubConfig fproxyConfig = new SubConfig("fproxy", config);
@@ -127,10 +148,13 @@

                fproxyConfig.register("port", DEFAULT_FPROXY_PORT, 2, true, 
"Fproxy port number", "Fproxy port number",
                                new FproxyPortCallback(node));
+               fproxyConfig.register("bindto", "127.0.0.1", 2, true, "IP 
address to bind to", "IP address to bind to",
+                                     new FproxyBindtoCallback(node));

                int port = fproxyConfig.getInt("port");
+               String bind_ip = fproxyConfig.getString("bindto");

-        SimpleToadletServer server = new SimpleToadletServer(port);
+        SimpleToadletServer server = new SimpleToadletServer(port, bind_ip);
         node.setToadletContainer(server);
         FproxyToadlet fproxy = new 
FproxyToadlet(node.makeClient(RequestStarter.INTERACTIVE_PRIORITY_CLASS));
         node.setFproxy(fproxy);

Modified: trunk/freenet/src/freenet/clients/http/SimpleToadletServer.java
===================================================================
--- trunk/freenet/src/freenet/clients/http/SimpleToadletServer.java     
2006-02-23 00:45:54 UTC (rev 8125)
+++ trunk/freenet/src/freenet/clients/http/SimpleToadletServer.java     
2006-02-23 01:08:09 UTC (rev 8126)
@@ -31,12 +31,18 @@
        }

        final int port;
+       final String bindto;
        private final ServerSocket sock;
        private final LinkedList toadlets;

        public SimpleToadletServer(int i) throws IOException {
+               this(i, "127.0.0.1");
+       }
+       
+       public SimpleToadletServer(int i, String newbindto) throws IOException {
                this.port = i;
-               this.sock = new ServerSocket(port, 0, 
InetAddress.getByName("127.0.0.1"));
+               this.bindto = newbindto;
+               this.sock = new ServerSocket(port, 0, 
InetAddress.getByName(this.bindto));
                toadlets = new LinkedList();
                Thread t = new Thread(this, "SimpleToadletServer");
                t.setDaemon(true);


Reply via email to