Skip to content

Commit b874f0f

Browse files
committed
Update list of unsafe ports. Closes #493
1 parent 5b21b2e commit b874f0f

File tree

1 file changed

+84
-4
lines changed

1 file changed

+84
-4
lines changed

shiny/_utils.py

Lines changed: 84 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,90 @@ def random_port(
9494
Number of times to attempt before giving up.
9595
"""
9696

97-
# fmt: off
98-
# From https://github.com/rstudio/httpuv/blob/main/R/random_port.R
99-
unsafe_ports = [1, 7, 9, 11, 13, 15, 17, 19, 20, 21, 22, 23, 25, 37, 42, 43, 53, 77, 79, 87, 95, 101, 102, 103, 104, 109, 110, 111, 113, 115, 117, 119, 123, 135, 139, 143, 179, 389, 427, 465, 512, 513, 514, 515, 526, 530, 531, 532, 540, 548, 556, 563, 587, 601, 636, 993, 995, 2049, 3659, 4045, 6000, 6665, 6666, 6667, 6668, 6669, 6697]
100-
# fmt: on
97+
# From https://chromium.googlesource.com/chromium/src.git/+/refs/heads/master/net/base/port_util.cc
98+
unsafe_ports = [
99+
1,
100+
7,
101+
9,
102+
11,
103+
13,
104+
15,
105+
17,
106+
19,
107+
20,
108+
21,
109+
22,
110+
23,
111+
25,
112+
37,
113+
42,
114+
43,
115+
53,
116+
69,
117+
77,
118+
79,
119+
87,
120+
95,
121+
101,
122+
102,
123+
103,
124+
104,
125+
109,
126+
110,
127+
111,
128+
113,
129+
115,
130+
117,
131+
119,
132+
123,
133+
135,
134+
137,
135+
139,
136+
143,
137+
161,
138+
179,
139+
389,
140+
427,
141+
465,
142+
512,
143+
513,
144+
514,
145+
515,
146+
526,
147+
530,
148+
531,
149+
532,
150+
540,
151+
548,
152+
554,
153+
556,
154+
563,
155+
587,
156+
601,
157+
636,
158+
989,
159+
990,
160+
993,
161+
995,
162+
1719,
163+
1720,
164+
1723,
165+
2049,
166+
3659,
167+
4045,
168+
5060,
169+
5061,
170+
6000,
171+
6566,
172+
6665,
173+
6666,
174+
6667,
175+
6668,
176+
6669,
177+
6697,
178+
10080,
179+
]
180+
101181
unusable = set([x for x in unsafe_ports if x >= min and x <= max])
102182
while n > 0:
103183
if (max - min + 1) <= len(unusable):

0 commit comments

Comments
 (0)