Skip to content

Commit cc9ae10

Browse files
committed
Address the following PR issues:
* Rename `_Port.error` to be `_Port.error_channel`. * Correct comment about where setsockopt is being called. * Add comments clarifying why the double call to the same methods to setup channel information. * Allow for ports specified with both local and remote port numbers.
1 parent 74d0e29 commit cc9ae10

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

stream/ws_client.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ def socket(self, port_number):
249249
raise ValueError("Invalid port number")
250250
return self.ports[port_number].socket
251251

252-
def error(self, port_number):
252+
def error_channel(self, port_number):
253253
if port_number not in self.ports:
254254
raise ValueError("Invalid port number")
255255
return self.ports[port_number].error
@@ -276,7 +276,7 @@ def __getattr__(self, name):
276276

277277
def setsockopt(self, level, optname, value):
278278
# The following socket option is not valid with a socket created from socketpair,
279-
# and is set when creating an SSLSocket from this socket.
279+
# and is set by the http.client.HTTPConnection.connect method.
280280
if level == socket.IPPROTO_TCP and optname == socket.TCP_NODELAY:
281281
return
282282
self._socket.setsockopt(level, optname, value)
@@ -288,8 +288,10 @@ def _proxy(self):
288288
python_ports = {}
289289
rlist = []
290290
for port in self.ports.values():
291+
# Setup the data channel for this port number
291292
channel_ports.append(port)
292293
channel_initialized.append(False)
294+
# Setup the error channel for this port number
293295
channel_ports.append(port)
294296
channel_initialized.append(False)
295297
python_ports[port.python] = port
@@ -455,7 +457,8 @@ def portforward_call(configuration, _method, url, **kwargs):
455457
if key == 'ports':
456458
for port in value.split(','):
457459
try:
458-
port = int(port)
460+
# The last specified port is the remote port
461+
port = int(port.split(':')[-1])
459462
if not (0 < port < 65536):
460463
raise ValueError
461464
ports.append(port)

0 commit comments

Comments
 (0)