Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed an issue using public commands where ripecheck did not alert ni…

…ck/channel when something went wrong
  • Loading branch information...
commit f2ebf5f6366bdf4a33160a1228ddc02205b01a38 1 parent 6bb3360
Stefan Wold authored June 03, 2009

Showing 2 changed files with 21 additions and 4 deletions. Show diff stats Hide diff stats

  1. 2  ChangeLog
  2. 23  ripecheck.tcl
2  ChangeLog
... ...
@@ -1,4 +1,6 @@
1 1
 ChangeLog:
  2
+3.0.1:	- Fixed an issue using public commands where ripecheck did not alert nick/channel when something went wrong.
  3
+
2 4
 3.0:    - Ripecheck is now using the namespace ::ripecheck
3 5
 	- Fixed duplicate entry in iplist.txt
4 6
 	- Fixed minor issue with .ripesettings
23  ripecheck.tcl
... ...
@@ -1,5 +1,5 @@
1 1
 #
2  
-# ripecheck.tcl  Version: 3.0  Author: Stefan Wold <ratler@stderr.eu>
  2
+# ripecheck.tcl  Version: 3.0.1  Author: Stefan Wold <ratler@stderr.eu>
3 3
 ###
4 4
 # Info:
5 5
 # This script check unresolved ip addresses against a RIPE database
@@ -160,7 +160,7 @@ bind msg -|- !ripeinfo ::ripecheck::msgRipeInfo
160 160
 
161 161
 namespace eval ::ripecheck {
162 162
     # Global variables
163  
-    variable version "3.0"
  163
+    variable version "3.0.1"
164 164
 
165 165
     variable maskarray
166 166
     variable chanarr
@@ -273,6 +273,15 @@ namespace eval ::ripecheck {
273 273
         }
274 274
     }
275 275
 
  276
+    proc notifySender { nick channel rtype msg } {
  277
+        putloglev $::ripecheck::conflag * "ripecheck: DEBUG: Entering notifySender()"
  278
+        if {$rtype == "pubRipeCheck"} {
  279
+            puthelp "PRIVMSG $channel :ripecheck: $msg"
  280
+        } elseif {$rtype == "pubRipeInfo"} {
  281
+            puthelp "NOTICE $nick :ripecheck: $msg"
  282
+        }
  283
+    }
  284
+
276 285
     proc ripecheck { ip host nick channel orghost ripe } {
277 286
         putloglev $::ripecheck::conflag * "ripecheck: DEBUG - Entering ripecheck()"
278 287
         set bantime [channel get $channel ripecheck.bantime]
@@ -348,7 +357,7 @@ namespace eval ::ripecheck {
348 357
         if {[regexp {[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}$} $ip]} {
349 358
             set iptype [::ip::type $ip]
350 359
             if {$iptype != "normal"} {
351  
-                puthelp "PRIVMSG $channel :ripecheck: Sorry but '$ip' is from a '$iptype' range"
  360
+                ::ripecheck::notifySender $nick $channel $rtype "Sorry but '$ip' is from a '$iptype' range"
352 361
             } else {
353 362
                 ::ripecheck::whoisFindServer $ip $ip "" $nick $channel "" $rtype
354 363
             }
@@ -376,6 +385,7 @@ namespace eval ::ripecheck {
376 385
     # Lookup which whois server to query and call whois_connect
377 386
     proc whoisFindServer { ip host status nick channel orghost rtype } {
378 387
         if {$status == 0} {
  388
+            ::ripecheck::notifySender $nick $channel $rtype "Failed to resolve '$host'!"
379 389
             putlog "ripecheck: Couldn't resolve '$host'. No further action taken."
380 390
             return 0
381 391
         }
@@ -394,6 +404,7 @@ namespace eval ::ripecheck {
394 404
         putloglev $::ripecheck::conflag * "ripecheck: DEBUG - Matching mask $matchmask using whois DB: $whoisdb"
395 405
 
396 406
         if {$whoisdb == "unallocated"} {
  407
+            ::ripecheck::notifySender $nick $channel $rtype "Unallocated netmask!"
397 408
             putlog "ripecheck: Unallocated netmask, bailing out!"
398 409
             return -1
399 410
         }
@@ -406,12 +417,14 @@ namespace eval ::ripecheck {
406 417
         after $::ripecheck::rtimeout * 1000 set ::ripecheck::constate "timeout"
407 418
 
408 419
         if {[catch {socket -async $whoisdb $whoisport} sock]} {
  420
+            ::ripecheck::notifySender $nick $channel $rtype "ERROR: Failed to connect to '$whoisdb'!"
409 421
             putlog "ripecheck: ERROR: Failed to connect to server $whoisdb!" ; return -1
410 422
         }
411 423
         fconfigure $sock -buffering line
412 424
         fileevent $sock writable [list ::ripecheck::whoisCallback $ip $host $nick $channel $orghost $sock $whoisdb $rtype]
413 425
         vwait ::ripecheck::constate
414 426
         if { $::ripecheck::constate == "timeout" } {
  427
+            ::ripecheck::notifySender $nick $channel $rtype "ERROR: Connection timeout using '$whoisdb'!"
415 428
             putlog "ripecheck: ERROR: Connection timeout against $whoisdb"; return -1
416 429
         }
417 430
     }
@@ -494,7 +507,7 @@ namespace eval ::ripecheck {
494 507
                         ::ripecheck::testripecheck $ip $host $channel $whoisdata(country)
495 508
                     }
496 509
                     pubRipeCheck {
497  
-                        puthelp "PRIVMSG $channel :ripecheck: $host is located in '$whoisdata(country)'"
  510
+                        ::ripecheck::notifySender $nick $channel $rtype "$host is located in '$whoisdata(country)'"
498 511
                     }
499 512
                     pubRipeInfo {
500 513
                         putloglev $::ripecheck::conflag * "ripecheck: DEBUG - switch $rtype"
@@ -505,6 +518,8 @@ namespace eval ::ripecheck {
505 518
                     }
506 519
                 }
507 520
             } else {
  521
+                # Respond that something went wrong
  522
+                ::ripecheck::notifySender $nick $channel $rtype "Whois query failed for '$host'!"
508 523
                 putlog "ripecheck: No country found for '$ip'. No further action taken. (Possible bug?)"
509 524
             }
510 525
         } else {

0 notes on commit f2ebf5f

Please sign in to comment.
Something went wrong with that request. Please try again.