Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed externalPort assignment when not set #1378

Merged
merged 3 commits into from May 12, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 2 additions & 15 deletions autobahn/websocket/protocol.py
Expand Up @@ -2615,7 +2615,7 @@ def processHandshake(self):
except ValueError:
return self.failHandshake("invalid port '%s' in HTTP Host header '%s'" % (str(p.strip()), str(self.http_request_host)))

# do port checking only if externalPort or URL was set
# do port checking only if externalPort was set
if self.factory.externalPort:
if port != self.factory.externalPort:
return self.failHandshake("port %d in HTTP Host header '%s' does not match server listening port %s" % (port, str(self.http_request_host), self.factory.externalPort))
Expand All @@ -2624,14 +2624,6 @@ def processHandshake(self):

self.http_request_host = h

else:
# do port checking only if externalPort or URL was set
if self.factory.externalPort:
if not ((self.factory.isSecure and self.factory.externalPort == 443) or (not self.factory.isSecure and self.factory.externalPort == 80)):
return self.failHandshake("missing port in HTTP Host header '%s' and server runs on non-standard port %d (wss = %s)" % (str(self.http_request_host), self.factory.externalPort, self.factory.isSecure))
else:
self.log.debug("skipping opening handshake port checking - neither WS URL nor external port set")

# Upgrade
#
if 'upgrade' not in self.http_headers:
Expand Down Expand Up @@ -3195,12 +3187,7 @@ def setSessionParameters(self,
self.server = server
self.headers = headers or {}

if externalPort:
self.externalPort = externalPort
elif url:
self.externalPort = self.port
else:
self.externalPort = None
self.externalPort = externalPort

def resetProtocolOptions(self):
"""
Expand Down