Hmmm. Does this result in "Unaviable" getting written to the config file
at the end of node startup? I suppose not, as we only write it back out
after completing boot up...

On Wed, Feb 22, 2006 at 08:35:19PM +0000, nextgens at freenetproject.org wrote:
> +
> +     static class FCPBindtoCallback implements StringCallback{
> +
> +             final Node node;
> +             
> +             FCPBindtoCallback(Node node) {
> +                     this.node = node;
> +             }
> +             
> +             public String get() {
> +                     // workaround for node startup
> +                     if(node.getFCPServer().bindto == null) return new 
> String("Unaviable");
> +                     return node.getFCPServer().bindto;
> +             }
> +
> +//TODO: Allow it
> +             public void set(String val) throws InvalidConfigValueException {
> +                     if(val.equals(get())) {
> +                             throw new InvalidConfigValueException("Cannot 
> change the ip address the server is binded to on the fly");
> +                     }
> +             }
> +     }
> +
>       
>       public static FCPServer maybeCreate(Node node, Config config) throws 
> IOException {
>               SubConfig fcpConfig = new SubConfig("fcp", config);
> -             // FIXME check enabled etc
> +             fcpConfig.register("enabled", true, 2, true, "Is FCP server 
> enabled ?", "Is FCP server enabled ?", new FCPEnabledCallback(node));
>               fcpConfig.register("port", 9481 /* anagram of 1984, and 1000 up 
> from old number */,
>                               2, true, "FCP port number", "FCP port number", 
> new FCPPortNumberCallback(node));
> -             FCPServer fcp = new FCPServer(fcpConfig.getInt("port"), node);
> -             node.setFCPServer(fcp);
> +             fcpConfig.register("bindto", "127.0.0.1", 2, true, "Ip address 
> to bind to", "Ip address to bind the FCP server to", new 
> FCPBindtoCallback(node));
> +             
> +             FCPServer fcp;
> +             if(fcpConfig.getBoolean("enabled")){
> +                     Logger.normal(node, "Starting FCP server on 
> "+fcpConfig.getString("bindto")+":"+fcpConfig.getInt("port")+".");
> +                     fcp = new FCPServer(fcpConfig.getString("bindto"), 
> fcpConfig.getInt("port"), node);
> +                     node.setFCPServer(fcp); 
> +             }else{
> +                     Logger.normal(node, "Not starting FCP server as it's 
> disabled");
> +                     fcp = null;
> +             }
>               fcpConfig.finishedInitialization();
>               return fcp;
>       }
> 
> _______________________________________________
> cvs mailing list
> cvs at freenetproject.org
> http://emu.freenetproject.org/cgi-bin/mailman/listinfo/cvs

-- 
Matthew J Toseland - toad at amphibian.dyndns.org
Freenet Project Official Codemonkey - http://freenetproject.org/
ICTHUS - Nothing is impossible. Our Boss says so.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: 
<https://emu.freenetproject.org/pipermail/devl/attachments/20060302/ed8c6bc0/attachment.pgp>

Reply via email to