Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
D
docker-py
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
docker-py
Commits
d47e5aaa
Unverified
Kaydet (Commit)
d47e5aaa
authored
Mar 25, 2019
tarafından
Ulysses Souza
Kaydeden (comit)
GitHub
Mar 25, 2019
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Sade Fark
Merge pull request #2281 from hannseman/sctp-protocol
Support for SCTP
üst
565489e2
7143cf02
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
29 additions
and
13 deletions
+29
-13
container.py
docker/api/container.py
+4
-3
containers.py
docker/models/containers.py
+2
-2
ports.py
docker/utils/ports.py
+1
-1
api_container_test.py
tests/integration/api_container_test.py
+12
-4
utils_test.py
tests/unit/utils_test.py
+10
-3
No files found.
docker/api/container.py
Dosyayı görüntüle @
d47e5aaa
...
...
@@ -915,9 +915,10 @@ class ContainerApiMixin(object):
if
'/'
in
private_port
:
return
port_settings
.
get
(
private_port
)
h_ports
=
port_settings
.
get
(
private_port
+
'/tcp'
)
if
h_ports
is
None
:
h_ports
=
port_settings
.
get
(
private_port
+
'/udp'
)
for
protocol
in
[
'tcp'
,
'udp'
,
'sctp'
]:
h_ports
=
port_settings
.
get
(
private_port
+
'/'
+
protocol
)
if
h_ports
:
break
return
h_ports
...
...
docker/models/containers.py
Dosyayı görüntüle @
d47e5aaa
...
...
@@ -650,8 +650,8 @@ class ContainerCollection(Collection):
The keys of the dictionary are the ports to bind inside the
container, either as an integer or a string in the form
``port/protocol``, where the protocol is either ``tcp``
or
``udp``.
``port/protocol``, where the protocol is either ``tcp``
,
``udp``
, or ``sctp``
.
The values of the dictionary are the corresponding ports to
open on the host, which can be either:
...
...
docker/utils/ports.py
Dosyayı görüntüle @
d47e5aaa
...
...
@@ -7,7 +7,7 @@ PORT_SPEC = re.compile(
r"(?P<ext>[\d]*)(-(?P<ext_end>[\d]+))?:"
# External range
")?"
r"(?P<int>[\d]+)(-(?P<int_end>[\d]+))?"
# Internal range
"(?P<proto>/(udp|tcp))?"
# Protocol
"(?P<proto>/(udp|tcp
|sctp
))?"
# Protocol
"$"
# Match full string
)
...
...
tests/integration/api_container_test.py
Dosyayı görüntüle @
d47e5aaa
...
...
@@ -1083,11 +1083,17 @@ class PortTest(BaseAPIIntegrationTest):
port_bindings
=
{
'1111'
:
(
'127.0.0.1'
,
'4567'
),
'2222'
:
(
'127.0.0.1'
,
'4568'
)
'2222'
:
(
'127.0.0.1'
,
'4568'
),
'3333/udp'
:
(
'127.0.0.1'
,
'4569'
),
}
ports
=
[
1111
,
2222
,
(
3333
,
'udp'
),
]
container
=
self
.
client
.
create_container
(
BUSYBOX
,
[
'sleep'
,
'60'
],
ports
=
list
(
port_bindings
.
keys
())
,
BUSYBOX
,
[
'sleep'
,
'60'
],
ports
=
ports
,
host_config
=
self
.
client
.
create_host_config
(
port_bindings
=
port_bindings
,
network_mode
=
'bridge'
)
...
...
@@ -1098,13 +1104,15 @@ class PortTest(BaseAPIIntegrationTest):
# Call the port function on each biding and compare expected vs actual
for
port
in
port_bindings
:
port
,
_
,
protocol
=
port
.
partition
(
'/'
)
actual_bindings
=
self
.
client
.
port
(
container
,
port
)
port_binding
=
actual_bindings
.
pop
()
ip
,
host_port
=
port_binding
[
'HostIp'
],
port_binding
[
'HostPort'
]
assert
ip
==
port_bindings
[
port
][
0
]
assert
host_port
==
port_bindings
[
port
][
1
]
port_binding
=
port
if
not
protocol
else
port
+
"/"
+
protocol
assert
ip
==
port_bindings
[
port_binding
][
0
]
assert
host_port
==
port_bindings
[
port_binding
][
1
]
self
.
client
.
kill
(
id
)
...
...
tests/unit/utils_test.py
Dosyayı görüntüle @
d47e5aaa
...
...
@@ -491,9 +491,12 @@ class PortsTest(unittest.TestCase):
assert
external_port
==
[(
"127.0.0.1"
,
"1000"
)]
def
test_split_port_with_protocol
(
self
):
internal_port
,
external_port
=
split_port
(
"127.0.0.1:1000:2000/udp"
)
assert
internal_port
==
[
"2000/udp"
]
assert
external_port
==
[(
"127.0.0.1"
,
"1000"
)]
for
protocol
in
[
'tcp'
,
'udp'
,
'sctp'
]:
internal_port
,
external_port
=
split_port
(
"127.0.0.1:1000:2000/"
+
protocol
)
assert
internal_port
==
[
"2000/"
+
protocol
]
assert
external_port
==
[(
"127.0.0.1"
,
"1000"
)]
def
test_split_port_with_host_ip_no_port
(
self
):
internal_port
,
external_port
=
split_port
(
"127.0.0.1::2000"
)
...
...
@@ -546,6 +549,10 @@ class PortsTest(unittest.TestCase):
with
pytest
.
raises
(
ValueError
):
split_port
(
"0.0.0.0:1000:2000:tcp"
)
def
test_split_port_invalid_protocol
(
self
):
with
pytest
.
raises
(
ValueError
):
split_port
(
"0.0.0.0:1000:2000/ftp"
)
def
test_non_matching_length_port_ranges
(
self
):
with
pytest
.
raises
(
ValueError
):
split_port
(
"0.0.0.0:1000-1010:2000-2002/tcp"
)
...
...
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