]> arthur.barton.de Git - ngircd-alex.git/blobdiff - src/ngircd/client.c
Save client IP address text for "WebIRC" users
[ngircd-alex.git] / src / ngircd / client.c
index 32690288529499097c0b6d88c1127774202f51bd..26d4929d732b04ecaaef3c24527465fafbe94160 100644 (file)
@@ -126,6 +126,10 @@ Client_Exit( void )
                next = (CLIENT *)c->next;
                if (c->account_name)
                        free(c->account_name);
+               if (c->cloaked)
+                       free(c->cloaked);
+               if (c->ipa_text)
+                       free(c->ipa_text);
                free( c );
                c = next;
        }
@@ -324,6 +328,8 @@ Client_Destroy( CLIENT *Client, const char *LogMsg, const char *FwdMsg, bool Sen
                                free(c->account_name);
                        if (c->cloaked)
                                free(c->cloaked);
+                       if (c->ipa_text)
+                               free(c->ipa_text);
                        free( c );
                        break;
                }
@@ -366,6 +372,27 @@ Client_SetHostname( CLIENT *Client, const char *Hostname )
 } /* Client_SetHostname */
 
 
+/**
+ * Set IP address to display for a client.
+ *
+ * @param Client The client.
+ * @param IPAText Textual representation of the IP address or NULL to unset.
+ */
+GLOBAL void
+Client_SetIPAText(CLIENT *Client, const char *IPAText)
+{
+       assert(Client != NULL);
+
+       if (Client->ipa_text)
+               free(Client->ipa_text);
+
+       if (*IPAText)
+               Client->ipa_text = strndup(IPAText, CLIENT_HOST_LEN - 1);
+       else
+               Client->ipa_text = NULL;
+}
+
+
 GLOBAL void
 Client_SetID( CLIENT *Client, const char *ID )
 {
@@ -467,7 +494,8 @@ Client_SetAccountName(CLIENT *Client, const char *AccountName)
                free(Client->account_name);
 
        if (*AccountName)
-               Client->account_name = strdup(AccountName);
+               Client->account_name = strndup(AccountName,
+                                              CLIENT_NICK_LEN - 1);
        else
                Client->account_name = NULL;
 }
@@ -786,6 +814,21 @@ Client_HostnameDisplayed(CLIENT *Client)
        return Client->cloaked;
 }
 
+GLOBAL const char *
+Client_IPAText(CLIENT *Client)
+{
+       assert(Client != NULL);
+
+       /* Not a local client? */
+       if (Client_Conn(Client) <= NONE)
+               return "0.0.0.0";
+
+       if (!Client->ipa_text)
+               return Conn_GetIPAInfo(Client_Conn(Client));
+       else
+               return Client->ipa_text;
+}
+
 /**
  * Update (and generate, if necessary) the cloaked hostname of a client.
  *