Skip to content

Commit 40dbd62

Browse files
committed
8.98: fixed a bug where servers would send ERR_UNKNOWNCOMMAND after incoming numerics which were being sent due to the recent changes that allow numerics to be fired on connection objects.
numerics are no longer sent to servers (not with the server as the target anyway). servers now do not send ERR_UNKNOWNCOMMAND to other registered servers, and all incoming numerics are ignored.
1 parent 1d0d714 commit 40dbd62

File tree

7 files changed

+54
-30
lines changed

7 files changed

+54
-30
lines changed

INDEV

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2506,10 +2506,10 @@ CHANGES:
25062506

25072507
94. moved the remainder of the command handlers to the new API.
25082508
removed the hideous old parameter parser.
2509-
RPL_UNKNOWNCOMMAND is now an event callback that is canceled by handler wrappers.
2509+
ERR_UNKNOWNCOMMAND is now an event callback that is canceled by handler wrappers.
25102510

25112511
95. updated Fantasy for the new evented command handler.
2512-
fixed an issue where parameter parser errors would lead to RPL_UNKNOWNCOMMAND.
2512+
fixed an issue where parameter parser errors would lead to ERR_UNKNOWNCOMMAND.
25132513
fixed a vulnerability where commands using echo or PRIVMSG could trigger additional fantasy commands.
25142514

25152515
96. message object ->source now automatically determines source object.
@@ -2519,6 +2519,10 @@ CHANGES:
25192519
97. silently ignore unhandled numerics from servers.
25202520
removed the matcher identifier code as it was unused and causing problems for the '...' (synonymous with @rest) modifier.
25212521

2522+
98. fixed a bug where servers would send ERR_UNKNOWNCOMMAND after incoming numerics which were being sent due to the recent changes that allow numerics to be fired on connection objects.
2523+
numerics are no longer sent to servers (not with the server as the target anyway).
2524+
servers now do not send ERR_UNKNOWNCOMMAND to other registered servers, and all incoming numerics are ignored.
2525+
25222526

25232527

25242528

TODO

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ Server linkage
137137
[*] Connection timers continue even after an ERROR message is received. Sometimes two
138138
timers may be ticking for the same server.
139139

140-
[*] SQUIT and CONNECT still do not work quite right, probably due to the above issues
140+
[ ] SQUIT and CONNECT still do not work quite right, probably due to the above issues
141141
with connection timers.
142142

143143
[ ] SQUIT and CONNECT probably do not accept server masks.
@@ -160,7 +160,7 @@ User commands that are in desperate need of rewriting
160160

161161
[ ] WHO needs to be evented, extensible, and fully supportive of WHOX
162162

163-
[ ] WHOIS needs to be evented and extensible
163+
[] WHOIS needs to be evented and extensible
164164

165165
Other user commands
166166
------------------------------------------------------------------------------------------

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
8.97
1+
8.98
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
{
2-
"version" : "8.96",
2+
"version" : "8.98",
33
"name" : "ircd::connection",
4+
"no_bless" : 1,
45
"author" : {
56
"website" : "https://github.com/cooper",
67
"name" : "Mitchell Cooper"
78
},
8-
"no_bless" : 1,
9-
"preserve_sym" : 1,
109
"description" : "represents a connection to the server",
10+
"preserve_sym" : 1,
1111
"package" : "connection"
1212
}

modules/ircd.module/connection.module/connection.pm

Lines changed: 37 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use 5.010;
1818
use parent 'Evented::Object';
1919

2020
use Socket::GetAddrInfo;
21-
use Scalar::Util 'weaken';
21+
use Scalar::Util qw(weaken blessed);
2222
use utils qw(conf v notice);
2323

2424
our ($api, $mod, $me, $pool);
@@ -32,14 +32,14 @@ sub init {
3232
# THIS IS ONLY USED FOR SERVERS AS OF 8 July 2014.
3333
$pool->on('connection.raw' => sub {
3434
my ($connection, $event, $data, @args) = @_;
35-
return unless $connection->{type};
36-
return unless $connection->{type}->isa('server');
35+
return unless $connection->server;
3736
$connection->{type}->handle($data, \@args);
3837
}, name => 'high.level.handlers', priority => -100, with_eo => 1);
3938

4039
# send unknown command. this is canceled by handlers.
4140
$pool->on('connection.message' => sub {
4241
my ($connection, $event, $msg) = @_;
42+
return if $connection->server;
4343
$connection->numeric(ERR_UNKNOWNCOMMAND => $msg->raw_cmd);
4444
return;
4545
}, name => 'ERR_UNKNOWNCOMMAND', priority => -200, with_eo => 1);
@@ -108,10 +108,11 @@ sub handle {
108108
);
109109

110110
# user events.
111+
my $user = $connection->user;
111112
push @events,
112-
[ $connection->{type}, message => $msg ],
113-
[ $connection->{type}, "message_${cmd}" => $msg ]
114-
if $connection->{type} && $connection->{type}->isa('user');
113+
[ $user, message => $msg ],
114+
[ $user, "message_${cmd}" => $msg ]
115+
if $user;
115116

116117
# fire with safe option.
117118
my $fire = $connection->prepare(@events)->fire('safe');
@@ -229,7 +230,7 @@ sub ready {
229230
}
230231

231232
weaken($connection->{type}{conn} = $connection);
232-
$connection->{type}->new_connection if $connection->{type}->isa('user');
233+
$connection->{type}->new_connection if $connection->user;
233234
return $connection->{ready} = 1;
234235
}
235236

@@ -251,8 +252,7 @@ sub sendfrom {
251252
sub sendme {
252253
my $connection = shift;
253254
my $source =
254-
$connection->{type} && $connection->{type}->isa('server') ?
255-
$me->{sid} : $me->{name};
255+
$connection->server ? $me->{sid} : $me->{name};
256256
$connection->sendfrom($source, @_);
257257
}
258258

@@ -283,7 +283,7 @@ sub early_reply {
283283

284284
# end a connection. this must be foolproof.
285285
sub done {
286-
my ($connection, $reason, $silent) = @_;
286+
my ($connection, $reason) = @_;
287287
L("Closing connection from $$connection{ip}: $reason");
288288

289289

@@ -298,9 +298,8 @@ sub done {
298298

299299
}
300300

301-
# I'm not sure where $silent is even used these days.
302301
# this is safe because ->send() is safe now.
303-
$connection->send("ERROR :Closing Link: $$connection{host} ($reason)") unless $silent;
302+
$connection->send("ERROR :Closing Link: $$connection{host} ($reason)");
304303

305304
# remove from connection the pool if it's still there.
306305
# if the connection has reserved a nick, release it.
@@ -350,8 +349,11 @@ sub numeric {
350349
@response = sprintf $val, @_;
351350
}
352351

353-
# local user.
354-
my $nick = ($connection->{type} || $connection)->{nick} // '*';
352+
# ignore registered servers.
353+
return if $connection->server;
354+
355+
# send.
356+
my $nick = ($connection->user || $connection)->{nick} // '*';
355357
$connection->sendme("$num $nick $_") foreach @response;
356358

357359
return 1;
@@ -362,7 +364,7 @@ sub numeric {
362364
### CAPABILITIES ###
363365
####################
364366

365-
# has a capability
367+
# has a capability.
366368
sub has_cap {
367369
my ($connection, $flag) = (shift, lc shift);
368370
return unless $connection->{cap_flags};
@@ -372,7 +374,7 @@ sub has_cap {
372374
return;
373375
}
374376

375-
# add a capability
377+
# add a capability.
376378
sub add_cap {
377379
my ($connection, @flags) = (shift, map { lc } @_);
378380
foreach my $flag (@flags) {
@@ -382,7 +384,7 @@ sub add_cap {
382384
return 1;
383385
}
384386

385-
# remove a capability
387+
# remove a capability.
386388
sub remove_cap {
387389
my ($connection, @flags) = (shift, map { lc } @_);
388390
return unless $connection->{cap_flags};
@@ -396,4 +398,22 @@ sub DESTROY {
396398
L("$connection destroyed");
397399
}
398400

401+
#############
402+
### TYPES ###
403+
#############
404+
405+
sub type { shift->{type} }
406+
407+
sub user {
408+
my $type = shift->{type};
409+
blessed $type && $type->isa('user') or return;
410+
return $type;
411+
}
412+
413+
sub server {
414+
my $type = shift->{type};
415+
blessed $type && $type->isa('server') or return;
416+
return $type;
417+
}
418+
399419
$mod

modules/ircd.module/ircd.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
{
2-
"version" : "8.95",
2+
"version" : "8.98",
33
"name" : "ircd",
4-
"no_bless" : 1,
54
"author" : {
65
"website" : "https://github.com/cooper",
76
"name" : "Mitchell Cooper"
87
},
9-
"description" : "main IRCd module",
8+
"no_bless" : 1,
109
"preserve_sym" : 1,
10+
"description" : "main IRCd module",
1111
"package" : "ircd"
1212
}

modules/ircd.module/ircd.pm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,7 @@ sub handle_connect {
505505
sub handle_data {
506506
my ($stream, $buffer) = @_;
507507
my $connection = $pool->lookup_connection($stream) or return;
508-
my $is_server = $connection->{type} && $connection->{type}->isa('server');
508+
my $is_server = $connection->server;
509509

510510
# fetch the values at which the limit was exceeded.
511511
my $overflow_1line = (my $max_in_line = conf('limit', 'bytes_line') // 2048) + 1;
@@ -573,7 +573,7 @@ sub ping_check {
573573
next;
574574
}
575575

576-
my $type = $connection->{type}->isa('user') ? 'user' : 'server';
576+
my $type = $connection->user ? 'user' : 'server';
577577
my $since_last = time - $connection->{last_response};
578578

579579
# no incoming data for configured frequency.

0 commit comments

Comments
 (0)