def __init__(self, host='localhost', port=51423, program=None, version=None, sec_list=None, timeout=15.0, uselowport=False): self.debug = 0 t = threading.currentThread() self.lock = threading.Lock() self.af = socket.AF_INET if host.find(':') != -1: self.af = socket.AF_INET6 self.remotehost = host self.remoteport = port self.timeout = timeout self.uselowport = uselowport self._socket = {} self.getsocket() # init socket, is this needed here? self.ipaddress = self.socket.getsockname()[0] self._rpcpacker = {t: rpc_pack.RPCPacker()} self._rpcunpacker = {t: rpc_pack.RPCUnpacker('')} self.default_prog = program self.default_vers = version self.xid = 0 self._xidlist = {} if sec_list is None: sec_list = [SecAuthNone()] self.sec_list = sec_list self._init_security(self.sec_list) # Note this can make calls self.security = sec_list[0]
def __init__(self, host='localhost', port=51423, program=None, version=None, sec_list=None, timeout=15.0, uselowport=False): self.debug = 0 t = threading.currentThread() self.lock = threading.Lock() res = socket.getaddrinfo(host, port, 0, socket.SOCK_STREAM) self.af, socktype, proto, cannonname, self.sa = res[0] self.remotehost = host self.remoteport = port self.timeout = timeout self.uselowport = uselowport self._socket = {} self.getsocket() # init socket, is this needed here? self.ipaddress = os.fsencode(self.socket.getsockname()[0]) self._rpcpacker = {t : rpc_pack.RPCPacker()} self._rpcunpacker = {t : rpc_pack.RPCUnpacker('')} self.default_prog = program self.default_vers = version self.xid = 0 self._xidlist = {} if sec_list is None: sec_list = [SecAuthNone()] self.sec_list = sec_list self._init_security(self.sec_list) # Note this can make calls self.security = sec_list[0]
def getrpcpacker(self): t = threading.currentThread() self.lock.acquire() if t in self._rpcpacker: out = self._rpcpacker[t] else: out = self._rpcpacker[t] = rpc_pack.RPCPacker() self._rpcunpacker[t] = rpc_pack.RPCUnpacker('') self.lock.release() return out
def __init__(self, prog=10, vers=4, host='', port=51423): Server.__init__(self, host, port) self.rpcpacker = rpc_pack.RPCPacker() self.rpcunpacker = rpc_pack.RPCUnpacker('') self.prog = prog self.vers = vers # FRED - this could be more general self.security = {} for secname, sectype in {'none': AUTH_NONE, 'sys': AUTH_SYS, 'gss': RPCSEC_GSS, }.items(): if secname in supported: self.security[sectype] = supported[secname]() self.readbufs = {} self.writebufs = {} self.packetbufs = {} # store packets read until have a whole record self.recordbufs = {} # write buffer for outgoing records self.sockets = {} self.s.listen(5)