Skip to content

Commit 6b666bf

Browse files
committed
fix: sync proxy instance ip_address and port with Uniproxy attribute changes
- added property setters for ip_address and port to ensure changes are reflected in the proxy instance
1 parent 66d31c0 commit 6b666bf

1 file changed

Lines changed: 23 additions & 3 deletions

File tree

uniproxy/__init__.py

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,32 @@
1616

1717
class Uniproxy:
1818
def __init__(self, ip: str, port: int):
19-
self.ip_address = ip
20-
self.port = port
21-
self.proxy = self.__get_proxy_instance()
19+
self._ip_address = ip
20+
self._port = port
21+
self.proxy = self.__get_proxy_instance()
2222
if not self.__check_connection():
2323
warnings.warn("Unable to bind to the specified IP and Port.\nPlease check if the IP and Port are correct\n and port is not already in use.")
2424

25+
@property
26+
def ip_address(self):
27+
return self._ip_address
28+
29+
@ip_address.setter
30+
def ip_address(self, value):
31+
self._ip_address = value
32+
if hasattr(self, 'proxy'):
33+
self.proxy.ip_address = value
34+
35+
@property
36+
def port(self):
37+
return self._port
38+
39+
@port.setter
40+
def port(self, value):
41+
self._port = value
42+
if hasattr(self, 'proxy'):
43+
self.proxy.port = value
44+
2545
def __check_connection(self):
2646
try:
2747
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

0 commit comments

Comments
 (0)