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
9a7412c0
Commit
9a7412c0
authored
Jul 11, 2011
by
Brian May
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
More changes to simplify the upcomming IPv6 patch.
parent
c6200eec
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
21 deletions
+25
-21
client.py
client.py
+3
-5
main.py
main.py
+22
-16
No files found.
client.py
View file @
9a7412c0
...
@@ -125,16 +125,14 @@ class MultiListener:
...
@@ -125,16 +125,14 @@ class MultiListener:
class
FirewallClient
:
class
FirewallClient
:
def
__init__
(
self
,
port
,
subnets_include
,
subnets_exclude
,
dnsport
,
method
):
def
__init__
(
self
,
port_v4
,
subnets_include
,
subnets_exclude
,
dnsport_v4
,
method
):
self
.
port
=
port
self
.
auto_nets
=
[]
self
.
auto_nets
=
[]
self
.
subnets_include
=
subnets_include
self
.
subnets_include
=
subnets_include
self
.
subnets_exclude
=
subnets_exclude
self
.
subnets_exclude
=
subnets_exclude
self
.
dnsport
=
dnsport
argvbase
=
([
sys
.
argv
[
1
],
sys
.
argv
[
0
],
sys
.
argv
[
1
]]
+
argvbase
=
([
sys
.
argv
[
1
],
sys
.
argv
[
0
],
sys
.
argv
[
1
]]
+
[
'-v'
]
*
(
helpers
.
verbose
or
0
)
+
[
'-v'
]
*
(
helpers
.
verbose
or
0
)
+
[
'--firewall'
,
str
(
port
),
[
'--firewall'
,
str
(
port
_v4
),
str
(
dnsport
),
str
(
dnsport
_v4
),
method
])
method
])
if
ssyslog
.
_p
:
if
ssyslog
.
_p
:
argvbase
+=
[
'--syslog'
]
argvbase
+=
[
'--syslog'
]
...
...
main.py
View file @
9a7412c0
...
@@ -4,30 +4,36 @@ import compat.ssubprocess as ssubprocess
...
@@ -4,30 +4,36 @@ import compat.ssubprocess as ssubprocess
from
helpers
import
*
from
helpers
import
*
# 1.2.3.4/5 or just 1.2.3.4
def
parse_subnet4
(
s
):
m
=
re
.
match
(
r'(\d+)(?:\.(\d+)\.(\d+)\.(\d+))?(?:/(\d+))?$'
,
s
)
if
not
m
:
raise
Fatal
(
'
%
r is not a valid IP subnet format'
%
s
)
(
a
,
b
,
c
,
d
,
width
)
=
m
.
groups
()
(
a
,
b
,
c
,
d
)
=
(
int
(
a
or
0
),
int
(
b
or
0
),
int
(
c
or
0
),
int
(
d
or
0
))
if
width
==
None
:
width
=
32
else
:
width
=
int
(
width
)
if
a
>
255
or
b
>
255
or
c
>
255
or
d
>
255
:
raise
Fatal
(
'
%
d.
%
d.
%
d.
%
d has numbers > 255'
%
(
a
,
b
,
c
,
d
))
if
width
>
32
:
raise
Fatal
(
'*/
%
d is greater than the maximum of 32'
%
width
)
return
(
socket
.
AF_INET
,
'
%
d.
%
d.
%
d.
%
d'
%
(
a
,
b
,
c
,
d
),
width
)
# list of:
# list of:
# 1.2.3.4/5 or just 1.2.3.4
# 1.2.3.4/5 or just 1.2.3.4
def
parse_subnets
(
subnets_str
):
def
parse_subnets
(
subnets_str
):
subnets
=
[]
subnets
=
[]
for
s
in
subnets_str
:
for
s
in
subnets_str
:
m
=
re
.
match
(
r'(\d+)(?:\.(\d+)\.(\d+)\.(\d+))?(?:/(\d+))?$'
,
s
)
subnet
=
parse_subnet4
(
s
)
if
not
m
:
subnets
.
append
(
subnet
)
raise
Fatal
(
'
%
r is not a valid IP subnet format'
%
s
)
(
a
,
b
,
c
,
d
,
width
)
=
m
.
groups
()
(
a
,
b
,
c
,
d
)
=
(
int
(
a
or
0
),
int
(
b
or
0
),
int
(
c
or
0
),
int
(
d
or
0
))
if
width
==
None
:
width
=
32
else
:
width
=
int
(
width
)
if
a
>
255
or
b
>
255
or
c
>
255
or
d
>
255
:
raise
Fatal
(
'
%
d.
%
d.
%
d.
%
d has numbers > 255'
%
(
a
,
b
,
c
,
d
))
if
width
>
32
:
raise
Fatal
(
'*/
%
d is greater than the maximum of 32'
%
width
)
subnets
.
append
((
socket
.
AF_INET
,
'
%
d.
%
d.
%
d.
%
d'
%
(
a
,
b
,
c
,
d
),
width
))
return
subnets
return
subnets
# 1.2.3.4:567 or just 1.2.3.4 or just 567
# 1.2.3.4:567 or just 1.2.3.4 or just 567
def
parse_ipport
(
s
):
def
parse_ipport
4
(
s
):
s
=
str
(
s
)
s
=
str
(
s
)
m
=
re
.
match
(
r'(?:(\d+)\.(\d+)\.(\d+)\.(\d+))?(?::)?(?:(\d+))?$'
,
s
)
m
=
re
.
match
(
r'(?:(\d+)\.(\d+)\.(\d+)\.(\d+))?(?::)?(?:(\d+))?$'
,
s
)
if
not
m
:
if
not
m
:
...
@@ -118,7 +124,7 @@ try:
...
@@ -118,7 +124,7 @@ try:
method
=
opt
.
method
method
=
opt
.
method
else
:
else
:
o
.
fatal
(
"method
%
s not supported"
%
opt
.
method
)
o
.
fatal
(
"method
%
s not supported"
%
opt
.
method
)
ipport_v4
=
parse_ipport
(
opt
.
listen
or
'0.0.0.0:0'
)
ipport_v4
=
parse_ipport
4
(
opt
.
listen
or
'0.0.0.0:0'
)
sys
.
exit
(
client
.
main
(
ipport_v4
,
sys
.
exit
(
client
.
main
(
ipport_v4
,
opt
.
ssh_cmd
,
opt
.
ssh_cmd
,
remotename
,
remotename
,
...
...
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