mirror of
https://github.com/osmarks/ngircd.git
synced 2025-05-20 16:14:09 +00:00
Always cloak client hostname, if needed
Not only cloak the hostname in Client_MaskCloaked(), but also in Client_HostnameCloaked() -- so move the actual cloaking to this function and call it in Client_MaskCloaked() to get the (cloaked) hostname. This fixes USERHOST not displaying the correctly cloaked hostname, for example.
This commit is contained in:
parent
864015fa3f
commit
33fae67579
@ -687,18 +687,35 @@ Client_Hostname(CLIENT *Client)
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get potentially cloaked hostname of a client.
|
* Get potentially cloaked hostname of a client.
|
||||||
|
*
|
||||||
* If the client has not enabled cloaking, the real hostname is used.
|
* If the client has not enabled cloaking, the real hostname is used.
|
||||||
|
* Please note that this function uses a global static buffer, so you can't
|
||||||
|
* nest invocations without overwriting earlier results!
|
||||||
|
*
|
||||||
* @param Client Pointer to client structure
|
* @param Client Pointer to client structure
|
||||||
* @return Pointer to client hostname
|
* @return Pointer to client hostname
|
||||||
*/
|
*/
|
||||||
GLOBAL char *
|
GLOBAL char *
|
||||||
Client_HostnameCloaked(CLIENT *Client)
|
Client_HostnameCloaked(CLIENT *Client)
|
||||||
{
|
{
|
||||||
|
static char Cloak_Buffer[CLIENT_HOST_LEN];
|
||||||
|
|
||||||
assert(Client != NULL);
|
assert(Client != NULL);
|
||||||
if (Client_HasMode(Client, 'x'))
|
|
||||||
return Client_ID(Client->introducer);
|
if (!Client_HasMode(Client, 'x'))
|
||||||
else
|
|
||||||
return Client_Hostname(Client);
|
return Client_Hostname(Client);
|
||||||
|
|
||||||
|
/* Do simple mapping to the server ID? */
|
||||||
|
if (!*Conf_CloakHostModeX)
|
||||||
|
return Client_ID(Client->introducer);
|
||||||
|
|
||||||
|
strlcpy(Cloak_Buffer, Client->host, CLIENT_HOST_LEN);
|
||||||
|
strlcat(Cloak_Buffer, Conf_CloakHostSalt, CLIENT_HOST_LEN);
|
||||||
|
|
||||||
|
snprintf(Cloak_Buffer, CLIENT_HOST_LEN, Conf_CloakHostModeX,
|
||||||
|
Hash(Cloak_Buffer));
|
||||||
|
|
||||||
|
return Cloak_Buffer;
|
||||||
} /* Client_HostnameCloaked */
|
} /* Client_HostnameCloaked */
|
||||||
|
|
||||||
|
|
||||||
@ -792,10 +809,12 @@ Client_Mask( CLIENT *Client )
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Return ID of a client with cloaked hostname: "client!user@server-name"
|
* Return ID of a client with cloaked hostname: "client!user@server-name"
|
||||||
|
*
|
||||||
* This client ID is used for IRC prefixes, for example.
|
* This client ID is used for IRC prefixes, for example.
|
||||||
* Please note that this function uses a global static buffer, so you can't
|
* Please note that this function uses a global static buffer, so you can't
|
||||||
* nest invocations without overwriting earlier results!
|
* nest invocations without overwriting earlier results!
|
||||||
* If the client has not enabled cloaking, the real hostname is used.
|
* If the client has not enabled cloaking, the real hostname is used.
|
||||||
|
*
|
||||||
* @param Client Pointer to client structure
|
* @param Client Pointer to client structure
|
||||||
* @return Pointer to global buffer containing the client ID
|
* @return Pointer to global buffer containing the client ID
|
||||||
*/
|
*/
|
||||||
@ -803,7 +822,6 @@ GLOBAL char *
|
|||||||
Client_MaskCloaked(CLIENT *Client)
|
Client_MaskCloaked(CLIENT *Client)
|
||||||
{
|
{
|
||||||
static char Mask_Buffer[GETID_LEN];
|
static char Mask_Buffer[GETID_LEN];
|
||||||
char Cloak_Buffer[GETID_LEN];
|
|
||||||
|
|
||||||
assert (Client != NULL);
|
assert (Client != NULL);
|
||||||
|
|
||||||
@ -811,16 +829,8 @@ Client_MaskCloaked(CLIENT *Client)
|
|||||||
if (!Client_HasMode(Client, 'x'))
|
if (!Client_HasMode(Client, 'x'))
|
||||||
return Client_Mask(Client);
|
return Client_Mask(Client);
|
||||||
|
|
||||||
if(*Conf_CloakHostModeX) {
|
snprintf(Mask_Buffer, GETID_LEN, "%s!%s@%s", Client->id, Client->user,
|
||||||
strlcpy(Cloak_Buffer, Client->host, GETID_LEN);
|
Client_HostnameCloaked(Client));
|
||||||
strlcat(Cloak_Buffer, Conf_CloakHostSalt, GETID_LEN);
|
|
||||||
snprintf(Cloak_Buffer, GETID_LEN, Conf_CloakHostModeX, Hash(Cloak_Buffer));
|
|
||||||
} else {
|
|
||||||
strncpy(Cloak_Buffer, Client_ID(Client->introducer), GETID_LEN);
|
|
||||||
}
|
|
||||||
|
|
||||||
snprintf(Mask_Buffer, GETID_LEN, "%s!%s@%s",
|
|
||||||
Client->id, Client->user, Cloak_Buffer);
|
|
||||||
|
|
||||||
return Mask_Buffer;
|
return Mask_Buffer;
|
||||||
} /* Client_MaskCloaked */
|
} /* Client_MaskCloaked */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user