File: unknown_hostname

package info (click to toggle)
usemod-wiki 1.2.2-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 896 kB
  • sloc: perl: 4,991; sh: 27; makefile: 16
file content (26 lines) | stat: -rw-r--r-- 1,179 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
--- a/wiki.pl
+++ b/wiki.pl
@@ -2771,6 +2771,11 @@ sub UserIsBanned {
   $host = &GetRemoteHost(0);
   foreach (split(/\n/, $data)) {
     next  if ((/^\s*$/) || (/^#/));  # Skip empty, spaces, or comments
+    if ($_ eq "unknown") { return 1 if ($host =~ /^[\d.]+$/); next; } # Ban unknown hosts
+    if ($_ eq "unknown+unregistered") { # Check whether the user is registered
+      return 1 if ($host =~ /^[\d.]+$/ and &GetParam('username','') eq '');
+      next;
+    }
     return 1  if ($ip   =~ /$_/i);
     return 1  if ($host =~ /$_/i);
   }
@@ -4530,7 +4535,10 @@ sub DoEditBanned {
         "<tt># blocks exact IP address</tt><br>",
         "<tt>^123\\.21\\.3\\.9\$</tt><br>",
         "<tt># blocks whole 123.21.3.* IP network</tt><br>",
-        "<tt>^123\\.21\\.3\\.\\d+\$</tt><p>";
+        "<tt>^123\\.21\\.3\\.\\d+\$</tt><br>",
+        "<tt># the special token 'unknown' blocks all unresolvable addresses</tt><br>",
+        "<tt># using 'unknown+unregistered' blocks unregistered users only</tt><br>",
+        "<tt>unknown</tt><p>";
   print &GetTextArea('banlist', $banList, 12, 50);
   print "<br>", $q->submit(-name=>'Save'), "\n";
   print $q->end_form;