mirror of
git://scm.dxcluster.org/scm/spider
synced 2024-09-21 07:47:10 +00:00
add the ability to limit no of connections
Add the ability to limit the no of connections an incoming user/node has. If a node/user is already connected elsewhere more than the maximum no of times then this incoming connection is refused.
This commit is contained in:
parent
624fab70a1
commit
8081646e93
5
Changes
5
Changes
@ -1,5 +1,10 @@
|
|||||||
01Oct08=======================================================================
|
01Oct08=======================================================================
|
||||||
1. added CTY-1809 prefix data
|
1. added CTY-1809 prefix data
|
||||||
|
2. added new config variables to allow an incoming users to have (as default)
|
||||||
|
up to 2 other connections to other nodes and incoming nodes up to 8 other
|
||||||
|
parents. Note that you can switch off this behaviour by setting
|
||||||
|
$main::maxconnect_user or $main::maxconnect_node = 0 (or set them to whatever
|
||||||
|
you need).
|
||||||
28Jun08=======================================================================
|
28Jun08=======================================================================
|
||||||
1. Made buddies work again on PC92.
|
1. Made buddies work again on PC92.
|
||||||
26Jun08=======================================================================
|
26Jun08=======================================================================
|
||||||
|
@ -15,7 +15,7 @@ foreach my $nref (@nodes) {
|
|||||||
my $ncall = $nref->call;
|
my $ncall = $nref->call;
|
||||||
next if @list && !grep $ncall =~ m|$_|, @list;
|
next if @list && !grep $ncall =~ m|$_|, @list;
|
||||||
my $call = $nref->user_call;
|
my $call = $nref->user_call;
|
||||||
my $l = join ',', (map {my $ref = Route::Node::get($_); $ref ? ($ref->user_call) : ("$_?")} sort @{$nref->parent});
|
my $l = join ',', (map {my $ref = Route::Node::get($_); $ref ? ($ref->user_call) : ("$_?")} sort $nref->parents);
|
||||||
push @out, "$call->$l";
|
push @out, "$call->$l";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ foreach my $uref (@users) {
|
|||||||
my $ucall = $uref->call;
|
my $ucall = $uref->call;
|
||||||
next if @list && !grep $ucall =~ m|$_|, @list;
|
next if @list && !grep $ucall =~ m|$_|, @list;
|
||||||
my $call = $uref->user_call;
|
my $call = $uref->user_call;
|
||||||
my $l = join ',', (map {my $ref = Route::Node::get($_); $ref ? ($ref->user_call) : ("$_?")} sort @{$uref->parent});
|
my $l = join ',', (map {my $ref = Route::Node::get($_); $ref ? ($ref->user_call) : ("$_?")} sort $uref->parents);
|
||||||
push @out, "$call->$l";
|
push @out, "$call->$l";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -218,7 +218,7 @@ sub start
|
|||||||
foreach my $call (@{$user->buddies}) {
|
foreach my $call (@{$user->buddies}) {
|
||||||
my $ref = Route::User::get($call);
|
my $ref = Route::User::get($call);
|
||||||
if ($ref) {
|
if ($ref) {
|
||||||
foreach my $node (@{$ref->parent}) {
|
foreach my $node ($ref->parents) {
|
||||||
$self->send($self->msg($node eq $main::mycall ? 'loginb' : 'loginbn', $call, $node));
|
$self->send($self->msg($node eq $main::mycall ? 'loginb' : 'loginbn', $call, $node));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1860,7 +1860,7 @@ sub find_pc9x_routes
|
|||||||
if ($ref->isa('Route::User')) {
|
if ($ref->isa('Route::User')) {
|
||||||
my $dxchan = DXChannel::get($to);
|
my $dxchan = DXChannel::get($to);
|
||||||
push @parent, $to if $dxchan;
|
push @parent, $to if $dxchan;
|
||||||
push @parent, @{$ref->parent};
|
push @parent, $ref->parents;
|
||||||
} else {
|
} else {
|
||||||
@parent = $to;
|
@parent = $to;
|
||||||
}
|
}
|
||||||
|
@ -36,6 +36,7 @@ package DXM;
|
|||||||
chattoomany => 'Not allowed, already in $_[1], use /chat $_[0]',
|
chattoomany => 'Not allowed, already in $_[1], use /chat $_[0]',
|
||||||
conother => 'Sorry $_[0] you are connected to me on another port',
|
conother => 'Sorry $_[0] you are connected to me on another port',
|
||||||
concluster => 'Sorry $_[0] you are already connected elsewhere on the cluster (on $_[1])',
|
concluster => 'Sorry $_[0] you are already connected elsewhere on the cluster (on $_[1])',
|
||||||
|
contomany => 'Sorry $_[0] but you are already connected to $_[1] other nodes (on $_[2])',
|
||||||
conscript => 'no connect script called \"$_[0]\" found in $main::root/connect',
|
conscript => 'no connect script called \"$_[0]\" found in $main::root/connect',
|
||||||
confail => 'connection to $_[0] failed ($_[1])',
|
confail => 'connection to $_[0] failed ($_[1])',
|
||||||
constart => 'connection to $_[0] started',
|
constart => 'connection to $_[0] started',
|
||||||
|
@ -375,7 +375,6 @@ sub delete_interface
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# track destruction
|
# track destruction
|
||||||
#
|
#
|
||||||
|
@ -221,12 +221,6 @@ sub nodes
|
|||||||
return @{$self->{nodes}};
|
return @{$self->{nodes}};
|
||||||
}
|
}
|
||||||
|
|
||||||
sub parents
|
|
||||||
{
|
|
||||||
my $self = shift;
|
|
||||||
return @{$self->{parent}};
|
|
||||||
}
|
|
||||||
|
|
||||||
sub rnodes
|
sub rnodes
|
||||||
{
|
{
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
|
@ -92,6 +92,8 @@ sub delparent
|
|||||||
return $self->_dellist('parent', @_);
|
return $self->_dellist('parent', @_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# generic AUTOLOAD for accessors
|
# generic AUTOLOAD for accessors
|
||||||
#
|
#
|
||||||
|
@ -11,6 +11,6 @@ use vars qw($version $subversion $build);
|
|||||||
|
|
||||||
$version = '1.55';
|
$version = '1.55';
|
||||||
$subversion = '0';
|
$subversion = '0';
|
||||||
$build = '27';
|
$build = '28';
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
@ -118,7 +118,7 @@ use vars qw(@inqueue $systime $starttime $lockfn @outstanding_connects
|
|||||||
$zombies $root @listeners $lang $myalias @debug $userfn $clusteraddr
|
$zombies $root @listeners $lang $myalias @debug $userfn $clusteraddr
|
||||||
$clusterport $mycall $decease $is_win $routeroot $me $reqreg $bumpexisting
|
$clusterport $mycall $decease $is_win $routeroot $me $reqreg $bumpexisting
|
||||||
$allowdxby $dbh $dsn $dbuser $dbpass $do_xml $systime_days $systime_daystart
|
$allowdxby $dbh $dsn $dbuser $dbpass $do_xml $systime_days $systime_daystart
|
||||||
$can_encode
|
$can_encode $maxconnect_user $maxconnect_node
|
||||||
);
|
);
|
||||||
|
|
||||||
@inqueue = (); # the main input queue, an array of hashes
|
@inqueue = (); # the main input queue, an array of hashes
|
||||||
@ -129,7 +129,10 @@ $starttime = 0; # the starting time of the cluster
|
|||||||
$reqreg = 0; # 1 = registration required, 2 = deregister people
|
$reqreg = 0; # 1 = registration required, 2 = deregister people
|
||||||
$bumpexisting = 1; # 1 = allow new connection to disconnect old, 0 - don't allow it
|
$bumpexisting = 1; # 1 = allow new connection to disconnect old, 0 - don't allow it
|
||||||
$allowdxby = 0; # 1 = allow "dx by <othercall>", 0 - don't allow it
|
$allowdxby = 0; # 1 = allow "dx by <othercall>", 0 - don't allow it
|
||||||
|
$maxconnect_user = 3; # the maximum no of concurrent connections a user can have at a time
|
||||||
|
$maxconnect_node = 8; # Ditto but for nodes. In either case if a new incoming connection
|
||||||
|
# takes the no of references in the routing table above these numbers
|
||||||
|
# then the connection is refused. This only affects INCOMING connections.
|
||||||
|
|
||||||
# send a message to call on conn and disconnect
|
# send a message to call on conn and disconnect
|
||||||
sub already_conn
|
sub already_conn
|
||||||
@ -182,6 +185,19 @@ sub new_channel
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# (fairly) politely disconnect people that are connected to too many other places at once
|
||||||
|
my $r = Route::get($call);
|
||||||
|
if ($r) {
|
||||||
|
my @n = $r->parents;
|
||||||
|
my $v = $r->isa('Route::Node') ? $maxconnect_node : $maxconnect_user;
|
||||||
|
if ($v && @n >= $v) {
|
||||||
|
my $nodes = join ',', @n;
|
||||||
|
LogDbg('DXCommand', "$call has too many connections ($v) at $nodes, disconnected");
|
||||||
|
already_conn($conn, $call, DXM::msg($lang, 'contomany', $call, $v, $nodes));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
# is he locked out ?
|
# is he locked out ?
|
||||||
my $basecall = $call;
|
my $basecall = $call;
|
||||||
$basecall =~ s/-\d+$//;
|
$basecall =~ s/-\d+$//;
|
||||||
|
Loading…
Reference in New Issue
Block a user