Thanks to visit codestin.com
Credit goes to github.com

Skip to content
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
3 changes: 3 additions & 0 deletions doc/sample-ngircd.conf.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,9 @@
;ConnectIPv6 = yes
;ConnectIPv4 = yes

# Default channel mode(s) to set on new channels. Default: none.
;DefaultChannelModes = n

# Default user mode(s) to set on new local clients. Please note that
# only modes can be set that the client could set using regular MODE
# commands, you can't set "a" (away) for example! Default: none.
Expand Down
6 changes: 5 additions & 1 deletion man/ngircd.conf.5.tmpl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.\"
.\" ngircd.conf(5) manual page template
.\"
.TH ngircd.conf 5 "May 2024" ngIRCd "ngIRCd Manual"
.TH ngircd.conf 5 "Sep 2025" ngIRCd "ngIRCd Manual"
.SH NAME
ngircd.conf \- configuration file of ngIRCd
.SH SYNOPSIS
Expand Down Expand Up @@ -273,6 +273,10 @@ Set this to no if you do not want ngIRCd to connect to other IRC servers using
the IPv6 protocol.
Default: yes.
.TP
\fBDefaultChannelModes\fR (string)
Default channel mode(s) to set on new channels.
Default: none.
.TP
\fBDefaultUserModes\fR (string)
Default user mode(s) to set on new local clients. Please note that only modes
can be set that the client could set using regular MODE commands, you can't
Expand Down
26 changes: 26 additions & 0 deletions src/ngircd/conf.c
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,7 @@ Conf_Test( void )
printf(" ConnectIPv4 = %s\n", yesno_to_str(Conf_ConnectIPv6));
printf(" ConnectIPv6 = %s\n", yesno_to_str(Conf_ConnectIPv4));
#endif
printf(" DefaultChannelModes = %s\n", Conf_DefaultChannelModes);
printf(" DefaultUserModes = %s\n", Conf_DefaultUserModes);
printf(" DNS = %s\n", yesno_to_str(Conf_DNS));
#ifdef IDENTAUTH
Expand Down Expand Up @@ -810,6 +811,7 @@ Set_Defaults(bool InitServers)
#else
Conf_ConnectIPv6 = false;
#endif
strcpy(Conf_DefaultChannelModes, "");
strcpy(Conf_DefaultUserModes, "");
Conf_DNS = true;
#ifdef IDENTAUTH
Expand Down Expand Up @@ -1654,6 +1656,30 @@ Handle_OPTIONS(const char *File, int Line, char *Var, char *Arg)
Conf_ConnectIPv4 = Check_ArgIsTrue(Arg);
return;
}
if (strcasecmp(Var, "DefaultChannelModes") == 0) {
p = Arg;
Conf_DefaultChannelModes[0] = '\0';
while (*p) {
if (strchr(Conf_DefaultChannelModes, *p)) {
/* Mode is already included; ignore it */
p++;
continue;
}

if (strchr(CHANMODES, *p)) {
len = strlen(Conf_DefaultChannelModes) + 1;
assert(len < sizeof(Conf_DefaultChannelModes));
Conf_DefaultChannelModes[len - 1] = *p;
Conf_DefaultChannelModes[len] = '\0';
} else {
Config_Error(LOG_WARNING,
"%s, line %d: Unknown channel mode \"%c\" in \"DefaultChannelModes\"!",
File, Line, *p);
}
p++;
}
return;
}
if (strcasecmp(Var, "DefaultUserModes") == 0) {
p = Arg;
Conf_DefaultUserModes[0] = '\0';
Expand Down
3 changes: 3 additions & 0 deletions src/ngircd/conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,9 @@ GLOBAL char Conf_PAMServiceName[MAX_PAM_SERVICE_NAME_LEN];
/** Disable all CTCP commands except for /me ? */
GLOBAL bool Conf_ScrubCTCP;

/** Default channel modes for new channels */
GLOBAL char Conf_DefaultChannelModes[CHANNEL_MODE_LEN];

/** Default user modes for new local clients */
GLOBAL char Conf_DefaultUserModes[CLIENT_MODE_LEN];

Expand Down
10 changes: 9 additions & 1 deletion src/ngircd/irc-channel.c
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ IRC_Send_Channel_Info(CLIENT *Client, CHANNEL *Chan)
GLOBAL bool
IRC_JOIN( CLIENT *Client, REQUEST *Req )
{
char *channame, *key = NULL, *flags, *lastkey = NULL, *lastchan = NULL;
char *channame, *key = NULL, *flags, *lastkey = NULL, *lastchan = NULL, *p;
CLIENT *target;
CHANNEL *chan;

Expand Down Expand Up @@ -389,6 +389,14 @@ IRC_JOIN( CLIENT *Client, REQUEST *Req )
if (!chan) { /* channel is new; it has been created above */
chan = Channel_Search(channame);
assert(chan != NULL);

/* Set default channel modes */
p = Conf_DefaultChannelModes;
while (*p) {
Channel_ModeAdd(chan, *p);
p++;
}

if (Channel_IsModeless(chan)) {
Channel_ModeAdd(chan, 't'); /* /TOPIC not allowed */
Channel_ModeAdd(chan, 'n'); /* no external msgs */
Expand Down
Loading