Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Synchronet
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Main
Synchronet
Commits
5a00606b
Commit
5a00606b
authored
1 year ago
by
Randy Sommerfeld
Browse files
Options
Downloads
Patches
Plain Diff
Comprehensive .ini and multi-RBL support
parent
bff5a691
No related branches found
No related tags found
1 merge request
!463
MRC mods by Codefenix (2024-10-20)
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
exec/ircd.js
+1
-0
1 addition, 0 deletions
exec/ircd.js
exec/load/ircd/config.js
+215
-20
215 additions, 20 deletions
exec/load/ircd/config.js
exec/load/ircd/core.js
+29
-18
29 additions, 18 deletions
exec/load/ircd/core.js
with
245 additions
and
38 deletions
exec/ircd.js
+
1
−
0
View file @
5a00606b
...
...
@@ -131,6 +131,7 @@ var QLines = []; /* [Q]uarantined (reserved) nicknames */
var
ULines
=
[];
/* Servers allowed to send unchecked MODE amongst other things */
var
YLines
=
[];
/* Defines what user & server objects get what settings */
var
ZLines
=
[];
/* IP based bans */
var
RBL
=
[];
/* RBL's */
/** Begin executing code **/
...
...
This diff is collapsed.
Click to expand it.
exec/load/ircd/config.js
+
215
−
20
View file @
5a00606b
...
...
@@ -15,6 +15,9 @@
Anything that handles manipulating the IRCd configuration.
BE AWARE that this file is loaded directly by programs other than the
IRCd, for example the UIFC interface for making config changes.
Copyright 2003-2023 Randy Sommerfeld <cyan@synchro.net>
*/
...
...
@@ -188,6 +191,7 @@ function Clear_Config_Globals() {
ULines
=
[];
YLines
=
[];
ZLines
=
[];
RBL
=
[];
Die_Password
=
""
;
Restart_Password
=
""
;
}
...
...
@@ -230,7 +234,7 @@ function Read_Config_File() {
}
function
ini_sections
()
{
this
.
IRCd
Info
=
ini_
IRCd
Info
;
this
.
Info
=
ini_Info
;
this
.
Port
=
ini_Port
;
this
.
ConnectClass
=
ini_ConnectClass
;
this
.
Allow
=
ini_Allow
;
...
...
@@ -241,61 +245,187 @@ function ini_sections() {
this
.
Hub
=
ini_Hub
;
}
function
ini_IRCdInfo
(
arg
,
ini
)
{
function
ini_Info
(
arg
,
ini
)
{
ServerName
=
format
(
"
%s.synchro.net
"
,
system
.
qwk_id
.
toLowerCase
());
if
(
ini
.
Hostname
)
ServerName
=
ini
.
Hostname
;
ServerDesc
=
ini
.
Info
;
ServerDesc
=
system
.
name
;
if
(
ini
.
Description
)
ServerDesc
=
ini
.
Description
;
Admin1
=
format
(
"
%s (%s)
"
,
system
.
name
,
system
.
qwk_id
);
if
(
ini
.
Admin1
)
Admin1
=
ini
.
Admin1
;
Admin2
=
system
.
version_notice
;
if
(
ini
.
Admin2
)
Admin2
=
ini
.
Admin2
;
Admin3
=
format
(
"
Sysop- <sysop@%s>
"
,
system
.
host_name
);
if
(
ini
.
Admin3
)
Admin3
=
ini
.
Admin3
;
}
/* Former M:Line */
/* Former M:Line
and P:Line combined into one
*/
function
ini_Port
(
arg
,
ini
)
{
var
port
=
parseInt
(
arg
);
if
(
port
!=
arg
)
{
log
(
LOG_WARNING
,
format
(
"
!WARNING Possible malformed port number in .ini: %s vs %u - section ignored.
"
,
arg
,
port
));
return
;
}
if
(
ini_false_true
(
ini
.
Default
))
{
Default_Port
=
arg
;
return
;
}
PLines
.
push
(
arg
);
return
;
}
/* Former Y:Line */
function
ini_ConnectClass
(
arg
,
ini
)
{
YLines
[
arg
]
=
new
YLine
(
parseInt
(
ini
.
PingFrequency
),
parseInt
(
ini
.
ConnectFrequency
),
parseInt
(
ini
.
Maximum
),
parseInt
(
ini
.
SendQ
)
/* Eventually it'd be nice to move to named classes instead of numbers. */
function
ini_Class
(
arg
,
ini
)
{
var
ircclass
=
parseInt
(
arg
);
if
(
ircclass
!=
arg
)
{
log
(
LOG_WARNING
,
format
(
"
!WARNING Possible malformed IRC class in .ini: %s vs %u - section ignored.
"
,
arg
,
ircclass
));
return
;
}
YLines
[
ircclass
]
=
new
YLine
(
ini_int_min_max
(
ini
.
PingFrequency
,
1
,
999
,
60
,
format
(
"
PingFrequency IRC class %u
"
,
ircclass
)),
ini_int_min_max
(
ini
.
ConnectFrequency
,
1
,
9999
,
60
,
format
(
"
ConnectFrequency IRC class %u
"
,
ircclass
)),
ini_int_min_max
(
ini
.
Maximum
,
1
,
99999
,
100
,
format
(
"
Maximum IRC class %u
"
,
ircclass
)),
ini_int_min_max
(
ini
.
SendQ
,
2048
,
999999999
,
1000000
,
format
(
"
SendQ IRC class %u
"
,
ircclass
))
);
}
/* Former I:Line */
function
ini_Allow
(
arg
,
ini
)
{
var
ircclass
;
if
(
!
ini
.
Mask
.
match
(
"
[@]
"
))
{
log
(
LOG_WARNING
,
"
!WARNING Malformed mask in Allow section. Proper format is user@hostname but usually *@*
"
);
return
;
}
ircclass
=
parseInt
(
ini
.
Class
);
if
(
ircclass
!=
ini
.
Class
)
{
log
(
LOG_WARNING
,
format
(
"
!WARNING No IRC class or malformed IRC class in Allow:%s. Using class of 0.
"
,
arg
));
ircclass
=
0
;
}
ILines
[
arg
]
=
new
ILine
(
ini
.
Mask
,
null
,
/* password */
ini
.
Mask
,
/* hostmask */
null
,
/* port */
0
/*
irc
class
*/
ircclass
);
}
/* Former O:Line */
function
ini_Operator
(
arg
,
ini
)
{
var
ircclass
;
if
(
!
ini
.
Nick
||
!
ini
.
Mask
||
!
ini
.
Password
||
!
ini
.
Flags
||
!
ini
.
Class
)
{
log
(
LOG_WARNING
,
format
(
"
!WARNING Missing information from Operator:%s. Section ignored.
"
,
arg
));
return
;
}
if
(
!
ini
.
Mask
.
match
(
"
[@]
"
))
{
log
(
LOG_WARNING
,
format
(
"
!WARNING Malformed mask in Operator:%s. Proper format is user@hostname with wildcards.
"
,
arg
));
return
;
}
ircclass
=
parseInt
(
ini
.
Class
);
if
(
ircclass
!=
ini
.
Class
)
{
log
(
LOG_WARNING
,
format
(
"
!WARNING Malformed IRC Class in Operator:%s. Proceeding with Class 0.
"
,
arg
));
ircclass
=
0
;
}
OLines
.
push
(
new
OLine
(
ini
.
Mask
,
ini
.
Password
,
ini
.
Nick
,
parse_oline_flags
(
ini
.
Flags
),
ircclass
));
return
;
}
/* Former U:Line */
function
ini_Services
(
arg
,
ini
)
{
if
(
ini
.
Server
)
ULines
.
push
(
ini
.
Server
);
return
;
}
/* Former K:Line & Z:Line */
function
ini_Ban
(
arg
,
ini
)
{
var
kline_mask
;
if
(
!
ini
.
Mask
)
{
log
(
LOG_WARNING
,
format
(
"
!WARNING No mask provided in Ban:%s. Ignoring.
"
,
arg
));
return
;
}
kline_mask
=
create_ban_mask
(
ini
.
Mask
,
true
/* kline */
);
if
(
!
kline_mask
)
{
log
(
LOG_WARNING
,
format
(
"
!WARNING Invalid ban mask %s Ignoring.
"
,
ini
.
Mask
));
return
;
}
function
ini_Restrict
(
arg
,
ini
)
{
KLines
.
push
(
new
KLine
(
kline_mask
,
ini
.
Reason
?
ini
.
Reason
:
"
No reason provided.
"
,
"
K
"
/* ban type: K, A, or Z. */
));
}
/* Former H:Line */
/* Servermasks are deprecated */
function
ini_Hub
(
arg
,
ini
)
{
HLines
.
push
(
new
HLine
(
"
*
"
,
/* servermask permitted */
arg
/* servername */
ini
.
Server
/* servername */
));
}
function
ini_RBL
(
arg
,
ini
)
{
if
(
!
ini
.
Hostname
)
{
log
(
LOG_WARNING
,
format
(
"
!WARNING No Hostname in RBL:%s. Ignoring.
"
,
arg
));
return
;
}
RBL
.
push
(
ini
.
Hostname
);
}
function
load_config_defaults
()
{
...
...
@@ -348,13 +478,78 @@ function read_ini_config(conf) {
var
Sections
=
new
ini_sections
();
var
i
,
s
;
for
(
var
i
in
ini
)
{
for
(
i
in
ini
)
{
if
(
ini_false_true
(
i
.
disabled
)
||
ini_false_true
(
i
.
Disabled
))
continue
;
if
(
!
ini_true_false
(
i
.
enabled
)
||
!
ini_true_false
(
i
.
Enabled
))
continue
;
s
=
i
.
name
.
split
(
"
:
"
);
if
(
typeof
Sections
[
s
[
0
]]
===
'
function
'
)
Sections
[
s
[
0
]](
s
[
1
],
i
);
}
}
function
ini_int_min_max
(
str
,
min
,
max
,
def
,
desc
)
{
var
input
=
parseInt
(
str
);
if
(
input
!=
str
)
{
log
(
LOG_WARNING
,
format
(
"
!WARNING Malformed value (%s vs. %u) in %s. Using default of %u.
"
,
str
,
input
,
desc
,
def
));
return
def
;
}
if
(
!
input
||
(
input
<
min
))
{
log
(
LOG_WARNING
,
format
(
"
!WARNING Value %u too low in %s. Using default of %u.
"
,
input
,
desc
,
def
));
return
def
;
}
if
(
input
>
max
)
{
log
(
LOG_WARNING
,
format
(
"
!WARNING Value %u too high in %s. Consider lowering it.
"
,
input
,
desc
,
def
));
}
return
input
;
}
function
ini_false_true
(
str
)
{
if
(
typeof
str
!==
"
string
"
)
return
false
;
str
=
str
.
toUpperCase
();
switch
(
str
[
0
])
{
case
"
1
"
:
case
"
Y
"
:
case
"
T
"
:
return
true
;
default
:
return
false
;
}
}
function
ini_true_false
(
str
)
{
if
(
typeof
str
!==
"
string
"
)
return
true
;
str
=
str
.
toUpperCase
();
switch
(
str
[
0
])
{
case
"
0
"
:
case
"
N
"
:
case
"
F
"
:
return
false
;
default
:
return
true
;
}
}
function
read_conf_config
(
conf
)
{
var
conf_line
,
arg
,
i
;
...
...
This diff is collapsed.
Click to expand it.
exec/load/ircd/core.js
+
29
−
18
View file @
5a00606b
...
...
@@ -2766,9 +2766,7 @@ function IRCClient_finalize_server_connect(states) {
}
function
accept_new_socket
()
{
var
unreg_obj
;
var
id
;
var
sock
;
var
unreg_obj
,
id
,
sock
,
num_rbls
,
count
,
i
,
dnsbl_result
;
sock
=
this
.
accept
();
...
...
@@ -2805,29 +2803,42 @@ function accept_new_socket() {
return
false
;
}
// Start of DNSBL check
if
(
!
dnsbl_exempt
(
sock
.
remote_ip_address
))
{
const
dnsbl_result
=
check_dnsbl
(
sock
.
remote_ip_address
,
'
dnsbl.dronebl.org
'
);
if
(
dnsbl_result
)
{
if
(
IP_Banned
(
sock
.
remote_ip_address
))
{
sock
.
send
(
format
(
"
:%s 46
3
* :You
r IP address is not welcome. Visit http://dronebl.org/lookup?ip=
"
+
sock
.
remote_ip_address
+
"
&network=Synchronet for more information.
"
,
"
:%s 46
5
* :You
've been banned from this server.
\r\n
"
,
ServerName
));
log
(
LOG_NOTICE
,
format
(
"
DNS-Blocked IP address %s resolves to %s
"
,
sock
.
remote_ip_address
,
dnsbl_result
));
sock
.
close
();
return
false
;
}
}
// End of DNSBL check
if
(
IP_Banned
(
sock
.
remote_ip_address
))
{
num_rbls
=
true_array_len
(
RBL
);
if
(
!
dnsbl_exempt
(
sock
.
remote_ip_address
))
{
count
=
0
;
for
(
i
in
RBL
)
{
count
++
;
sock
.
send
(
format
(
"
:%s NOTICE * :Performing RBL check %u of %u. Please stand by.
"
,
ServerName
,
count
,
num_rbls
));
dnsbl_result
=
check_dnsbl
(
sock
.
remote_ip_address
,
RBL
[
i
]);
if
(
dnsbl_result
)
{
sock
.
send
(
format
(
"
:%s 46
5
* :You
've bee
n
b
an
ned from this server.
\r\n
"
,
"
:%s 46
3
* :You
r IP address is o
n an
RBL. Connection denied.
"
,
ServerName
));
log
(
LOG_NOTICE
,
format
(
"
DNS-Blocked IP address %s resolves to %s from RBL %s
"
,
sock
.
remote_ip_address
,
dnsbl_result
,
RBL
[
i
]
));
sock
.
close
();
return
false
;
}
}
}
if
(
server
.
client_add
!==
undefined
)
{
server
.
client_add
(
sock
);
...
...
This diff is collapsed.
Click to expand it.
Ghost User
@ghost
mentioned in issue
#647 (closed)
·
1 year ago
mentioned in issue
#647 (closed)
mentioned in issue #647
Toggle commit list
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment