Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Ophélie Gagnard
slapos.core
Commits
6ba97a5c
Commit
6ba97a5c
authored
Jun 18, 2018
by
Guillaume Hervier
Committed by
Rafael Monnerat
Jul 05, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
portredir: Add support for UDP redirection
parent
b33a7cbf
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
3 deletions
+7
-3
slapos/manager/portredir.py
slapos/manager/portredir.py
+7
-3
No files found.
slapos/manager/portredir.py
View file @
6ba97a5c
...
@@ -78,6 +78,8 @@ class Manager(object):
...
@@ -78,6 +78,8 @@ class Manager(object):
# Generate socat commands to run with supervisord
# Generate socat commands to run with supervisord
socat_programs
=
[]
socat_programs
=
[]
for
port_redirect
in
port_redirects
:
for
port_redirect
in
port_redirects
:
redir_type
=
port_redirect
.
get
(
'type'
,
'tcp'
)
source_port
=
port_redirect
[
'srcPort'
]
source_port
=
port_redirect
[
'srcPort'
]
source_addr
=
port_redirect
.
get
(
'srcAddress'
)
source_addr
=
port_redirect
.
get
(
'srcAddress'
)
...
@@ -92,14 +94,16 @@ class Manager(object):
...
@@ -92,14 +94,16 @@ class Manager(object):
command
=
[
'socat'
]
command
=
[
'socat'
]
socat_source_type
=
'TCP4-LISTEN'
if
source_is_ipv4
else
'TCP6-LISTEN'
socat_source_version
=
4
if
source_is_ipv4
else
6
socat_source_type
=
'{rtype}{version}-LISTEN'
.
format
(
rtype
=
redir_type
.
upper
(),
version
=
socat_source_version
)
socat_source
=
'{}:{}'
.
format
(
socat_source_type
,
source_port
)
socat_source
=
'{}:{}'
.
format
(
socat_source_type
,
source_port
)
if
source_addr
is
not
None
:
if
source_addr
is
not
None
:
socat_source
+=
',bind={}'
.
format
(
source_addr
)
socat_source
+=
',bind={}'
.
format
(
source_addr
)
socat_source
+=
',fork'
socat_source
+=
',fork'
command
.
append
(
socat_source
)
command
.
append
(
socat_source
)
socat_dest_type
=
'TCP6'
if
dest_is_ipv6
else
'TCP4'
socat_dest_version
=
6
if
dest_is_ipv6
else
4
socat_dest_type
=
'{rtype}{version}'
.
format
(
rtype
=
redir_type
.
upper
(),
version
=
socat_dest_version
)
socat_dest
=
'{}:{}:{}'
.
format
(
socat_dest_type
,
dest_addr
,
dest_port
)
socat_dest
=
'{}:{}:{}'
.
format
(
socat_dest_type
,
dest_addr
,
dest_port
)
command
.
append
(
socat_dest
)
command
.
append
(
socat_dest
)
...
@@ -109,7 +113,7 @@ class Manager(object):
...
@@ -109,7 +113,7 @@ class Manager(object):
socat_programs
.
append
({
socat_programs
.
append
({
'as_user'
:
as_user
,
'as_user'
:
as_user
,
'command'
:
' '
.
join
(
command
),
'command'
:
' '
.
join
(
command
),
'name'
:
'socat-{}
'
.
format
(
source_port
),
'name'
:
'socat-{}
-{}'
.
format
(
redir_type
.
lower
(),
source_port
),
})
})
# Generate supervisord configuration with socat processes added
# Generate supervisord configuration with socat processes added
...
...
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