def start(self, protocol): """ Execute NTP protocol :param protocol: instance of NtpProtocol """ if IpUtil.get_ip_version(protocol.host) == 6: self.port = reactor.listenUDP(0, protocol, interface='::') else: self.port = reactor.listenUDP(0, protocol)
def start(self, protocol): """ Execute NTP protocol :param protocol: instance of NtpProtocol """ if IpUtil.get_ip_version(protocol.host) == 6: self.port = reactor.listenUDP(0, protocol, interface='::') else: self.port = reactor.listenUDP(0, protocol)
def parse(self, results): """Parses command output in `results` string and returns services information in format: [(proto, port, addr), ...] """ services = [] for line in results.split("\n"): # tcp UNCONN 0 0 *:68 *:* fields = line.split() if len(fields) != 6: continue try: proto = fields[0] # please note protocol alway be tcp due a bug in RH; # see https://bugzilla.redhat.com/show_bug.cgi?id=1063927 if fields[1] == 'UNCONN': proto = 'udp' addr, port = fields[4].rsplit(":", 1) if addr == '*': addr = '0.0.0.0' else: ip_version = IpUtil.get_ip_version(addr) if ip_version is None: # Not a valid ip continue elif ip_version == 6: proto = proto + '6' self.log.debug("Got %s %s port %s", addr, proto, port) port = int(port) except ValueError: self.log.exception("Failed to parse IPService information '%s'", line) continue services.append((proto, port, addr)) return services
def parse(self, results): """Parses command output in `results` string and returns services information in format: [(proto, port, addr), ...] """ services = [] for line in results.split("\n"): # tcp UNCONN 0 0 *:68 *:* fields = line.split() if len(fields) != 6: continue try: proto = fields[0] # please note protocol alway be tcp due a bug in RH; # see https://bugzilla.redhat.com/show_bug.cgi?id=1063927 if fields[1] == 'UNCONN': proto = 'udp' addr, port = fields[4].rsplit(":", 1) if addr == '*': addr = '0.0.0.0' else: ip_version = IpUtil.get_ip_version(addr) if ip_version is None: # Not a valid ip continue elif ip_version == 6: proto = proto + '6' self.log.debug("Got %s %s port %s", addr, proto, port) port = int(port) except ValueError: self.log.exception( "Failed to parse IPService information '%s'", line) continue services.append((proto, port, addr)) return services