MCPcopy Index your code
hub / github.com/Rushifakami/csfloat_api / _validate_proxy

Method _validate_proxy

csfloat_client.py:60–76  ·  view source on GitHub ↗

Validates the proxy URL format. Raises: ValueError: If the proxy URL format is invalid or the port is out of range.

(self)

Source from the content-addressed store, hash-verified

58 await self._session.close()
59
60 def _validate_proxy(self) -> None:
61 """Validates the proxy URL format.
62
63 Raises:
64 ValueError: If the proxy URL format is invalid or the port is out of range.
65 """
66 if not self.proxy:
67 return # Proxy is not set, which is acceptable
68 # Regular expression to check the format: socks5://user:pass@host:port, etc.
69 pattern = r'^(socks5|socks4|http|https)://(\w+:\w+@)?[\w.-]+:\d+$'
70 if not re.match(pattern, self.proxy):
71 raise ValueError(
72 f"Invalid proxy URL format: {self.proxy}. Expected format like 'socks5://user:pass@host:port'")
73 # Check the port
74 port = self.proxy.split(':')[-1]
75 if not port.isdigit() or not (1 <= int(port) <= 65535):
76 raise ValueError(f"Invalid port in proxy URL: {port}")
77
78 async def _request(self, method: str, parameters: str, json_data=None) -> Optional[dict]:
79 if method not in self._SUPPORTED_METHODS:

Callers 1

__init__Method · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected