mirror of
https://github.com/osmarks/ngircd.git
synced 2025-01-08 14:50:27 +00:00
Hashed hostnames for CloakHost
Implemented support for hashed hostnames for CloakHost. The admin can use '%x' in both the CloakHost and CloakHostModeX setting. The config option CloakHostModeX was renamed to CloakHostSalt. This salt is used for both cloaking options.
This commit is contained in:
parent
49385a98b2
commit
d0bb185cf5
@ -125,17 +125,17 @@
|
|||||||
;ChrootDir = /var/empty
|
;ChrootDir = /var/empty
|
||||||
|
|
||||||
# Set this hostname for every client instead of the real one.
|
# Set this hostname for every client instead of the real one.
|
||||||
# Please note: don't use the percentage sign ("%"), it is reserved for
|
# Use %x to add the hashed value of the original hostname.
|
||||||
# future extensions!
|
|
||||||
;CloakHost = cloaked.host
|
;CloakHost = cloaked.host
|
||||||
|
|
||||||
# Use this hostname for hostname cloaking on clients that have the
|
# Use this hostname for hostname cloaking on clients that have the
|
||||||
# user mode "+x" set, instead of the name of the server.
|
# user mode "+x" set, instead of the name of the server.
|
||||||
# Use %x to add the hashed value of the original hostname
|
# Use %x to add the hashed value of the original hostname.
|
||||||
;CloakHostModeX = cloaked.user
|
;CloakHostModeX = cloaked.user
|
||||||
|
|
||||||
# The Salt for cloaked hostname hashing
|
# The Salt for cloaked hostname hashing. When undefined a random
|
||||||
;CloakHostModeXSalt = abcdefghijklmnopqrstuvwxyz
|
# hash is generated after each server start.
|
||||||
|
;CloakHostSalt = abcdefghijklmnopqrstuvwxyz
|
||||||
|
|
||||||
# Set every clients' user name to their nick name
|
# Set every clients' user name to their nick name
|
||||||
;CloakUserToNick = yes
|
;CloakUserToNick = yes
|
||||||
|
@ -212,21 +212,16 @@ For this to work the server must have been started with root privileges!
|
|||||||
.TP
|
.TP
|
||||||
\fBCloakHost\fR (string)
|
\fBCloakHost\fR (string)
|
||||||
Set this hostname for every client instead of the real one. Default: empty,
|
Set this hostname for every client instead of the real one. Default: empty,
|
||||||
don't change.
|
don't change. Use %x to add the hashed value of the original hostname.
|
||||||
.PP
|
|
||||||
.RS
|
|
||||||
.B Please note:
|
|
||||||
.br
|
|
||||||
Don't use the percentage sign ("%"), it is reserved for future extensions!
|
|
||||||
.RE
|
|
||||||
.TP
|
.TP
|
||||||
\fBCloakHostModeX\fR (string)
|
\fBCloakHostModeX\fR (string)
|
||||||
Use this hostname for hostname cloaking on clients that have the user mode
|
Use this hostname for hostname cloaking on clients that have the user mode
|
||||||
"+x" set, instead of the name of the server. Default: empty, use the name
|
"+x" set, instead of the name of the server. Default: empty, use the name
|
||||||
of the server. Use %x to add the hashed value of the original hostname
|
of the server. Use %x to add the hashed value of the original hostname
|
||||||
.TP
|
.TP
|
||||||
\fBCloakHostModeXSalt\fR (string)
|
\fBCloakHostSalt\fR (string)
|
||||||
The Salt for cloaked hostname hashing
|
The Salt for cloaked hostname hashing. When undefined a random hash is
|
||||||
|
generated after each server start.
|
||||||
.TP
|
.TP
|
||||||
\fBCloakUserToNick\fR (boolean)
|
\fBCloakUserToNick\fR (boolean)
|
||||||
Set every clients' user name to their nick name and hide the one supplied
|
Set every clients' user name to their nick name and hide the one supplied
|
||||||
|
@ -331,9 +331,15 @@ Client_SetHostname( CLIENT *Client, const char *Hostname )
|
|||||||
assert(Hostname != NULL);
|
assert(Hostname != NULL);
|
||||||
|
|
||||||
if (strlen(Conf_CloakHost)) {
|
if (strlen(Conf_CloakHost)) {
|
||||||
|
char cloak[GETID_LEN];
|
||||||
|
|
||||||
|
strlcpy(cloak, Hostname, GETID_LEN);
|
||||||
|
strlcat(cloak, Conf_CloakHostSalt, GETID_LEN);
|
||||||
|
snprintf(cloak, GETID_LEN, Conf_CloakHost, Hash(cloak));
|
||||||
|
|
||||||
LogDebug("Updating hostname of \"%s\": \"%s\" -> \"%s\"",
|
LogDebug("Updating hostname of \"%s\": \"%s\" -> \"%s\"",
|
||||||
Client_ID(Client), Client->host, Conf_CloakHost);
|
Client_ID(Client), Client->host, cloak);
|
||||||
strlcpy(Client->host, Conf_CloakHost, sizeof(Client->host));
|
strlcpy(Client->host, cloak, sizeof(Client->host));
|
||||||
} else {
|
} else {
|
||||||
LogDebug("Updating hostname of \"%s\": \"%s\" -> \"%s\"",
|
LogDebug("Updating hostname of \"%s\": \"%s\" -> \"%s\"",
|
||||||
Client_ID(Client), Client->host, Hostname);
|
Client_ID(Client), Client->host, Hostname);
|
||||||
@ -826,8 +832,9 @@ Client_MaskCloaked(CLIENT *Client)
|
|||||||
return Client_Mask(Client);
|
return Client_Mask(Client);
|
||||||
|
|
||||||
if(*Conf_CloakHostModeX) {
|
if(*Conf_CloakHostModeX) {
|
||||||
snprintf(Mask_Buffer, GETID_LEN, "%s%s", Client->host, Conf_CloakHostModeXSalt);
|
strlcpy(Cloak_Buffer, Client->host, GETID_LEN);
|
||||||
snprintf(Cloak_Buffer, GETID_LEN, Conf_CloakHostModeX, Hash(Mask_Buffer));
|
strlcat(Cloak_Buffer, Conf_CloakHostSalt, GETID_LEN);
|
||||||
|
snprintf(Cloak_Buffer, GETID_LEN, Conf_CloakHostModeX, Hash(Cloak_Buffer));
|
||||||
} else {
|
} else {
|
||||||
strncpy(Cloak_Buffer, Client_ID(Client->introducer), GETID_LEN);
|
strncpy(Cloak_Buffer, Client_ID(Client->introducer), GETID_LEN);
|
||||||
}
|
}
|
||||||
|
@ -359,7 +359,7 @@ Conf_Test( void )
|
|||||||
printf(" ChrootDir = %s\n", Conf_Chroot);
|
printf(" ChrootDir = %s\n", Conf_Chroot);
|
||||||
printf(" CloakHost = %s\n", Conf_CloakHost);
|
printf(" CloakHost = %s\n", Conf_CloakHost);
|
||||||
printf(" CloakHostModeX = %s\n", Conf_CloakHostModeX);
|
printf(" CloakHostModeX = %s\n", Conf_CloakHostModeX);
|
||||||
printf(" CloakHostModeXSalt = %s\n", Conf_CloakHostModeXSalt);
|
printf(" CloakHostSalt = %s\n", Conf_CloakHostSalt);
|
||||||
printf(" CloakUserToNick = %s\n", yesno_to_str(Conf_CloakUserToNick));
|
printf(" CloakUserToNick = %s\n", yesno_to_str(Conf_CloakUserToNick));
|
||||||
#ifdef WANT_IPV6
|
#ifdef WANT_IPV6
|
||||||
printf(" ConnectIPv4 = %s\n", yesno_to_str(Conf_ConnectIPv6));
|
printf(" ConnectIPv4 = %s\n", yesno_to_str(Conf_ConnectIPv6));
|
||||||
@ -688,7 +688,7 @@ Set_Defaults(bool InitServers)
|
|||||||
strlcpy(Conf_Chroot, CHROOT_DIR, sizeof(Conf_Chroot));
|
strlcpy(Conf_Chroot, CHROOT_DIR, sizeof(Conf_Chroot));
|
||||||
strcpy(Conf_CloakHost, "");
|
strcpy(Conf_CloakHost, "");
|
||||||
strcpy(Conf_CloakHostModeX, "");
|
strcpy(Conf_CloakHostModeX, "");
|
||||||
strcpy(Conf_CloakHostModeXSalt,ngt_RandomStr(random,RANDOM_SALT_LEN));
|
strcpy(Conf_CloakHostSalt, ngt_RandomStr(random, RANDOM_SALT_LEN));
|
||||||
Conf_CloakUserToNick = false;
|
Conf_CloakUserToNick = false;
|
||||||
Conf_ConnectIPv4 = true;
|
Conf_ConnectIPv4 = true;
|
||||||
#ifdef WANT_IPV6
|
#ifdef WANT_IPV6
|
||||||
@ -1488,9 +1488,9 @@ Handle_OPTIONS(int Line, char *Var, char *Arg)
|
|||||||
Config_Error_TooLong(Line, Var);
|
Config_Error_TooLong(Line, Var);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (strcasecmp(Var, "CloakHostModeXSalt") == 0) {
|
if (strcasecmp(Var, "CloakHostSalt") == 0) {
|
||||||
len = strlcpy(Conf_CloakHostModeXSalt, Arg, sizeof(Conf_CloakHostModeXSalt));
|
len = strlcpy(Conf_CloakHostSalt, Arg, sizeof(Conf_CloakHostSalt));
|
||||||
if (len >= sizeof(Conf_CloakHostModeX))
|
if (len >= sizeof(Conf_CloakHostSalt))
|
||||||
Config_Error_TooLong(Line, Var);
|
Config_Error_TooLong(Line, Var);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -169,8 +169,8 @@ GLOBAL char Conf_CloakHost[CLIENT_ID_LEN];
|
|||||||
/** Cloaked hostname for clients that did +x */
|
/** Cloaked hostname for clients that did +x */
|
||||||
GLOBAL char Conf_CloakHostModeX[CLIENT_ID_LEN];
|
GLOBAL char Conf_CloakHostModeX[CLIENT_ID_LEN];
|
||||||
|
|
||||||
/** Salt for hostname hash for clients that did +x */
|
/** Salt for hostname hash for cloaked hostnames */
|
||||||
GLOBAL char Conf_CloakHostModeXSalt[CLIENT_ID_LEN];
|
GLOBAL char Conf_CloakHostSalt[CLIENT_ID_LEN];
|
||||||
|
|
||||||
/** Use nick name as user name? */
|
/** Use nick name as user name? */
|
||||||
GLOBAL bool Conf_CloakUserToNick;
|
GLOBAL bool Conf_CloakUserToNick;
|
||||||
|
Loading…
Reference in New Issue
Block a user