File tree Expand file tree Collapse file tree 2 files changed +23
-19
lines changed Expand file tree Collapse file tree 2 files changed +23
-19
lines changed Original file line number Diff line number Diff line change 33use  strict;
44use  warnings FATAL  =>  ' all' 
55
6- my  @ips  = ` fetch -o - https://raw.githubusercontent.com/zapret-info/z-i/master/dump.csv | sed 1d | cut -d ';' -f 1 | tr "\\ |" "\\ n" | sed 's/^[ \\ t]*//;s/[ \\ t]*\$ //' | sort | uniq` 
6+ # my @ips = `fetch -o - https://raw.githubusercontent.com/zapret-info/z-i/master/dump.csv | sed 1d | cut -d ';' -f 1 | tr "\\|" "\\n" | sed 's/^[ \\t]*//;s/[ \\t]*\$//' | sort | uniq`;
7+ my  @ips  = ` fetch -o - http://api.antizapret.info/group.php | sort | uniq` 
78
89my  $buf  = ' ' 
910my  $cnt  = 0;
1011my  $mask  = ' ' 
1112
1213foreach  $ip  (@ips ) {
13- 	if  ($mask  == ' ' 
14- 		($mask ) = ($ip  =~ / ^(\d {1,3}\.\d {1,3}\.\d {1,3}\. )/ 
15- 		$buf  = $ip ;
16- 		$cnt  = 1;
17- 	} elsif  (starts_with($ip , $mask )) {
18- 		$buf  .= $ip ;
19- 		$cnt ++;
20- 	} elsif  ($cnt  >= 10) {
21- 		print  $mask ." 0/24\n " 
22- 		$buf  = $mask  = ' ' 
23- 		$cnt  = 0;
24- 	} else  {
25- 		print  $buf ;
26- 		$buf  = $mask  = ' ' 
27- 		$cnt  = 0;
28- 	}
14+     if  ($mask  == ' ' 
15+         ($mask ) = ($ip  =~ / ^(\d {1,3}\.\d {1,3}\.\d {1,3}\. )/ 
16+         $buf  = $ip ;
17+         $cnt  = 1;
18+     }
19+     elsif  (starts_with($ip , $mask )) {
20+         $buf  .= $ip ;
21+         $cnt ++;
22+     }
23+     else  {
24+         if  ($cnt  >= 10) {
25+             print  $mask  . " 0/24\n " 
26+         }
27+         else  {
28+             print  $buf ;
29+         }
30+         ($mask ) = ($ip  =~ / ^(\d {1,3}\.\d {1,3}\.\d {1,3}\. )/ 
31+         $buf  = $ip ;
32+         $cnt  = 1;
33+     }
2934}
3035
3136
3237
33- sub  starts_with 
34- {
38+ sub  starts_with  {
3539    return  substr ($_ [0], 0, length ($_ [1])) eq  $_ [1];
3640}
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments