@@ -19,17 +19,6 @@ class VPNType:
19
19
20
20
21
21
class VPN :
22
- _mgmt_host = None # Management interface host
23
- _mgmt_port = None # Management interface port
24
- _mgmt_socket = None # Management interface UNIX socket
25
- _type : Optional [str ] = None # VPNType object to choose between IP (host:port) and socket
26
- _socket = None
27
-
28
- _release = None # OpenVPN release string
29
- _state = None # State object
30
- stats = ServerStats () # Stats object
31
- sessions = [] # Client sessions
32
-
33
22
def __init__ (self , host : Optional [str ] = None , port : Optional [int ] = None , socket : Optional [str ] = None ):
34
23
if (socket and host ) or (socket and port ) or (not socket and not host and not port ):
35
24
raise errors .VPNError ("Must specify either socket or host and port" )
@@ -40,6 +29,8 @@ def __init__(self, host: Optional[str] = None, port: Optional[int] = None, socke
40
29
self ._mgmt_host = host
41
30
self ._mgmt_port = port
42
31
self ._type = VPNType .IP
32
+ self ._socket = None
33
+ self .clear_cache () # Initialise release info and daemon state caches
43
34
44
35
@property
45
36
def type (self ) -> Optional [str ]:
@@ -62,7 +53,6 @@ def connect(self) -> Optional[bool]:
62
53
try :
63
54
if self .type == VPNType .IP :
64
55
self ._socket = socket .create_connection ((self ._mgmt_host , self ._mgmt_port ), timeout = 3 )
65
-
66
56
else :
67
57
self ._socket = socket .socket (socket .AF_UNIX , socket .SOCK_STREAM )
68
58
self ._socket .connect (self ._mgmt_socket )
0 commit comments