Add set/maxconnect command
authorDirk Koopman <djk@tobit.co.uk>
Thu, 2 Oct 2008 09:13:18 +0000 (10:13 +0100)
committerDirk Koopman <djk@tobit.co.uk>
Thu, 2 Oct 2008 09:13:18 +0000 (10:13 +0100)
Changes
cmd/Commands_en.hlp
cmd/set/maxconnect.pl [new file with mode: 0644]
perl/DXUser.pm
perl/Messages
perl/Version.pm
perl/cluster.pl

diff --git a/Changes b/Changes
index e84146cb7423f8e4455ee5f4a26d7b4dc2bd743c..bcc4bf544f4fb9e5497f85ffb24110d23140904c 100644 (file)
--- a/Changes
+++ b/Changes
@@ -1,3 +1,6 @@
+02Oct08=======================================================================
+1. Add set/maxconnect command to allow the defaults to be overridden for
+individual users/nodes.
 01Oct08=======================================================================
 1. added CTY-1809 prefix data
 2. added new config variables to allow an incoming users to have (as default)
index c7b436aac37a10d6796d1175f9ef510a7344eae6..86e22d4c672c84f3a60919a045f017efa96bd9bd 100644 (file)
@@ -1659,6 +1659,20 @@ then this command will set your QRA locator for you. For example:-
 === 9^SET/LOCKOUT <call>^Stop a callsign connecting to the cluster
 === 9^UNSET/LOCKOUT <call>^Allow a callsign to connect to the cluster
 
+=== 8^SET/MAXCONNECT <value> [<call> ..]^Set max incoming connections for user/node
+Set the maximum no of connections (parents) an incoming user or node is
+allowed to have. If this incoming connection takes it over the separate
+limits for users and nodes (defaults: 3 and 8 respectively), then the
+connection is refused (with a polite message).
+
+The idea behind this to limit the number of copies of messages that
+are sent to users (and nodes). Nodes really don't need to have more than
+5 or 6 partners and users don't need more than two connections into the
+cluster cloud.
+
+This check is only for INCOMING connections, no check is performed for
+outgoing connections.
+
 === 0^SET/NAME <your name>^Set your name
 Tell the system what your name is eg:-
   SET/NAME Dirk
diff --git a/cmd/set/maxconnect.pl b/cmd/set/maxconnect.pl
new file mode 100644 (file)
index 0000000..715b355
--- /dev/null
@@ -0,0 +1,31 @@
+#
+# set the maximum no of connections this user/node can have
+# whilst connecting to this node
+#
+# Copyright (c) 2008 - Dirk Koopman G1TLH
+#
+
+my ($self, $line) = @_;
+my @args = split /\s+/, $line;
+my $call;
+my @out;
+my $user;
+my $val = shift @args if @args;
+
+
+return (1, $self->msg('e5')) if $self->priv < 8;
+return (1, $self->msg('e14')) unless defined $val;
+return (1, $self->msg('e12')) unless @args;
+
+foreach $call (@args) {
+       $call = uc $call;
+       $user = DXUser::get_current($call);
+       if ($user) {
+               $user->maxconnect($val);
+               $user->put;
+               push @out, $self->msg('maxconnect', $call, $val);
+       } else {
+               push @out, $self->msg('e3', "set/maxconnect", $call);
+       }
+}
+return (1, @out);
index 3bc4218ce289363e458be4f28fb6e1c14a472a56..94fa3d1a9ff1549fe2659b69444fef2915c565a9 100644 (file)
@@ -89,6 +89,7 @@ $v3 = 0;
                  build => '1,Build',
                  believe => '1,Believable nodes,parray',
                  lastping => '1,Last Ping at,ptimelist',
+                 maxconnect => '1,Max Connections',
                 );
 
 #no strict;
index 38e030f0f02423ae3b8ae9449aef478c53047758..a68712c4b1a1c67317a8ac9dc23b781dc3678008 100644 (file)
@@ -205,6 +205,7 @@ package DXM;
                                m18 => 'Sorry, message $_[0] is currently set to KEEP',
                                m19 => 'Startup Script for $_[0] saved, $_[1] lines',
                                m20 => 'Empty Startup Script for $_[0] deleted',
+                               maxconnect => 'Max connections on $_[0] set to $_[1]',
                                msg1 => 'Bulletin Messages Queued',
                                msg2 => 'Private Messages Queued',
                                msg3 => 'Msg $_[0]: $_[1] changed from $_[2] to $_[3]',
index be2a961b28df1917e754386aa2eb814b5a4965b2..0bddeb20281861630f2f3e1947de92ace03bfc1e 100644 (file)
@@ -11,6 +11,6 @@ use vars qw($version $subversion $build);
 
 $version = '1.55';
 $subversion = '0';
-$build = '28';
+$build = '29';
 
 1;
index 46f4818325af00ef5945e48ac2027e58dbef3877..0bf306599d30ee09f7650f4f0ae04ca85c4170b4 100755 (executable)
@@ -187,12 +187,15 @@ sub new_channel
 
        # (fairly) politely disconnect people that are connected to too many other places at once
        my $r = Route::get($call);
-       if ($r) {
+       if ($r && $user) {
                my @n = $r->parents;
-               my $v = $r->isa('Route::Node') ? $maxconnect_node : $maxconnect_user;
+               my $m = $r->isa('Route::Node') ? $maxconnect_node : $maxconnect_user;
+               my $c = $user->maxconnect;
+               my $v;
+               $v = defined $c ? $c : $m;
                if ($v && @n >= $v) {
                        my $nodes = join ',', @n;
-                       LogDbg('DXCommand', "$call has too many connections ($v) at $nodes, disconnected");
+                       LogDbg('DXCommand', "$call has too many connections ($v) at $nodes - disconnected");
                        already_conn($conn, $call, DXM::msg($lang, 'contomany', $call, $v, $nodes));
                        return;
                }