Пример #1
0
 def __init__(self,
              host: Optional[str] = None,
              port: Optional[int] = None,
              socket: Optional[str] = None):
     if (socket and host) or (socket and port) or (not socket and not host
                                                   and not port):
         raise errors.VPNError(
             "Must specify either socket or host and port")
     if socket:
         self._mgmt_socket = socket
         self._type = VPNType.UNIX_SOCKET
     else:
         self._mgmt_host = host
         self._mgmt_port = port
         self._type = VPNType.IP
     self._socket = None
     self.clear_cache()  # Initialise release info and daemon state caches
Пример #2
0
    def __init__(self,
                 host: str = None,
                 port: int = None,
                 unix_socket: str = None):
        if (unix_socket and host) or (unix_socket
                                      and port) or (not unix_socket
                                                    and not host and not port):
            raise errors.VPNError(
                "Must specify either socket or host and port")

        self._mgmt_socket: Optional[str] = unix_socket
        self._mgmt_host: Optional[str] = host
        self._mgmt_port: Optional[int] = port
        self._socket: Optional[socket.socket] = None

        # Release info cache
        self._release: Optional[str] = None
Пример #3
0
 def __init__(self,
              host: Optional[str] = None,
              port: Optional[int] = None,
              unix_socket: Optional[str] = None):
     if (unix_socket and host) or (unix_socket
                                   and port) or (not unix_socket
                                                 and not host and not port):
         raise errors.VPNError(
             "Must specify either socket or host and port")
     if unix_socket:
         self._mgmt_socket = unix_socket
         self._type = VPNType.UNIX_SOCKET
     else:
         self._mgmt_host = host
         self._mgmt_port = port
         self._type = VPNType.IP
     self._socket = None  # type: Optional[socket.socket]
     # Initialise release info and daemon state caches
     self._release = None  # type: Optional[str]