Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix several net-type bugs #1216

Open
wants to merge 7 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 60 additions & 5 deletions src/mod/irc.mod/irc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1161,7 +1161,7 @@ static void irc_report(int idx, int details)
* they support max_modes. If they support max_modes, set each of
* other sub-max settings equal to max_modes
*/
static void do_nettype()
static void do_nettype_irc()
{
switch (net_type_int) {
case NETT_EFNET:
Expand Down Expand Up @@ -1295,7 +1295,62 @@ static char *traced_nettype(ClientData cdata, Tcl_Interp *irp,
EGG_CONST char *name1,
EGG_CONST char *name2, int flags)
{
do_nettype();
const char *value;
int warn = 0;

value = Tcl_GetVar2(irp, name1, name2, TCL_GLOBAL_ONLY);
if (!strcasecmp(value, "DALnet"))
net_type_int = NETT_DALNET;
else if (!strcasecmp(value, "EFnet"))
net_type_int = NETT_EFNET;
else if (!strcasecmp(value, "freenode"))
net_type_int = NETT_FREENODE;
else if (!strcasecmp(value, "IRCnet"))
net_type_int = NETT_IRCNET;
else if (!strcasecmp(value, "Libera"))
net_type_int = NETT_LIBERA;
else if (!strcasecmp(value, "QuakeNet"))
net_type_int = NETT_QUAKENET;
else if (!strcasecmp(value, "Rizon"))
net_type_int = NETT_RIZON;
else if (!strcasecmp(value, "Undernet"))
net_type_int = NETT_UNDERNET;
else if (!strcasecmp(value, "Twitch"))
net_type_int = NETT_TWITCH;
else if (!strcasecmp(value, "Other"))
net_type_int = NETT_OTHER;
else if (!strcasecmp(value, "0")) { /* For backwards compatibility */
net_type_int = NETT_EFNET;
warn = 1;
} else if (!strcasecmp(value, "1")) { /* For backwards compatibility */
net_type_int = NETT_IRCNET;
warn = 1;
} else if (!strcasecmp(value, "2")) { /* For backwards compatibility */
net_type_int = NETT_UNDERNET;
warn = 1;
} else if (!strcasecmp(value, "3")) { /* For backwards compatibility */
net_type_int = NETT_DALNET;
warn = 1;
} else if (!strcasecmp(value, "4")) { /* For backwards compatibility */
net_type_int = NETT_HYBRID_EFNET;
warn = 1;
} else if (!strcasecmp(value, "5")) { /* For backwards compatibility */
net_type_int = NETT_OTHER;
warn = 1;
} else if (!online_since) {
fatal("ERROR: NET-TYPE NOT SET.\n Must be one of DALNet, EFnet, freenode, "
"Libera, IRCnet, Quakenet, Rizon, Undernet, Other.", 0);
} else
return("Must be one of DALNet, EFnet, freenode, Libera, IRCnet, Quakenet, "
"Rizon, Undernet, Other.");
if (warn) {
putlog(LOG_MISC, "*",
"INFO: The config setting for \"net-type\" has transitioned from a number\n"
"to a text string. Please update your choice to one of the allowed values\n"
"listed in the current configuration file from the source directory\n");
}
do_nettype_irc();
do_nettype_server();
return NULL;
}

Expand Down Expand Up @@ -1357,7 +1412,7 @@ static char *irc_close()
TCL_TRACE_READS | TCL_TRACE_WRITES | TCL_TRACE_UNSETS,
traced_rfccompliant, NULL);
Tcl_UntraceVar(interp, "net-type",
TCL_TRACE_READS | TCL_TRACE_WRITES | TCL_TRACE_UNSETS,
TCL_TRACE_WRITES | TCL_TRACE_UNSETS,
traced_nettype, NULL);
module_undepend(MODULE_NAME);
return NULL;
Expand Down Expand Up @@ -1443,7 +1498,7 @@ char *irc_start(Function *global_funcs)
add_hook(HOOK_ADD_MODE, (Function) real_add_mode);
add_hook(HOOK_IDLE, (Function) flush_modes);
Tcl_TraceVar(interp, "net-type",
TCL_TRACE_READS | TCL_TRACE_WRITES | TCL_TRACE_UNSETS,
TCL_TRACE_WRITES | TCL_TRACE_UNSETS,
traced_nettype, NULL);
Tcl_TraceVar(interp, "rfc-compliant",
TCL_TRACE_READS | TCL_TRACE_WRITES | TCL_TRACE_UNSETS,
Expand Down Expand Up @@ -1474,6 +1529,6 @@ char *irc_start(Function *global_funcs)
H_ircaway = add_bind_table("ircaway", HT_STACKABLE, channels_5char);
H_account = add_bind_table("account", HT_STACKABLE, channels_5char);
H_chghost = add_bind_table("chghost", HT_STACKABLE, channels_5char);
do_nettype();
do_nettype_irc();
return NULL;
}
82 changes: 6 additions & 76 deletions src/mod/server.mod/server.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ static int exclusive_binds; /* configures PUBM and MSGM binds to be
static int answer_ctcp; /* answer how many stacked ctcp's ? */
static int lowercase_ctcp; /* answer lowercase CTCP's (non-standard) */
static int check_mode_r; /* check for IRCnet +r modes */
static char net_type[9];
static int net_type_int;
static char net_type[9] = "EFnet";
static int net_type_int = NETT_EFNET;
static char connectserver[121]; /* what, if anything, to do before connect
* to the server */
static int resolvserv; /* in the process of resolving a server host */
Expand Down Expand Up @@ -1588,7 +1588,7 @@ static char *traced_botname(ClientData cdata, Tcl_Interp *irp,
return NULL;
}

static void do_nettype(void)
void do_nettype_server()
{
switch (net_type_int) {
case NETT_EFNET:
Expand Down Expand Up @@ -1645,69 +1645,6 @@ static void do_nettype(void)
}
}

static char *traced_nettype(ClientData cdata, Tcl_Interp *irp,
EGG_CONST char *name1,
EGG_CONST char *name2, int flags)
{
int warn = 0;

if (!strcasecmp(net_type, "DALnet"))
net_type_int = NETT_DALNET;
else if (!strcasecmp(net_type, "EFnet"))
net_type_int = NETT_EFNET;
else if (!strcasecmp(net_type, "freenode"))
net_type_int = NETT_FREENODE;
else if (!strcasecmp(net_type, "IRCnet"))
net_type_int = NETT_IRCNET;
else if (!strcasecmp(net_type, "Libera"))
net_type_int = NETT_LIBERA;
else if (!strcasecmp(net_type, "QuakeNet"))
net_type_int = NETT_QUAKENET;
else if (!strcasecmp(net_type, "Rizon"))
net_type_int = NETT_RIZON;
else if (!strcasecmp(net_type, "Undernet"))
net_type_int = NETT_UNDERNET;
else if (!strcasecmp(net_type, "Twitch"))
net_type_int = NETT_TWITCH;
else if (!strcasecmp(net_type, "Other"))
net_type_int = NETT_OTHER;
else if (!strcasecmp(net_type, "0")) { /* For backwards compatibility */
net_type_int = NETT_EFNET;
warn = 1;
}
else if (!strcasecmp(net_type, "1")) { /* For backwards compatibility */
net_type_int = NETT_IRCNET;
warn = 1;
}
else if (!strcasecmp(net_type, "2")) { /* For backwards compatibility */
net_type_int = NETT_UNDERNET;
warn = 1;
}
else if (!strcasecmp(net_type, "3")) { /* For backwards compatibility */
net_type_int = NETT_DALNET;
warn = 1;
}
else if (!strcasecmp(net_type, "4")) { /* For backwards compatibility */
net_type_int = NETT_HYBRID_EFNET;
warn = 1;
}
else if (!strcasecmp(net_type, "5")) { /* For backwards compatibility */
net_type_int = NETT_OTHER;
warn = 1;
} else {
fatal("ERROR: NET-TYPE NOT SET.\n Must be one of DALNet, EFnet, freenode, "
"Libera, IRCnet, Quakenet, Rizon, Undernet, Other.", 0);
}
if (warn) {
putlog(LOG_MISC, "*",
"INFO: The config setting for \"net-type\" has transitioned from a number\n"
"to a text string. Please update your choice to one of the allowed values\n"
"listed in the current configuration file from the source directory\n");
}
do_nettype();
return NULL;
}

static char *traced_nicklen(ClientData cdata, Tcl_Interp *irp,
EGG_CONST char *name1,
EGG_CONST char *name2, int flags)
Expand Down Expand Up @@ -2295,9 +2232,6 @@ static char *server_close()
Tcl_UntraceVar(interp, "serveraddress",
TCL_TRACE_READS | TCL_TRACE_WRITES | TCL_TRACE_UNSETS,
traced_serveraddress, NULL);
Tcl_UntraceVar(interp, "net-type",
TCL_TRACE_WRITES | TCL_TRACE_UNSETS,
traced_nettype, NULL);
Tcl_UntraceVar(interp, "nick-len",
TCL_TRACE_READS | TCL_TRACE_WRITES | TCL_TRACE_UNSETS,
traced_nicklen, NULL);
Expand Down Expand Up @@ -2387,7 +2321,8 @@ static Function server_table[] = {
(Function) encode_msgtags,
/* 52 - 55 */
(Function) & H_monitor,
(Function) isupport_get_prefixchars
(Function) isupport_get_prefixchars,
(Function) do_nettype_server
};

char *server_start(Function *global_funcs)
Expand Down Expand Up @@ -2433,7 +2368,6 @@ char *server_start(Function *global_funcs)
check_mode_r = 0;
maxqmsg = 300;
burst = 0;
strlcpy(net_type, "EFnet", sizeof net_type);
double_mode = 0;
double_server = 0;
double_help = 0;
Expand Down Expand Up @@ -2481,9 +2415,6 @@ char *server_start(Function *global_funcs)
Tcl_TraceVar(interp, "serveraddress",
TCL_TRACE_READS | TCL_TRACE_WRITES | TCL_TRACE_UNSETS,
traced_serveraddress, NULL);
Tcl_TraceVar(interp, "net-type",
TCL_TRACE_WRITES | TCL_TRACE_UNSETS,
traced_nettype, NULL);
Tcl_TraceVar(interp, "nick-len",
TCL_TRACE_READS | TCL_TRACE_WRITES | TCL_TRACE_UNSETS,
traced_nicklen, NULL);
Expand Down Expand Up @@ -2546,7 +2477,6 @@ char *server_start(Function *global_funcs)
newserver[0] = 0;
newserverport = 0;
curserv = 999;
/* Because this reads the interp variable, the read trace MUST be after */
do_nettype();
do_nettype_server();
return NULL;
}
1 change: 1 addition & 0 deletions src/mod/server.mod/server.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@
/* 52 - 55 */
#define H_monitor (*(p_tcl_bind_list *)(server_funcs[52]))
#define isupport_get_prefixchars ((const char *(*)(void))server_funcs[53])
#define do_nettype_server ((void (*) (void))server_funcs[54])


#endif /* MAKING_SERVER */
Expand Down