mirror of
https://github.com/python-kasa/python-kasa.git
synced 2025-12-02 06:08:17 +00:00
Update to use http port from discovery if present
This commit is contained in:
@@ -120,6 +120,8 @@ class AesTransport(BaseTransport):
|
||||
@property
|
||||
def default_port(self) -> int:
|
||||
"""Default port for the transport."""
|
||||
if port := self._config.connection_type.http_port:
|
||||
return port
|
||||
return self.DEFAULT_PORT
|
||||
|
||||
@property
|
||||
|
||||
@@ -93,6 +93,8 @@ class KlapTransport(BaseTransport):
|
||||
"""
|
||||
|
||||
DEFAULT_PORT: int = 80
|
||||
DEFAULT_HTTPS_PORT: int = 4433
|
||||
|
||||
SESSION_COOKIE_NAME = "TP_SESSIONID"
|
||||
TIMEOUT_COOKIE_NAME = "TIMEOUT"
|
||||
# Copy & paste from sslaestransport
|
||||
@@ -144,6 +146,13 @@ class KlapTransport(BaseTransport):
|
||||
@property
|
||||
def default_port(self) -> int:
|
||||
"""Default port for the transport."""
|
||||
config = self._config
|
||||
if port := config.connection_type.http_port:
|
||||
return port
|
||||
|
||||
if config.connection_type.https:
|
||||
return self.DEFAULT_HTTPS_PORT
|
||||
|
||||
return self.DEFAULT_PORT
|
||||
|
||||
@property
|
||||
|
||||
@@ -55,6 +55,8 @@ class LinkieTransportV2(BaseTransport):
|
||||
@property
|
||||
def default_port(self) -> int:
|
||||
"""Default port for the transport."""
|
||||
if port := self._config.connection_type.http_port:
|
||||
return port
|
||||
return self.DEFAULT_PORT
|
||||
|
||||
@property
|
||||
|
||||
@@ -133,6 +133,8 @@ class SslAesTransport(BaseTransport):
|
||||
@property
|
||||
def default_port(self) -> int:
|
||||
"""Default port for the transport."""
|
||||
if port := self._config.connection_type.http_port:
|
||||
return port
|
||||
return self.DEFAULT_PORT
|
||||
|
||||
@staticmethod
|
||||
|
||||
@@ -94,6 +94,8 @@ class SslTransport(BaseTransport):
|
||||
@property
|
||||
def default_port(self) -> int:
|
||||
"""Default port for the transport."""
|
||||
if port := self._config.connection_type.http_port:
|
||||
return port
|
||||
return self.DEFAULT_PORT
|
||||
|
||||
@property
|
||||
|
||||
Reference in New Issue
Block a user