Skip to content

Commit 69ae478

Browse files
committed
升级
1 parent 5701e02 commit 69ae478

File tree

13 files changed

+71
-35
lines changed

13 files changed

+71
-35
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ firewall
44
Install
55
-------
66
# cd /usr/local/src/
7-
# yum install -y git python39
7+
# yum install -y git python39
88
# git clone https://github.com/netkiller/firewall.git
99
# cd firewall
1010
# bash install.sh

example/cisco.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/usr/bin/env python3
2+
# -*- coding: utf-8 -*-
3+
########################################
4+
# Cisco ASA Style
5+
########################################
6+
from netkiller.firewall import Firewall
7+
gateway = Firewall()
8+
gateway.inside().accept()
9+
gateway.inside().state(('RELATED','ESTABLISHED')).accept('# match test')
10+
gateway.outside().drop()
11+
gateway.show()

example/example.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
#
2323
#
2424

25-
from firewall import *
25+
from netkiller.firewall import *
2626

2727
def main():
2828
########################################

example/juniper.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/usr/bin/env python3
2+
# -*- coding: utf-8 -*-
3+
########################################
4+
# Juniper JunOS Style
5+
########################################
6+
from netkiller.firewall import Firewall
7+
gateway = Firewall()
8+
gateway.trust().accept()
9+
gateway.untrust().drop()
10+
gateway.input().protocol('icmp').drop()
11+
gateway.input().protocol('tcp').dport(('3389','5900')).accept()
12+
gateway.show()

example/pppoe.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/usr/bin/env python3
2+
# -*- coding: utf-8 -*-
3+
########################################
4+
# Linux Gateway via pppoe
5+
########################################
6+
from netkiller.firewall import Firewall
7+
gateway = Firewall()
8+
gateway.input().drop()
9+
gateway.output().accept()
10+
gateway.inside().state(('RELATED','ESTABLISHED')).accept('# match test')
11+
gateway.forward().destination('127.16.0.0/24').accept()
12+
gateway.chain('POSTROUTING').inbound("ppp0").source('172.16.0.0/24').masquerade()
13+
gateway.show()

example/test.py

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
#!/usr/bin/env python3
22
# -*- coding: utf-8 -*-
3-
4-
from firewall import Firewall
5-
6-
single = Firewall()
7-
single.policy(single.INPUT,single.DROP)
8-
single.policy(single.OUTPUT,single.ACCEPT)
9-
single.policy(single.FORWARD,single.DROP)
10-
single.input().protocol('icmp').drop()
11-
single.input().protocol('tcp').dport(('3389','5900')).accept()
12-
single.input().protocol('tcp').dport(('137','138','139','145')).accept()
13-
single.show()
14-
#single.run()
15-
#single.list()
3+
from netkiller.firewall import Firewall
4+
test = Firewall()
5+
test.flush()
6+
test.policy(test.INPUT,test.DROP)
7+
test.policy(test.OUTPUT,test.ACCEPT)
8+
test.policy(test.FORWARD,test.DROP)
9+
test.input().protocol('icmp').drop()
10+
test.input().protocol('tcp').dport(('3389','5900')).accept()
11+
test.input().protocol('tcp').dport(('137','138','139','145')).accept()
12+
test.show()
13+
#test.run()
14+
#test.list()

install.sh

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
11
rm -rf /srv/firewall/
2+
3+
dnf remove -y firewalld
4+
dnf install -y iptables
5+
6+
python3 setup.py sdist
7+
python3 setup.py install
8+
29
install -dv /srv/firewall/{sbin,libexec}
310
install -D -m 0700 -o root sbin/firewall /srv/firewall/sbin/
411
install -D -m 0700 -o root libexec/*.py /srv/firewall/libexec/
@@ -8,10 +15,4 @@ install -D -m 0700 -o root systemd/firewall.service /usr/lib/systemd/system/
815
install -D -m 0700 -o root systemd/firewall /etc/sysconfig/
916

1017
systemctl enable firewall
11-
systemctl start firewall
12-
13-
cd firewall/
14-
python3 setup.py sdist
15-
python3 setup.py install
16-
cd -
17-
18+
systemctl start firewall

libexec/db.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
#
2323
#
2424

25-
from firewall import *
25+
from netkiller.firewall import *
2626

2727
########################################
2828
# PostgreSQL Firewall

libexec/smtp.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
#
2323
#
2424

25-
from firewall import *
25+
from netkiller.firewall import *
2626

2727
########################################
2828
# Web Application

libexec/www.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
#
2323
#
2424

25-
from firewall import *
25+
from netkiller.firewall import *
2626

2727
########################################
2828
# Web Application
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
name = "netkiller-firewall"
22
__version__ = "0.0.1"
3-
# __author__ = 'Neo Chen'
3+
__author__ = 'Neo Chen'
File renamed without changes.

setup.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
import setuptools
2-
# from firewall import __version__, __author__
2+
from netkiller import __version__, name, __author__
33

44
with open("README.md", "r") as fh:
55
long_description = fh.read()
66

77
setuptools.setup(
8-
name="netkiller-firewall",
9-
version="0.0.1",
10-
author="Neo Chen",
8+
name=name,
9+
version=__version__,
10+
author=__author__,
1111
author_email="[email protected]",
12-
description="Python firewall(iptables)",
12+
description="Netkiller Python firewall",
1313
long_description=long_description,
1414
long_description_content_type="text/markdown",
1515
url="https://github.com/netkiller/firewall",
16-
license='BSD',
16+
license='MIT',
1717
# py_modules = ['firewall'],
18-
# packages=setuptools.find_packages(),
19-
packages=[''],
18+
packages=setuptools.find_packages(),
19+
# packages=[''],
2020
# packages=setuptools.find_packages('packages'),
21-
# package_dir = {'':'packages'},
21+
# package_dir = {'':'package'},
2222
classifiers=[
2323
"Programming Language :: Python :: 3",
2424
"License :: OSI Approved :: MIT License",

0 commit comments

Comments
 (0)