]> arthur.barton.de Git - ngircd-alex.git/blobdiff - src/ngircd/client.c
New RPL_WHOISHOST_MSG(378): show hostname and IP address
[ngircd-alex.git] / src / ngircd / client.c
index 16c551f97a89b422bf356465f45b0cc85a522e11..1aaf687ce6995e8f958daf7d4b98860084234d9a 100644 (file)
@@ -768,7 +768,7 @@ Client_NextHop( CLIENT *Client )
  * Return ID of a client: "client!user@host"
  * This client ID is used for IRC prefixes, for example.
  * Please note that this function uses a global static buffer, so you can't
- * nest invocations without overwriting erlier results!
+ * nest invocations without overwriting earlier results!
  * @param Client Pointer to client structure
  * @return Pointer to global buffer containing the client ID
  */
@@ -793,7 +793,7 @@ Client_Mask( CLIENT *Client )
  * Return ID of a client with cloaked hostname: "client!user@server-name"
  * This client ID is used for IRC prefixes, for example.
  * Please note that this function uses a global static buffer, so you can't
- * nest invocations without overwriting erlier results!
+ * nest invocations without overwriting earlier results!
  * If the client has not enabled cloaking, the real hostname is used.
  * @param Client Pointer to client structure
  * @return Pointer to global buffer containing the client ID
@@ -1097,6 +1097,39 @@ Client_StartTime(CLIENT *Client)
 } /* Client_Uptime */
 
 
+/**
+ * Reject a client when logging in.
+ *
+ * This function is called when a client isn't allowed to connect to this
+ * server. Possible reasons are bad server password, bad PAM password,
+ * or that the client is G/K-Line'd.
+ *
+ * After calling this function, the client isn't connected any more.
+ *
+ * @param Client The client to reject.
+ * @param Reason The reason why the client has been rejected.
+ * @param InformClient If true, send the exact reason to the client.
+ */
+GLOBAL void
+Client_Reject(CLIENT *Client, const char *Reason, bool InformClient)
+{
+       char info[COMMAND_LEN];
+
+       assert(Client != NULL);
+       assert(Reason != NULL);
+
+       if (InformClient)
+               snprintf(info, sizeof(info), "Access denied: %s", Reason);
+       else
+               strcpy(info, "Access denied: Bad password?");
+
+       Log(LOG_ERR,
+           "User \"%s\" rejected (connection %d): %s!",
+           Client_Mask(Client), Client_Conn(Client), Reason);
+       Conn_Close(Client_Conn(Client), Reason, info, true);
+}
+
+
 static unsigned long
 Count( CLIENT_TYPE Type )
 {