]> jfr.im git - irc/SurrealServices/srsv.git/commitdiff
merge r3567 to 0.5.0: work-around broken Math::BigInt
authortabris <redacted>
Thu, 8 Sep 2011 05:58:52 +0000 (05:58 +0000)
committertabris <redacted>
Thu, 8 Sep 2011 05:58:52 +0000 (05:58 +0000)
git-svn-id: http://svn.tabris.net/repos/srsv@3568 70d4eda1-72e9-0310-a436-91e5bd24443c

branches/0.5.0/SrSv/ChanReg/Flags.pm
branches/0.5.0/SrSv/IPv6.pm
branches/0.5.0/SrSv/Unreal/Base64.pm
branches/0.5.0/help/chanserv/set.txt
branches/0.5.0/help/chanserv/set/noclones.txt [new file with mode: 0644]
branches/0.5.0/modules/serviceslibs/chanserv.pm

index fbc331b30d0a474e785cbda14930096f39c02534..e42bfbfdbf48d85dcbcd40578a63b9961fad8dc2 100644 (file)
@@ -42,6 +42,7 @@ BEGIN {
                CRF_AUTOVOICE => 1024,
                CRF_WELCOMEINCHAN => 2048,
                CRF_NEVEROP => 4096,
+               CRF_NOCLONES => 8192,
        );
 
        our @EXPORT = (qw(cr_chk_flag cr_set_flag), keys(%constants));
index 90f41ecc4160c5672040a933a595160c12297ae2..741c42380d96fcf3edc7129ec3297b8ab42ff9d0 100644 (file)
@@ -10,8 +10,15 @@ BEGIN {
                require Socket; import Socket;
                require Socket6; import Socket6;
                if(!HAS_64BIT_INT) {
-                       require Math::BigInt;
-                       import Math::BigInt try => 'GMP';
+                       eval {
+                               require Math::BigInt;
+                               import Math::BigInt try => 'GMP';
+                       };
+                       if($@) {
+                               print STDERR "Running old version of perl/Math::BigInt.\n", $@, "Trying again.\n";
+                               require Math::BigInt;
+                               import Math::BigInt;
+                       }
                }
                push @EXPORT, qw( AF_INET6 );
        }
index 79410787eacf66fdb337e6553aeaec2b60089a58..871cea3d2f30ef060e855b27893a4f275dd1e613 100644 (file)
@@ -26,8 +26,15 @@ use strict;
 use SrSv::64bit;
 BEGIN {
        if(!HAS_64BIT_INT) {
-               require Math::BigInt;
-               import Math::BigInt try => 'GMP';
+               eval {
+                       require Math::BigInt;
+                       import Math::BigInt try => 'GMP';
+               };
+               if($@) {
+                       print STDERR "Running old version of perl/Math::BigInt.\n", $@, "Trying again.\n";
+                       require Math::BigInt;
+                       import Math::BigInt;
+               }
        }
 }
 
index 5a424df98ed8f728c3a59c0673a971150117da91..480a668209f4ddfd4ede08bce92e40a1d907caeb 100644 (file)
@@ -17,7 +17,7 @@ Settings:
   AUTOVOICE      Voices everyone who joins the channel.
   BANTYPE        Selects the ban-type to be used for KICKBAN and AKICKs
   TOPICLOCK      Restricts who can change the topic in the channel.
-
+  NOCLONES       Bans people who bring clones into the channel.
 Oper only flags:
   HOLD         Prevent channel from expiring
   FREEZE       Suspend access in this channel
diff --git a/branches/0.5.0/help/chanserv/set/noclones.txt b/branches/0.5.0/help/chanserv/set/noclones.txt
new file mode 100644 (file)
index 0000000..0a75743
--- /dev/null
@@ -0,0 +1,4 @@
+%BChanServ SET NOCLONES%B Kicks and bans users who bring clones (multiple connections) to a channel.
+Users in the channel's access lists are excempt.
+Syntax: %BSET%B %U#channel%U %BNOCLONES%B <%UON/OFF%U>
index 9be96d01ef03a30f4b616f98d6d1f4630cd00911..6dcee5893a93f0f1b15ffac8984c63d0a157214e 100644 (file)
@@ -149,7 +149,7 @@ our ($cur_lock, $cnt_lock);
 our (
        $get_joinpart_lock, $get_modelock_lock, $get_update_modes_lock,
        
-       $chanjoin, $chanpart, $chop, $chdeop, $get_op, $get_user_chans, $get_user_chans_recent,
+       $chanjoin, $chanpart, $chanpart2, $chop, $chdeop, $get_op, $get_user_chans, $get_user_chans_recent,
        $get_all_closed_chans, $get_user_count,
 
        $is_in_chan,
@@ -213,6 +213,8 @@ our (
        $set_bantype, $get_bantype,
 
        $drop_chantext, $drop_nicktext,
+       $get_host,
+       $get_host_inchan,
 );
 
 sub init() {
@@ -225,6 +227,7 @@ sub init() {
        $chanjoin = $dbh->prepare("REPLACE INTO chanuser (seq,nickid,chan,op,joined) VALUES (?, ?, ?, ?, 1)");
        $chanpart = $dbh->prepare("UPDATE chanuser SET joined=0, seq=?
                WHERE nickid=? AND chan=? AND (seq <= ? OR seq > ?)");
+       $chanpart2 = $dbh->prepare("UPDATE chanuser SET joined=0 WHERE nickid=? AND chan=?");
        #$chop = $dbh->prepare("UPDATE chanuser SET op=op+? WHERE nickid=? AND chan=?");
        $chop = $dbh->prepare("UPDATE chanuser SET op=IF(op & ?, op, op ^ ?) WHERE nickid=? AND chan=?");
        $chdeop = $dbh->prepare("UPDATE chanuser SET op=IF(op & ?, op ^ ?, op) WHERE nickid=? AND chan=?");
@@ -514,6 +517,8 @@ sub init() {
 
        $drop_chantext = $dbh->prepare("DELETE FROM chantext WHERE chan=?");
        $drop_nicktext = $dbh->prepare("DELETE nicktext.* FROM nicktext WHERE nicktext.chan=?");
+       $get_host = $dbh->prepare ("SELECT user.host from user where user.nick=?");
+       $get_host_inchan = $dbh->prepare ("select user.nick from user  left join chanuser on (user.id=chanuser.nickid) where user.host=? and chanuser.joined=1 and chanuser.chan=? and user.nick<>?");
 }
 
 use SrSv::MySQL::Stub {
@@ -541,6 +546,22 @@ our %high_priority_cmds = (
        down => 1,
 );
 
+sub clones_exist ($$) {
+       my ($user, $chan) = @_;
+       my $cn = $chan->{CHAN};
+       unless(cr_chk_flag($chan, CRF_NOCLONES)) {
+               return;
+       }
+       my $nick = $user->{NICK};
+       $get_host->execute($nick);
+       my ($host) = $get_host->fetchrow_array;
+       $get_host_inchan -> execute ($host,$cn,$nick);
+       my ($joined) = $get_host_inchan->fetchrow_array;
+       if ($joined) {
+               return $joined;
+       }
+       return 0;
+}
 sub dispatch($$$) {
        our $csUser = { NICK => $csnick, ID => ircd::getAgentUuid($csnick) };
        my ($user, $dstUser, $msg) = @_;
@@ -1762,6 +1783,7 @@ sub cs_set_pre($$$$) {
 
                'autovoice' => 1, 'avoice' => 1,
                'neverop' => 1, 'noop' => 1,
+               'noclones' => 1,
        );
        my %override_set = (
                'hold' => 'SERVOP', 'noexpire' => 'SERVOP', 'no-expire' => 'SERVOP',
@@ -1937,7 +1959,20 @@ sub cs_set($$$;$) {
                notice($user, "Please say \002on\002 or \002off\002.");
                return;
        }
-       
+       if ($set =~ /^(?:noclones)$/i) {
+               cr_set_flag($chan, CRF_NOCLONES, $val);
+               if($val) {
+                       notice($user,
+                               "Noclones is now \002ON\002.",
+                               "Clones will be kicked out of \002$cn\002."
+                       );
+               } else {
+                       notice($user,
+                               "Noclones is now \002OFF\002.",
+                               "People are allowed to bring clones in \002$cn\002."
+                       );
+               }
+       }
        if($set =~ /^(?:opguard|secureops)$/i) {
                cr_set_flag($chan, CRF_OPGUARD, $val);
 
@@ -3730,7 +3765,14 @@ sub do_status($$;$) {
                return 0;
        }
        my ($acc, $root) = get_best_acc($user, $chan, 2);
-       if(!can_do($chan, 'JOIN', $user, { ACC => $acc, NOREPLY => 1 })) {
+       my ($accnick, $override) = can_do($chan, 'JOIN', $user, { ACC => $acc, NOREPLY => 1 });
+       unless ($acc > 0 || $override) {
+               if (clones_exist ($user, $chan)) {
+                       kickban($chan, $user, undef, 'No clones allowed in this channel.')
+               }
+       }
+       
+       if(!$accnick && !$override) {
                if (!is_agent ($user->{NICK})) {
                        kickban($chan, $user, undef, 'This is a private channel.')
                                unless $check_only;
@@ -4653,6 +4695,7 @@ sub user_join_multi($$) {
                        get_user_nick ($user); # INSP
                }
                $user->{__ID} = get_user_id($user);
+               
                unless (defined($user->{__ID})) {
                        # This does happen occasionally. it's a BUG.
                        # At least we have a diagnostic for it now.