Skip to content

Commit

Permalink
Add set { cloak-method ip; }; which will make cloaking only be done
Browse files Browse the repository at this point in the history
on the IP and thus result in an XX.YY.ZZ.IP cloaked host.
This so you can have "IP cloaking" without disabling DNS lookups.
GLINES on hosts still work and IRCOps (and yourself) can still see
the host in /WHOIS.
Requested in 4957 by Gottem and The_Myth.
  • Loading branch information
syzop committed Oct 8, 2017
1 parent 6614392 commit 1b6d49a
Showing 1 changed file with 47 additions and 7 deletions.
54 changes: 47 additions & 7 deletions src/modules/cloak.c
Expand Up @@ -26,14 +26,16 @@ static char *cloak_key1 = NULL, *cloak_key2 = NULL, *cloak_key3 = NULL;
static char cloak_checksum[64];
static int nokeys = 1;

int CLOAK_IP_ONLY = 0;

#undef KEY1
#undef KEY2
#undef KEY3
#define KEY1 cloak_key1
#define KEY2 cloak_key2
#define KEY3 cloak_key3

DLLFUNC char *hidehost(char *host);
DLLFUNC char *hidehost(aClient *acptr, char *host);
DLLFUNC char *cloakcsum();
DLLFUNC int cloak_config_test(ConfigFile *, ConfigEntry *, int, int *);
DLLFUNC int cloak_config_run(ConfigFile *, ConfigEntry *, int);
Expand All @@ -57,7 +59,7 @@ ModuleHeader MOD_HEADER(cloak)

MOD_TEST(cloak)
{
cloak = CallbackAddPCharEx(modinfo->handle, CALLBACKTYPE_CLOAK, hidehost);
cloak = CallbackAddPCharEx(modinfo->handle, CALLBACKTYPE_CLOAK_EX, hidehost);
if (!cloak)
{
config_error("cloak: Error while trying to install cloaking callback!");
Expand Down Expand Up @@ -117,9 +119,32 @@ char *p;

DLLFUNC int cloak_config_test(ConfigFile *cf, ConfigEntry *ce, int type, int *errs)
{
ConfigEntry *cep;
int keycnt = 0, errors = 0;
char *keys[3];
ConfigEntry *cep;
int keycnt = 0, errors = 0;
char *keys[3];

if (type == CONFIG_SET)
{
/* set::cloak-method */
if (!ce || !ce->ce_varname || strcmp(ce->ce_varname, "cloak-method"))
return 0;

if (!ce->ce_varname)
{
config_error("%s:%i: blank set::cloak-method item",
ce->ce_fileptr->cf_filename, ce->ce_varlinenum);
errors++;
} else
if (strcmp(ce->ce_vardata, "ip") && strcmp(ce->ce_vardata, "host"))
{
config_error("%s:%i: set::cloak-method: unknown method '%s'. The only supported methods are: 'ip' and 'host'",
ce->ce_fileptr->cf_filename, ce->ce_varlinenum, ce->ce_vardata);
errors++;
}

*errs = errors;
return errors ? -1 : 1;
}

if (type != CONFIG_CLOAKKEYS)
return 0;
Expand Down Expand Up @@ -185,6 +210,18 @@ DLLFUNC int cloak_config_run(ConfigFile *cf, ConfigEntry *ce, int type)
ConfigEntry *cep;
char buf[512], result[16];

if (type == CONFIG_SET)
{
/* set::cloak-method */
if (!ce || !ce->ce_varname || strcmp(ce->ce_varname, "cloak-method"))
return 0;

if (!strcmp(ce->ce_vardata, "ip"))
CLOAK_IP_ONLY = 1;

return 0;
}

if (type != CONFIG_CLOAKKEYS)
return 0;

Expand Down Expand Up @@ -220,9 +257,12 @@ char buf[512], result[16];
return 1;
}

DLLFUNC char *hidehost(char *host)
DLLFUNC char *hidehost(aClient *acptr, char *host)
{
char *p;
char *p;

if (CLOAK_IP_ONLY)
host = GetIP(acptr);

/* IPv6 ? */
if (strchr(host, ':'))
Expand Down

0 comments on commit 1b6d49a

Please sign in to comment.