Skip to content

Commit 406c7fb

Browse files
author
brentru
committed
use dynamic port numbers 41952-65535, randomize to prevent reuse!
1 parent 088421e commit 406c7fb

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

adafruit_wiznet5k/adafruit_wiznet5k.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
4242
* Adafruit's Bus Device library: https://github.com/adafruit/Adafruit_CircuitPython_BusDevice
4343
"""
44-
44+
from random import randint
4545
import time
4646
from micropython import const
4747

@@ -540,8 +540,8 @@ def get_socket(self, sockets):
540540
break
541541

542542
if self._src_port == 0:
543-
self._src_port = 1024
544-
543+
# Dynamic ports 49152 to 65535.
544+
self._src_port += randint(49152, 65535)
545545
if self._debug:
546546
print("Allocated socket #{}:{}".format(sock, self._src_port))
547547
return sock

0 commit comments

Comments
 (0)