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
Cédric Le Ninivin
slapos.core
Commits
2163b10a
Commit
2163b10a
authored
Jun 28, 2018
by
Guillaume Hervier
Committed by
Rafael Monnerat
Jul 05, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
portredir: Correctly format destination IPv6
parent
45468431
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
1 deletion
+21
-1
slapos/manager/portredir.py
slapos/manager/portredir.py
+6
-1
slapos/tests/slapgrid.py
slapos/tests/slapgrid.py
+15
-0
No files found.
slapos/manager/portredir.py
View file @
2163b10a
...
...
@@ -10,6 +10,11 @@ from zope import interface
logger
=
logging
.
getLogger
(
__name__
)
def
_format_ip_addr
(
ip_addr
):
if
ip_addr
.
version
==
6
:
return
'[{}]'
.
format
(
ip_addr
)
return
str
(
ip_addr
)
class
Manager
(
object
):
interface
.
implements
(
IManager
)
...
...
@@ -126,7 +131,7 @@ class Manager(object):
command
.
append
(
socat_source
)
socat_dest_type
=
'{rtype}{version}'
.
format
(
rtype
=
redir_type
.
upper
(),
version
=
dest_addr
.
version
)
socat_dest
=
'{}:{}:{}'
.
format
(
socat_dest_type
,
dest_addr
,
dest_port
)
socat_dest
=
'{}:{}:{}'
.
format
(
socat_dest_type
,
_format_ip_addr
(
dest_addr
)
,
dest_port
)
command
.
append
(
socat_dest
)
# If source port >= 1024, we don't need to run as root
...
...
slapos/tests/slapgrid.py
View file @
2163b10a
...
...
@@ -2783,6 +2783,21 @@ class TestSlapgridWithPortRedirection(MasterMixin, unittest.TestCase):
self.assertIn('socat-tcp-{}'.format(1234), partition_supervisord_config)
self.assertIn('socat TCP4-LISTEN:1234,fork TCP4:127.0.0.1:4321', partition_supervisord_config)
def test_ipv6_port_redirection(self):
with self._mock_requests():
self._setup_instance([
{
'srcPort': 1234,
'destPort': 4321,
'destAddress': '::1',
}
])
# Check the socat command
partition_supervisord_config = self._read_instance_supervisord_config()
self.assertIn('socat-tcp-{}'.format(1234), partition_supervisord_config)
self.assertIn('socat TCP4-LISTEN:1234,fork TCP6:[::1]:4321', partition_supervisord_config)
def test_udp_port_redirection(self):
with self._mock_requests():
self._setup_instance([
...
...
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