def __init__(self, arg1 = None, arg2 = None): if arg1 == None or Common.typeIsString(arg1): filePath = "" if arg1 == None and arg2 == None: # Check if we can connect using UnixSocket. tryFilePath = "/var/run/nfd.sock" # Use listdir because isfile doesn't see socket file types. if (os.path.basename(tryFilePath) in os.listdir(os.path.dirname(tryFilePath))): filePath = tryFilePath else: tryFilePath = "/tmp/.ndnd.sock" if (os.path.basename(tryFilePath) in os.listdir(os.path.dirname(tryFilePath))): filePath = tryFilePath if filePath == "": transport = TcpTransport() host = arg1 if arg1 != None else "localhost" connectionInfo = TcpTransport.ConnectionInfo( host, arg2 if type(arg2) is int else 6363) else: transport = UnixTransport() connectionInfo = UnixTransport.ConnectionInfo(filePath) else: transport = arg1 connectionInfo = arg2 self._node = Node(transport, connectionInfo) self._commandKeyChain = None self._commandCertificateName = Name()
def __init__(self, arg1=None, arg2=None): if arg1 == None or Common.typeIsString(arg1): filePath = "" if arg1 == None and arg2 == None: # Check if we can connect using UnixSocket. filePath = self._getUnixSocketFilePathForLocalhost() if filePath == "": transport = TcpTransport() host = arg1 if arg1 != None else "localhost" connectionInfo = TcpTransport.ConnectionInfo( host, arg2 if type(arg2) is int else 6363) else: transport = UnixTransport() connectionInfo = UnixTransport.ConnectionInfo(filePath) else: transport = arg1 connectionInfo = arg2 self._node = Node(transport, connectionInfo) self._commandKeyChain = None self._commandCertificateName = Name()