Skip to content

Instantly share code, notes, and snippets.

@c834606877
Last active September 8, 2021 15:00
Show Gist options
  • Save c834606877/2252b53e7aec150b39f55e289c71bfdb to your computer and use it in GitHub Desktop.
Save c834606877/2252b53e7aec150b39f55e289c71bfdb to your computer and use it in GitHub Desktop.
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)
@c834606877
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment