pythonlib: Proxy credentials are now optional

This commit is contained in:
Nongzhsh 2024-11-18 10:57:22 +08:00
parent d1bc5f7644
commit 74e0d08afc

View file

@ -22,8 +22,8 @@ class Proxy:
""" """
server: str server: str
username: str username: Optional[str] = None
password: str password: Optional[str] = None
@staticmethod @staticmethod
def parse_server(server: str) -> Tuple[str, str, Optional[str]]: def parse_server(server: str) -> Tuple[str, str, Optional[str]]:
@ -44,8 +44,9 @@ class Proxy:
result += f"{self.username}" result += f"{self.username}"
if self.password: if self.password:
result += f":{self.password}" result += f":{self.password}"
result += "@"
result += f"@{url}" result += url
if port: if port:
result += f":{port}" result += f":{port}"
return result return result