Use proper e-mail address format everywhere.
[doldaconnect.git] / daemon / filenet.c
index 42fb165..f11836f 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *  Dolda Connect - Modular multiuser Direct Connect-style client
- *  Copyright (C) 2004 Fredrik Tolf (fredrik@dolda2000.com)
+ *  Copyright (C) 2004 Fredrik Tolf <fredrik@dolda2000.com>
  *  
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -68,7 +68,10 @@ void killfnetnode(struct fnetnode *fn)
     {
        fn->sk->close = 1;
        if(fn->sk->data == fn)
+       {
+           fn->sk->data = NULL;
            putfnetnode(fn);
+       }
        putsock(fn->sk);
        fn->sk = NULL;
     }
@@ -106,14 +109,20 @@ void putfnetnode(struct fnetnode *fn)
     CBCHAINFREE(fn, fnetpeer_chdi);
     if(fn->fnet->destroy != NULL)
        fn->fnet->destroy(fn);
+    while(fn->args != NULL)
+       freewcspair(fn->args, &fn->args);
     while(fn->peers != NULL)
        fnetdelpeer(fn->peers);
     if(fn->mynick != NULL)
        free(fn->mynick);
+    if(fn->pubid != NULL)
+       free(fn->pubid);
     if(fn->name != NULL)
        free(fn->name);
     if(fn->sk != NULL)
        putsock(fn->sk);
+    if(fn->owner != NULL)
+       free(fn->owner);
     free(fn);
     numfnetnodes--;
 }
@@ -437,10 +446,11 @@ struct fnet *findfnet(wchar_t *name)
     return(fnet);
 }
 
-struct fnetnode *fnetinitconnect(wchar_t *name, char *addr)
+struct fnetnode *fnetinitconnect(wchar_t *name, wchar_t *owner, char *addr, struct wcspair *args)
 {
     struct fnet *fnet;
     struct fnetnode *fn;
+    struct wcspair *arg;
     
     if((fnet = findfnet(name)) == NULL)
     {
@@ -448,6 +458,16 @@ struct fnetnode *fnetinitconnect(wchar_t *name, char *addr)
        return(NULL);
     }
     fn = newfn(fnet);
+    fn->owner = swcsdup(owner);
+    fn->pubid = icmbstowcs(addr, NULL);
+    if(fn->pubid == NULL)
+       fn->pubid = swcsdup(L"");
+    fn->args = args;
+    for(arg = fn->args; arg != NULL; arg = arg->next)
+    {
+       if(!wcscmp(arg->key, L"nick"))
+           fnetsetnick(fn, arg->val);
+    }
     getfnetnode(fn);
     if(netresolve(addr, (void (*)(struct sockaddr *, int, void *))resolvecb, fn) < 0)
        return(NULL);
@@ -482,9 +502,26 @@ void fnethandlechat(struct fnetnode *fn, int public, wchar_t *name, wchar_t *pee
 
 static struct configvar myvars[] =
 {
+    /** The number of seconds to wait between searches. Most hubs
+     * require at least ten seconds, and quite often network lag will
+     * often make searches arrive to the hub more often than sent. It
+     * may be semi-dangerous to specify too low a value, since hubs
+     * will often kick users that search too often (even when the
+     * reason is network lag -- there is no way for the hub to know
+     * this), but it is quite annoying to set too high a value. 15 to
+     * 40 seconds are the recommended range (although the default is
+     * 15 seconds, it is recommended to set to 30 seconds). */
     {CONF_VAR_INT, "srchwait", {.num = 15}},
+    /** The TOS value to use for hub connections (see the TOS VALUES
+     * section). */
     {CONF_VAR_INT, "fntos", {.num = 0}},
+    /** The TOS value to use for peer connections (see the TOS VALUES
+     * section). */
     {CONF_VAR_INT, "fnptos", {.num = 0}},
+    /** Specifies a maximum number of simultaneously connected
+     * hubs. Attempts to connect to new hubs beyond this limit will
+     * return an error. Set to zero to remove the limit. */
+    {CONF_VAR_INT, "maxnodes", {.num = 0}},
     {CONF_VAR_END}
 };