mirror of
https://github.com/unrealircd/unrealircd.git
synced 2026-06-12 19:14:46 +02:00
Scanner config changes
This commit is contained in:
@@ -1153,4 +1153,6 @@ v- Fixed some bugreport stuff
|
||||
- -Wall cleanup cleanup with SSL AUTH problem
|
||||
- Fix for /version crash, reported by RaYmAn
|
||||
- Made all functions use new-style parameter lists
|
||||
|
||||
- Moved set::socks::ban-time to set::scan::bantime, and remove the other set::socks::* (not used)
|
||||
also added set::scan::timeout to specify how long the scanner should wait for a response before giving up
|
||||
- Added HOOKTYPE_STATS - allows modules to respond to certain /stats (so far only S is supported)
|
||||
|
||||
@@ -15,10 +15,6 @@ set {
|
||||
auto-join "0";
|
||||
/* What channels opers will autojoin on connect*/
|
||||
oper-auto-join "0";
|
||||
/* This needs to be an unused port, that the IRCd will bind
|
||||
* to, and make insecure proxies connect to.
|
||||
*/
|
||||
blackhole [ip]:port;
|
||||
dns {
|
||||
/* What IP has our DNS server got? */
|
||||
nameserver 127.0.0.1;
|
||||
@@ -35,11 +31,6 @@ set {
|
||||
identd-check;
|
||||
};
|
||||
|
||||
socks {
|
||||
ban-message "Insecure SOCKS server";
|
||||
quit-message "Insecure SOCKS server";
|
||||
ban-time "1d";
|
||||
};
|
||||
/*
|
||||
* How many channels each user can join
|
||||
*/
|
||||
|
||||
@@ -68,11 +68,8 @@ struct zConfiguration {
|
||||
char *auto_join_chans;
|
||||
char *oper_auto_join_chans;
|
||||
char *oper_only_stats;
|
||||
int socksbantime;
|
||||
int maxchannelsperuser;
|
||||
int anti_spam_quit_message_time;
|
||||
char *socksbanmessage;
|
||||
char *socksquitmessage;
|
||||
aNetwork network;
|
||||
};
|
||||
|
||||
@@ -93,9 +90,6 @@ extern aConfiguration iConf;
|
||||
#define OPER_AUTO_JOIN_CHANS iConf.oper_auto_join_chans
|
||||
#define HOST_TIMEOUT iConf.host_timeout
|
||||
#define HOST_RETRIES iConf.host_retries
|
||||
#define SOCKSBANMSG iConf.socksbanmessage
|
||||
#define SOCKSQUITMSG iConf.socksquitmessage
|
||||
#define SOCKSBANTIME iConf.socksbantime
|
||||
#define NAME_SERVER iConf.name_server
|
||||
#define IDENT_CHECK iConf.ident_check
|
||||
#define FAILOPER_WARN iConf.fail_oper_warn
|
||||
|
||||
+1
-1
@@ -218,7 +218,7 @@ Hook *HookDel(Hook *hook);
|
||||
#define HOOKTYPE_GUEST 10
|
||||
#define HOOKTYPE_SERVER_CONNECT 11
|
||||
#define HOOKTYPE_SERVER_QUIT 12
|
||||
|
||||
#define HOOKTYPE_STATS 13
|
||||
/* Module flags */
|
||||
#define MODFLAG_NONE 0x0000
|
||||
#define MODFLAG_LOADED 0x0001 /* (mod_load has been called and suceeded) */
|
||||
|
||||
+37
-3
@@ -59,12 +59,13 @@ Module *Mod_Handle = NULL;
|
||||
#define Mod_Handle NULL
|
||||
#endif
|
||||
struct SOCKADDR_IN Scan_endpoint;
|
||||
|
||||
int Scan_BanTime = 0, Scan_TimeOut = 0;
|
||||
static Scan_AddrStruct *Scannings = NULL;
|
||||
MUTEX Scannings_lock;
|
||||
|
||||
DLLFUNC int h_scan_connect(aClient *sptr);
|
||||
DLLFUNC int h_config_set_scan(void);
|
||||
DLLFUNC int h_stats_scan(aClient *sptr, char *stats);
|
||||
|
||||
#ifndef DYNAMIC_LINKING
|
||||
ModuleHeader m_scan_Header
|
||||
@@ -83,7 +84,7 @@ ModuleHeader Mod_Header
|
||||
EVENT(e_scannings_clean);
|
||||
|
||||
static Event *Scannings_clean = NULL;
|
||||
static Hook *LocConnect = NULL, *ConfUnknown = NULL;
|
||||
static Hook *LocConnect = NULL, *ConfUnknown = NULL, *ServerStats = NULL;
|
||||
|
||||
/* This is called on module init, before Server Ready */
|
||||
#ifdef DYNAMIC_LINKING
|
||||
@@ -94,6 +95,7 @@ int m_scan_Init(int module_load)
|
||||
{
|
||||
LocConnect = HookAddEx(Mod_Handle, HOOKTYPE_LOCAL_CONNECT, h_scan_connect);
|
||||
ConfUnknown = HookAddEx(Mod_Handle, HOOKTYPE_CONFIG_UNKNOWN, h_config_set_scan);
|
||||
ServerStats = HookAddEx(Mod_Handle, HOOKTYPE_STATS, h_stats_scan);
|
||||
IRCCreateMutex(Scannings_lock);
|
||||
return MOD_SUCCESS;
|
||||
}
|
||||
@@ -116,6 +118,11 @@ int m_scan_Load(int module_load)
|
||||
Scan_endpoint.SIN_PORT = htons(2121);
|
||||
Scan_endpoint.SIN_FAMILY = AFINET;
|
||||
}
|
||||
if (Scan_BanTime == 0)
|
||||
Scan_BanTime = 86400;
|
||||
|
||||
if (Scan_TimeOut == 0)
|
||||
Scan_TimeOut = 20;
|
||||
|
||||
Scannings_clean = EventAddEx(Mod_Handle, "e_scannings_clean", 0, 0, e_scannings_clean, NULL);
|
||||
return MOD_SUCCESS;
|
||||
@@ -237,7 +244,7 @@ EVENT(e_scan_ban)
|
||||
strcpy(hostip, Inet_ia2p(&sr->in));
|
||||
tkllayer[4] = hostip;
|
||||
tkllayer[5] = me.name;
|
||||
ircsprintf(mo, "%li", SOCKSBANTIME + TStime());
|
||||
ircsprintf(mo, "%li", Scan_BanTime + TStime());
|
||||
ircsprintf(mo2, "%li", TStime());
|
||||
tkllayer[6] = mo;
|
||||
tkllayer[7] = mo2;
|
||||
@@ -324,6 +331,23 @@ DLLFUNC int h_config_set_scan(void)
|
||||
{
|
||||
for (ce = sets->ce_entries; ce; ce = (ConfigEntry *)ce->ce_next)
|
||||
{
|
||||
if (!strcmp(ce->ce_varname, "bantime")) {
|
||||
if (!ce->ce_vardata) {
|
||||
config_error("%s:%i: set::scan::bantime has no value",
|
||||
ce->ce_fileptr->cf_filename, ce->ce_varlinenum);
|
||||
break;
|
||||
}
|
||||
Scan_BanTime = atime(ce->ce_vardata);
|
||||
}
|
||||
if (!strcmp(ce->ce_varname, "timeout")) {
|
||||
if (!ce->ce_vardata) {
|
||||
config_error("%s:%i: set::scan::timeout has no value",
|
||||
ce->ce_fileptr->cf_filename, ce->ce_varlinenum);
|
||||
break;
|
||||
}
|
||||
Scan_TimeOut = atime(ce->ce_vardata);
|
||||
}
|
||||
|
||||
if (!strcmp(ce->ce_varname, "endpoint"))
|
||||
{
|
||||
if (!ce->ce_vardata)
|
||||
@@ -369,3 +393,13 @@ DLLFUNC int h_config_set_scan(void)
|
||||
return 0;
|
||||
}
|
||||
|
||||
DLLFUNC int h_stats_scan(aClient *sptr, char *stats) {
|
||||
if (*stats == 'S') {
|
||||
sendto_one(sptr, ":%s %i %s :scan::endpoint: %s:%d", me.name, RPL_TEXT, sptr->name,
|
||||
Inet_si2p(&Scan_endpoint), ntohs(Scan_endpoint.SIN_PORT));
|
||||
sendto_one(sptr, ":%s %i %s :scan::bantime: %d", me.name, RPL_TEXT, sptr->name,
|
||||
Scan_BanTime);
|
||||
sendto_one(sptr, ":%s %i %s :scan::timeout: %d", me.name, RPL_TEXT, sptr->name,
|
||||
Scan_TimeOut);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,6 +63,7 @@ struct _hsstruct
|
||||
|
||||
static vFP xEadd_scan = NULL;
|
||||
static struct SOCKADDR_IN *xScan_endpoint = NULL;
|
||||
static int xScan_TimeOut = 0;
|
||||
static Hook *HttpScanHost = NULL;
|
||||
#ifdef STATIC_LINKING
|
||||
extern void Eadd_scan();
|
||||
@@ -77,6 +78,7 @@ static Mod_SymbolDepTable modsymdep[] =
|
||||
{
|
||||
MOD_Dep(Eadd_scan, xEadd_scan, "src/modules/scan.so"),
|
||||
MOD_Dep(Scan_endpoint, xScan_endpoint, "src/modules/scan.so"),
|
||||
MOD_Dep(Scan_TimeOut, xScan_TimeOut, "src/modules/scan.so"),
|
||||
{NULL, NULL}
|
||||
};
|
||||
|
||||
@@ -247,7 +249,7 @@ void scan_http_scan_port(HSStruct *z)
|
||||
}
|
||||
|
||||
/* We wait for write-ready */
|
||||
tv.tv_sec = 40;
|
||||
tv.tv_sec = xScan_TimeOut;
|
||||
tv.tv_usec = 0;
|
||||
FD_ZERO(&rfds);
|
||||
FD_SET(fd, &rfds);
|
||||
@@ -266,7 +268,7 @@ void scan_http_scan_port(HSStruct *z)
|
||||
goto exituniverse;
|
||||
}
|
||||
/* Now we wait for data. 10 secs ought to be enough */
|
||||
tv.tv_sec = 10;
|
||||
tv.tv_sec = xScan_TimeOut;
|
||||
tv.tv_usec = 0;
|
||||
FD_ZERO(&rfds);
|
||||
FD_SET(fd, &rfds);
|
||||
|
||||
@@ -59,6 +59,7 @@
|
||||
static Hook *SocksScanHost = NULL;
|
||||
static vFP xEadd_scan = NULL;
|
||||
static struct SOCKADDR_IN *xScan_endpoint = NULL;
|
||||
static int xScan_TimeOut = 0;
|
||||
#ifdef STATIC_LINKING
|
||||
extern void Eadd_scan();
|
||||
extern struct SOCKADDR_IN Scan_endpoint;
|
||||
@@ -75,6 +76,7 @@ static Mod_SymbolDepTable modsymdep[] =
|
||||
{
|
||||
MOD_Dep(Eadd_scan, xEadd_scan, "src/modules/scan.so"),
|
||||
MOD_Dep(Scan_endpoint, xScan_endpoint, "src/modules/scan.so"),
|
||||
MOD_Dep(Scan_TimeOut, xScan_TimeOut, "src/modules/scan.so"),
|
||||
{NULL, NULL}
|
||||
};
|
||||
|
||||
@@ -229,7 +231,7 @@ void scan_socks4_scan(Scan_AddrStruct *h)
|
||||
}
|
||||
|
||||
/* We wait for write-ready */
|
||||
tv.tv_sec = 40;
|
||||
tv.tv_sec = xScan_TimeOut;
|
||||
tv.tv_usec = 0;
|
||||
FD_ZERO(&rfds);
|
||||
FD_SET(fd, &rfds);
|
||||
@@ -260,7 +262,7 @@ void scan_socks4_scan(Scan_AddrStruct *h)
|
||||
goto exituniverse;
|
||||
}
|
||||
/* Now we wait for data. 10 secs ought to be enough */
|
||||
tv.tv_sec = 10;
|
||||
tv.tv_sec = xScan_TimeOut;
|
||||
tv.tv_usec = 0;
|
||||
FD_ZERO(&rfds);
|
||||
FD_SET(fd, &rfds);
|
||||
@@ -366,7 +368,7 @@ void scan_socks5_scan(Scan_AddrStruct *h)
|
||||
}
|
||||
|
||||
/* We wait for write-ready */
|
||||
tv.tv_sec = 40;
|
||||
tv.tv_sec = xScan_TimeOut;
|
||||
tv.tv_usec = 0;
|
||||
FD_ZERO(&rfds);
|
||||
FD_SET(fd, &rfds);
|
||||
@@ -388,7 +390,7 @@ void scan_socks5_scan(Scan_AddrStruct *h)
|
||||
CLOSE_SOCK(fd);
|
||||
goto exituniverse;
|
||||
}
|
||||
tv.tv_sec = 10;
|
||||
tv.tv_sec = xScan_TimeOut;
|
||||
tv.tv_usec = 0;
|
||||
FD_ZERO(&rfds);
|
||||
FD_SET(fd, &rfds);
|
||||
|
||||
@@ -2307,21 +2307,6 @@ int _conf_set(ConfigFile *conf, ConfigEntry *ce)
|
||||
}
|
||||
ircstrdup(prefix_quit, cep->ce_vardata);
|
||||
}
|
||||
else
|
||||
if (!strcmp(cep->ce_varname, "socks")) {
|
||||
for (cepp = cep->ce_entries; cepp; cepp = cepp->ce_next) {
|
||||
CheckNull(cepp);
|
||||
if (!strcmp(cepp->ce_varname, "ban-message")) {
|
||||
ircstrdup(SOCKSBANMSG, cepp->ce_vardata);
|
||||
}
|
||||
else if (!strcmp(cepp->ce_varname, "quit-message")) {
|
||||
ircstrdup(SOCKSQUITMSG, cepp->ce_vardata);
|
||||
}
|
||||
else if (!strcmp(cepp->ce_varname, "ban-time")) {
|
||||
SOCKSBANTIME = atime(cepp->ce_vardata);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (!strcmp(cep->ce_varname, "dns")) {
|
||||
for (cepp = cep->ce_entries; cepp; cepp = cepp->ce_next) {
|
||||
CheckNull(cepp);
|
||||
@@ -3089,18 +3074,6 @@ void validate_configuration(void)
|
||||
Error("set::help-channel is missing");
|
||||
if (Missing(STATS_SERVER))
|
||||
Warning("set::stats-server is missing. /statserv is being disabled");
|
||||
if (iConf.socksbantime < 10) {
|
||||
Warning("set::socks::ban-time is invalid. Using default of 1 day");
|
||||
iConf.socksbantime = 86400;
|
||||
}
|
||||
if (Missing(iConf.socksbanmessage)) {
|
||||
Warning("set::socks::ban-message is missing. Using default of \"Insecure SOCKS server\"");
|
||||
ircstrdup(iConf.socksbanmessage, "Insecure SOCKS server");
|
||||
}
|
||||
if (Missing(iConf.socksquitmessage)) {
|
||||
Warning("set::socks::quit-message is missing. Using default of \"Insecure SOCKS server\"");
|
||||
ircstrdup(iConf.socksquitmessage, "Insecure SOCKS server");
|
||||
}
|
||||
if ((CLOAK_KEY1 < 10000) || (CLOAK_KEY2 < 10000) || (CLOAK_KEY3 < 10000))
|
||||
{
|
||||
if (!CLOAK_KEY1 || !CLOAK_KEY2 || !CLOAK_KEY3)
|
||||
@@ -4065,12 +4038,6 @@ void report_dynconf(aClient *sptr)
|
||||
sptr->name, FAILOPER_WARN);
|
||||
sendto_one(sptr, ":%s %i %s :options::show-connect-info: %d", me.name, RPL_TEXT,
|
||||
sptr->name, SHOWCONNECTINFO);
|
||||
sendto_one(sptr, ":%s %i %s :socks::ban-message: %s", me.name, RPL_TEXT,
|
||||
sptr->name, iConf.socksbanmessage);
|
||||
sendto_one(sptr, ":%s %i %s :socks::quit-message: %s", me.name, RPL_TEXT,
|
||||
sptr->name, iConf.socksquitmessage);
|
||||
sendto_one(sptr, ":%s %i %s :socks::ban-time: %i", me.name, RPL_TEXT,
|
||||
sptr->name, iConf.socksbantime);
|
||||
sendto_one(sptr, ":%s %i %s :maxchannelsperuser: %i", me.name, RPL_TEXT,
|
||||
sptr->name, MAXCHANNELSPERUSER);
|
||||
sendto_one(sptr, ":%s %i %s :auto-join: %s", me.name, RPL_TEXT,
|
||||
|
||||
+3
-1
@@ -2259,8 +2259,10 @@ int m_stats(aClient *cptr, aClient *sptr, int parc, char *parv[])
|
||||
}
|
||||
break;
|
||||
case 'S':
|
||||
if (IsOper(sptr))
|
||||
if (IsOper(sptr)) {
|
||||
report_dynconf(sptr);
|
||||
RunHook2(HOOKTYPE_STATS, sptr, "S");
|
||||
}
|
||||
break;
|
||||
case 'D':
|
||||
{
|
||||
|
||||
+1
-1
@@ -676,7 +676,7 @@ int m_post(aClient *cptr, aClient *sptr, int parc, char *parv[])
|
||||
|
||||
tkllayer[4] = hostip;
|
||||
tkllayer[5] = me.name;
|
||||
ircsprintf(mo, "%li", iConf.socksbantime + TStime());
|
||||
ircsprintf(mo, "%li", 0 + TStime());
|
||||
ircsprintf(mo2, "%li", TStime());
|
||||
tkllayer[6] = mo;
|
||||
tkllayer[7] = mo2;
|
||||
|
||||
Reference in New Issue
Block a user