Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
sshuttle
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
pub
sshuttle
Commits
84076f29
Commit
84076f29
authored
Jan 31, 2020
by
Haw Loeung
Committed by
Brian May
Feb 03, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Handle when default chains already exists (#392)
parent
ad31ac4e
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
8 deletions
+12
-8
nft.py
sshuttle/methods/nft.py
+12
-8
No files found.
sshuttle/methods/nft.py
View file @
84076f29
import
socket
import
socket
from
sshuttle.firewall
import
subnet_weight
from
sshuttle.firewall
import
subnet_weight
from
sshuttle.helpers
import
Fatal
,
log
from
sshuttle.linux
import
nft
,
nft_get_handle
,
nonfatal
from
sshuttle.linux
import
nft
,
nft_get_handle
,
nonfatal
from
sshuttle.methods
import
BaseMethod
from
sshuttle.methods
import
BaseMethod
...
@@ -21,16 +22,19 @@ class Method(BaseMethod):
...
@@ -21,16 +22,19 @@ class Method(BaseMethod):
def
_nft
(
action
,
*
args
):
def
_nft
(
action
,
*
args
):
return
nft
(
family
,
table
,
action
,
*
args
)
return
nft
(
family
,
table
,
action
,
*
args
)
chain
=
'sshuttle-
%
s'
%
port
# basic cleanup/setup of chains
# basic cleanup/setup of chains
_nft
(
'add table'
,
''
)
_nft
(
'add table'
,
''
)
_nft
(
'add chain'
,
'prerouting'
,
# prerouting, postrouting, and output chains may already exist
'{ type nat hook prerouting priority -100; policy accept; }'
)
for
chain
in
[
'prerouting'
,
'postrouting'
,
'output'
]:
_nft
(
'add chain'
,
'postrouting'
,
rules
=
'{{ type nat hook {} priority -100; policy accept; }}'
\
'{ type nat hook postrouting priority 100; policy accept; }'
)
.
format
(
chain
)
_nft
(
'add chain'
,
'output'
,
try
:
'{ type nat hook output priority -100; policy accept; }'
)
_nft
(
'add chain'
,
chain
,
rules
)
except
Fatal
:
log
(
'Chain {} already exists, ignoring
\n
'
.
format
(
chain
))
chain
=
'sshuttle-
%
s'
%
port
_nft
(
'add chain'
,
chain
)
_nft
(
'add chain'
,
chain
)
_nft
(
'flush chain'
,
chain
)
_nft
(
'flush chain'
,
chain
)
_nft
(
'add rule'
,
'output jump
%
s'
%
chain
)
_nft
(
'add rule'
,
'output jump
%
s'
%
chain
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment