Skip to content

Commit b6404da

Browse files
committed
11.93: added 'truncate_hosts' ircd option to specify the max host length an ircd supports. closes #135. the 'no_host_slashes' ircd option now replaces slashes with dots. closes #115 for now.
1 parent d51aafe commit b6404da

File tree

5 files changed

+14
-13
lines changed

5 files changed

+14
-13
lines changed

INDEV

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3695,3 +3695,6 @@ CHANGES:
36953695
ircd and proto server keys are now always numeric. update oper notice to use link_type and ircd_name.
36963696

36973697
92. cleaned up ircd.pm by splitting the initializing process into 8 phases. closes #129.
3698+
3699+
93. added 'truncate_hosts' ircd option to specify the max host length an ircd supports. closes #135.
3700+
the 'no_host_slashes' ircd option now replaces slashes with dots. closes #115 for now.

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
11.92
1+
11.93

etc/default.conf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,7 @@
295295
nicklen = 9 # maximum nicj length
296296
no_host_slashes = on # don't allow slashes in hosts
297297
burst_topicwho = on # include the 'setby' param in TB
298+
truncate_hosts = 63 # truncate hosts to 63 characters
298299

299300
[ ircd_umodes: ratbox ]
300301

modules/TS6/Outgoing.module/Outgoing.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@
1212
"description" : "basic set of TS6 outgoing commands",
1313
"name" : "TS6::Outgoing",
1414
"package" : "M::TS6::Outgoing",
15-
"version" : "13.4"
15+
"version" : "13.5"
1616
}

modules/TS6/Outgoing.module/Outgoing.pm

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use 5.010;
2121

2222
use Scalar::Util qw(blessed);
2323
use M::TS6::Utils qw(ts6_id ts6_prefixes ts6_prefix ts6_closest_level);
24-
use utils qw(notice);
24+
use utils qw(notice cut_to_length);
2525

2626
our ($api, $mod, $pool, $me);
2727
my ($TS_CURRENT, $TS_MIN) =(
@@ -154,19 +154,16 @@ sub safe_nick {
154154
# ts6 host safety
155155
sub safe_host {
156156
my ($host, $serv) = @_;
157-
my $ircd = $serv->{ircd_name} // '';
158157

158+
# truncate when necessary
159+
if (my $limit = $serv->ircd_opt('truncate_hosts')) {
160+
$host = cut_to_length($limit, $host);
161+
}
162+
163+
# replace slashes with dots when necessary
159164
# HACK: see issue #115
160165
if ($serv->ircd_opt('no_host_slashes')) {
161-
my $out = '';
162-
for (split //, $host) {
163-
if (/[\/]/) {
164-
$out .= '.-'.ord().'.';
165-
next;
166-
}
167-
$out .= $_;
168-
}
169-
$host = $out;
166+
$host =~ s/\//\./g;
170167
}
171168

172169
return $host;

0 commit comments

Comments
 (0)