mirror of
				https://github.com/osmarks/ngircd.git
				synced 2025-10-31 05:52:59 +00:00 
			
		
		
		
	Implemented hashed cloaked hostnames for +x
CloakHostModeX can now contain '%x'. It will be replace by the hash of the original client hostname. The new config option CloakHostModeXSalt defines the salt for the hash function. When CloakHostModeXSalt is not set a random salt will be generated after each server restart. Spelling fix in defines.h
This commit is contained in:
		| @@ -20,7 +20,9 @@ | ||||
| #include <assert.h> | ||||
| #include <ctype.h> | ||||
| #include <stdio.h> | ||||
| #include <stdlib.h> | ||||
| #include <string.h> | ||||
| #include <sys/time.h> | ||||
|  | ||||
| #include <netinet/in.h> | ||||
|  | ||||
| @@ -129,6 +131,34 @@ ngt_TrimLastChr( char *String, const char Chr) | ||||
| } /* ngt_TrimLastChr */ | ||||
|  | ||||
|  | ||||
| /** | ||||
|  * Fill a String with random chars | ||||
|  */ | ||||
| GLOBAL char * | ||||
| ngt_RandomStr( char *String, const size_t len) | ||||
| { | ||||
| 	assert(String != NULL); | ||||
|  | ||||
| 	static const char chars[] =  | ||||
| 		"0123456789ABCDEFGHIJKLMNO" | ||||
| 		"PQRSTUVWXYZabcdefghijklmn" | ||||
| 		"opqrstuvwxyz!\"#$&'()*+,-" | ||||
| 		"./:;<=>?@[\\]^_`"; | ||||
|  | ||||
| 	struct timeval t; | ||||
| 	gettimeofday(&t, NULL); | ||||
| 	srand(t.tv_usec * t.tv_sec); | ||||
|  | ||||
| 	for (size_t i = 0; i < len; ++i) { | ||||
| 		String[i] = chars[rand() % (sizeof(chars) - 1)]; | ||||
| 	} | ||||
|  | ||||
| 	String[len] = '\0'; | ||||
|  | ||||
| 	return String; | ||||
| } /* ngt_RandomStr */ | ||||
|  | ||||
|  | ||||
| #ifdef SYSLOG | ||||
|  | ||||
|  | ||||
|   | ||||
| @@ -32,6 +32,8 @@ GLOBAL void ngt_TrimStr PARAMS((char *String )); | ||||
| GLOBAL char *ngt_UpperStr PARAMS((char *String )); | ||||
| GLOBAL char *ngt_LowerStr PARAMS((char *String )); | ||||
|  | ||||
| GLOBAL char *ngt_RandomStr PARAMS((char *String, const size_t len)); | ||||
|  | ||||
| #ifdef SYSLOG | ||||
| GLOBAL const char *ngt_SyslogFacilityName PARAMS((int Facility)); | ||||
| GLOBAL int ngt_SyslogFacilityID PARAMS((char *Name, int DefaultFacility)); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Sebastian Köhler
					Sebastian Köhler