Skip to content

Commit 9fddd87

Browse files
committed
DTLS server: Only run when explicitly enabled
1 parent 7434fed commit 9fddd87

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

aiocoap/defaults.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,8 @@ def get_default_servertransports(*, loop=None, use_env=True):
8888
yield 'oscore'
8989

9090
if not dtls_missing_modules():
91-
yield 'tinydtls_server'
91+
if 'AIOCOAP_DTLSSERVER_ENABLED' in os.environ:
92+
yield 'tinydtls_server'
9293
yield 'tinydtls'
9394

9495
yield 'tcpserver'

aiocoap/transports/tinydtls_server.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,15 @@
1111
1212
Bear in mind that the aiocoap CoAPS support is highly experimental and
1313
incomplete.
14+
15+
Unlike other transports this is *not* enabled automatically in general, as it
16+
is limited to servers bound to a single address for implementation reasons.
17+
(Basically, because it is built on the simplesocketserver rather than the udp6
18+
server -- that can change in future, though). Until either the implementation
19+
is changed or binding arguments are (allowing different transports to bind to
20+
per-transport addresses or ports), a DTLS server will only be enabled if the
21+
AIOCOAP_DTLSSERVER_ENABLED environment variable is set, or tinydtls_server is
22+
listed explicitly in AIOCOAP_SERVER_TRANSPORT.
1423
"""
1524

1625
# Comparing this to the tinydtls transport, things are a bit easier as we don't

tests/common.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@
2121
import gbulb
2222
gbulb.install()
2323

24+
# All test servers are bound to loopback; if for any reason one'd want to run
25+
# with particular transports, just set them explicitly.
26+
os.environ['AIOCOAP_DTLSSERVER_ENABLED'] = '1'
27+
2428
if 'coverage' in sys.modules:
2529
PYTHON_PREFIX = [sys.executable, '-m', 'coverage', 'run', '--parallel-mode']
2630
else:

0 commit comments

Comments
 (0)