Last active
September 8, 2021 15:00
-
-
Save c834606877/2252b53e7aec150b39f55e289c71bfdb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from werkzeug.wrappers import Request, Response | |
import subprocess | |
@Request.application | |
def application(request): | |
iplist = ",".join(request.access_route) | |
for ipaddr in request.access_route: | |
ipaddr = ''.join(i for i in ipaddr if i in '0123456789.') | |
cmd = ["firewall-cmd","--zone=sszone","--add-source="+ipaddr+"/32"] | |
subprocess.check_call(cmd) | |
return Response("<h1>Your IP:" + iplist + " will be record!<h1>") | |
if __name__ == "__main__": | |
from werkzeug.serving import run_simple | |
run_simple("0.0.0.0", 8000, application, threaded=True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
firewall-cmd --add-port=8000 --permanent # for self port
firewall-cmd --new-zone=sszone --permanent
firewall-cmd --zone=sszone --add-port=8080/tcp
firewall-cmd --zone=sszone --add-port=8080/tcp --permanent # for target port
firewall-cmd --list-all --zone=sszone