-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfirewall.py
38 lines (30 loc) · 1.1 KB
/
firewall.py
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
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
import argparse
import logging
from common.logger import logger
from firewall.handler import HTTP
def main():
parser = argparse.ArgumentParser(
description='Simple Python Application Firewall',
epilog='Simple Python Application Firewall'
)
parser.add_argument('--webhost', default='127.0.0.1',
help='Default: 127.0.0.1')
parser.add_argument('--webport', default='80', help='Default: 80')
parser.add_argument('--srvhost', default='127.0.0.1',
help='Default: 127.0.0.1')
parser.add_argument('--srvport', default='8083', help='Default: 8083')
parser.add_argument('--log-level', default='INFO',
help='DEBUG, INFO, WARNING, ERROR, CRITICAL')
args = parser.parse_args()
logger.setLevel(getattr(logging, args.log_level))
webhost = args.webhost
webport = int(args.webport)
srvhost = args.srvhost
srvport = int(args.srvport)
proxy = HTTP(srvhost, srvport, webhost, webport)
proxy.run()
if __name__ == '__main__':
main()