mirror of
				https://github.com/PurpleI2P/i2pd-tools.git
				synced 2025-11-04 08:30:47 +00:00 
			
		
		
		
	Merge pull request #4 from majestrate/master
add flask app for serving router info blacklist
This commit is contained in:
		
						commit
						8d4f1ab998
					
				
					 4 changed files with 43 additions and 4 deletions
				
			
		| 
						 | 
				
			
			@ -17,7 +17,7 @@ def main():
 | 
			
		|||
 | 
			
		||||
    args = ap.parse_args()
 | 
			
		||||
    s = settings.load(args.settings)
 | 
			
		||||
    fmax = s.get("thresholds", "max_floodfills_per_ip", fallback=5)
 | 
			
		||||
    fmax = s.get("thresholds", "max_floodfills_per_ip", fallback=3)
 | 
			
		||||
    f = filter.FloodfillFilter(fmax)
 | 
			
		||||
    p = processor.BaddieProcessor([f])
 | 
			
		||||
    netdb.inspect(p.hook)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										37
									
								
								baddiefinder/baddiefinder/web.py
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										37
									
								
								baddiefinder/baddiefinder/web.py
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,37 @@
 | 
			
		|||
import flask
 | 
			
		||||
import io
 | 
			
		||||
import netdb
 | 
			
		||||
 | 
			
		||||
from . import settings
 | 
			
		||||
from . import filter
 | 
			
		||||
from . import processor
 | 
			
		||||
 | 
			
		||||
app = flask.Flask(__name__)
 | 
			
		||||
 | 
			
		||||
@app.route("/baddies.txt")
 | 
			
		||||
def baddies():
 | 
			
		||||
    s = settings.load('baddies.ini')
 | 
			
		||||
    fmax = s.get("thresholds", "max_floodfills_per_ip", fallback=3)
 | 
			
		||||
    f = filter.FloodfillFilter(fmax)
 | 
			
		||||
    p = processor.BaddieProcessor([f])
 | 
			
		||||
    path = s.get("netdb", "dir", fallback=None)
 | 
			
		||||
    if path:
 | 
			
		||||
        netdb.inspect(p.hook, path)
 | 
			
		||||
    else:
 | 
			
		||||
        netdb.inspect(p.hook)
 | 
			
		||||
    body = io.StringIO()
 | 
			
		||||
    p.write_blocklist(body)
 | 
			
		||||
    v = body.getvalue()
 | 
			
		||||
    body.close()
 | 
			
		||||
    r = flask.Response(v)
 | 
			
		||||
    r.headers["Content-Type"] = 'text/plain'
 | 
			
		||||
    return r
 | 
			
		||||
 | 
			
		||||
@app.route("/")
 | 
			
		||||
def index():
 | 
			
		||||
    return """this server serves a router info blocklist of ip addresses with unreasonably high desnity of i2p routers (right now just floodfills)
 | 
			
		||||
"""
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
if __name__ == '__main__':
 | 
			
		||||
    app.run()
 | 
			
		||||
| 
						 | 
				
			
			@ -1,2 +1,5 @@
 | 
			
		|||
[thresholds]
 | 
			
		||||
max_floodfills_per_ip = 3
 | 
			
		||||
 | 
			
		||||
#[netdb]
 | 
			
		||||
#dir=/var/lib/i2p/netdb
 | 
			
		||||
| 
						 | 
				
			
			@ -1,2 +1 @@
 | 
			
		|||
python-geoip
 | 
			
		||||
python-geoip-geolite2
 | 
			
		||||
flask
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue