当前位置: 首页>>代码示例>>Python>>正文


Python helpers.debug2函数代码示例

本文整理汇总了Python中sshuttle.helpers.debug2函数的典型用法代码示例。如果您正苦于以下问题:Python debug2函数的具体用法?Python debug2怎么用?Python debug2使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了debug2函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: connect_dst

def connect_dst(family, ip, port):
    debug2('Connecting to %s:%d\n' % (ip, port))
    outsock = socket.socket(family)
    outsock.setsockopt(socket.SOL_IP, socket.IP_TTL, 42)
    return SockWrapper(outsock, outsock,
                       connect_to=(ip, port),
                       peername='%s:%d' % (ip, port))
开发者ID:TooKennySupreme,项目名称:sshuttle,代码行数:7,代码来源:ssnet.py

示例2: try_send

    def try_send(self):
        if self.tries >= 3:
            return
        self.tries += 1

        family, peer = resolvconf_random_nameserver()

        sock = socket.socket(family, socket.SOCK_DGRAM)
        sock.setsockopt(socket.SOL_IP, socket.IP_TTL, 42)
        sock.connect((peer, 53))

        self.peers[sock] = peer

        debug2('DNS: sending to %r (try %d)\n' % (peer, self.tries))
        try:
            sock.send(self.request)
            self.socks.append(sock)
        except socket.error:
            _, e = sys.exc_info()[:2]
            if e.args[0] in ssnet.NET_ERRS:
                # might have been spurious; try again.
                # Note: these errors sometimes are reported by recv(),
                # and sometimes by send().  We have to catch both.
                debug2('DNS send to %r: %s\n' % (peer, e))
                self.try_send()
                return
            else:
                log('DNS send to %r: %s\n' % (peer, e))
                return
开发者ID:dlenski,项目名称:sshuttle,代码行数:29,代码来源:server.py

示例3: _check_nmb

def _check_nmb(hostname, is_workgroup, is_master):
    return
    global _nmb_ok
    if not _nmb_ok:
        return
    argv = ['nmblookup'] + ['-M'] * is_master + ['--', hostname]
    debug2(' > n%d%d: %s\n' % (is_workgroup, is_master, hostname))
    try:
        p = ssubprocess.Popen(argv, stdout=ssubprocess.PIPE, stderr=null)
        lines = p.stdout.readlines()
        rv = p.wait()
    except OSError:
        _, e = sys.exc_info()[:2]
        log('%r failed: %r\n' % (argv, e))
        _nmb_ok = False
        return
    if rv:
        log('%r returned %d\n' % (argv, rv))
        return
    for line in lines:
        m = re.match(r'(\d+\.\d+\.\d+\.\d+) (\w+)<\w\w>\n', line)
        if m:
            g = m.groups()
            (ip, name) = (g[0], g[1].lower())
            debug3('<    %s -> %s\n' % (name, ip))
            if is_workgroup:
                _enqueue(_check_smb, ip)
            else:
                found_host(name, ip)
                check_host(name)
开发者ID:dlenski,项目名称:sshuttle,代码行数:30,代码来源:hostwatch.py

示例4: runonce

def runonce(handlers, mux):
    r = []
    w = []
    x = []
    to_remove = [s for s in handlers if not s.ok]
    for h in to_remove:
        handlers.remove(h)

    for s in handlers:
        s.pre_select(r, w, x)
    debug2('Waiting: %d r=%r w=%r x=%r (fullness=%d/%d)\n'
           % (len(handlers), _fds(r), _fds(w), _fds(x),
               mux.fullness, mux.too_full))
    (r, w, x) = select.select(r, w, x)
    debug2('  Ready: %d r=%r w=%r x=%r\n'
           % (len(handlers), _fds(r), _fds(w), _fds(x)))
    ready = r + w + x
    did = {}
    for h in handlers:
        for s in h.socks:
            if s in ready:
                h.callback(s)
                did[s] = 1
    for s in ready:
        if s not in did:
            raise Fatal('socket %r was not used by any handler' % s)
开发者ID:TooKennySupreme,项目名称:sshuttle,代码行数:26,代码来源:ssnet.py

示例5: send

 def send(self, dstip, data):
     debug2('UDP: sending to %r port %d\n' % dstip)
     try:
         self.sock.sendto(data, dstip)
     except socket.error as e:
         log('UDP send to %r port %d: %s\n' % (dstip[0], dstip[1], e))
         return
开发者ID:64BitChris,项目名称:sshuttle,代码行数:7,代码来源:server.py

示例6: __init__

 def __init__(self, mux, channel):
     SockWrapper.__init__(self, mux.rsock, mux.wsock)
     self.mux = mux
     self.channel = channel
     self.mux.channels[channel] = self.got_packet
     self.socks = []
     debug2('new channel: %d\n' % channel)
开发者ID:TooKennySupreme,项目名称:sshuttle,代码行数:7,代码来源:ssnet.py

示例7: nowrite

 def nowrite(self):
     if not self.shut_write:
         debug2('%r: done writing\n' % self)
         self.shut_write = True
         try:
             self.wsock.shutdown(SHUT_WR)
         except socket.error as e:
             self.seterr('nowrite: %s' % e)
开发者ID:64BitChris,项目名称:sshuttle,代码行数:8,代码来源:ssnet.py

示例8: _check_revdns

def _check_revdns(ip):
    debug2(' > rev: %s\n' % ip)
    try:
        r = socket.gethostbyaddr(ip)
        debug3('<    %s\n' % r[0])
        check_host(r[0])
        found_host(r[0], ip)
    except socket.herror:
        pass
开发者ID:dlenski,项目名称:sshuttle,代码行数:9,代码来源:hostwatch.py

示例9: flush

 def flush(self):
     self.wsock.setblocking(False)
     if self.outbuf and self.outbuf[0]:
         wrote = _nb_clean(os.write, self.wsock.fileno(), self.outbuf[0])
         debug2('mux wrote: %r/%d\n' % (wrote, len(self.outbuf[0])))
         if wrote:
             self.outbuf[0] = self.outbuf[0][wrote:]
     while self.outbuf and not self.outbuf[0]:
         self.outbuf[0:1] = []
开发者ID:TooKennySupreme,项目名称:sshuttle,代码行数:9,代码来源:ssnet.py

示例10: callback

 def callback(self, sock):
     try:
         data, peer = sock.recvfrom(4096)
     except socket.error as e:
         log('UDP recv from %r port %d: %s\n' % (peer[0], peer[1], e))
         return
     debug2('UDP response: %d bytes\n' % len(data))
     hdr = "%s,%r," % (peer[0], peer[1])
     self.mux.send(self.chan, ssnet.CMD_UDP_DATA, hdr + data)
开发者ID:64BitChris,项目名称:sshuttle,代码行数:9,代码来源:server.py

示例11: _check_dns

def _check_dns(hostname):
    debug2(' > dns: %s\n' % hostname)
    try:
        ip = socket.gethostbyname(hostname)
        debug3('<    %s\n' % ip)
        check_host(ip)
        found_host(hostname, ip)
    except socket.gaierror:
        pass
开发者ID:dlenski,项目名称:sshuttle,代码行数:9,代码来源:hostwatch.py

示例12: send

 def send(self, channel, cmd, data):
     assert isinstance(data, bytes)
     assert len(data) <= 65535
     p = struct.pack('!ccHHH', b'S', b'S', channel, cmd, len(data)) + data
     self.outbuf.append(p)
     debug2(' > channel=%d cmd=%s len=%d (fullness=%d)\n'
            % (channel, cmd_to_name.get(cmd, hex(cmd)),
               len(data), self.fullness))
     self.fullness += len(data)
开发者ID:64BitChris,项目名称:sshuttle,代码行数:9,代码来源:ssnet.py

示例13: print_listening

 def print_listening(self, what):
     if self.v6:
         listenip = self.v6.getsockname()
         debug1('%s listening on %r.\n' % (what, listenip))
         debug2('%s listening with %r.\n' % (what, self.v6))
     if self.v4:
         listenip = self.v4.getsockname()
         debug1('%s listening on %r.\n' % (what, listenip))
         debug2('%s listening with %r.\n' % (what, self.v4))
开发者ID:Kriechi,项目名称:sshuttle,代码行数:9,代码来源:client.py

示例14: _check_smb

def _check_smb(hostname):
    return
    global _smb_ok
    if not _smb_ok:
        return
    argv = ['smbclient', '-U', '%', '-L', hostname]
    debug2(' > smb: %s\n' % hostname)
    try:
        p = ssubprocess.Popen(argv, stdout=ssubprocess.PIPE, stderr=null)
        lines = p.stdout.readlines()
        p.wait()
    except OSError:
        _, e = sys.exc_info()[:2]
        log('%r failed: %r\n' % (argv, e))
        _smb_ok = False
        return

    lines.reverse()

    # junk at top
    while lines:
        line = lines.pop().strip()
        if re.match(r'Server\s+', line):
            break

    # server list section:
    #    Server   Comment
    #    ------   -------
    while lines:
        line = lines.pop().strip()
        if not line or re.match(r'-+\s+-+', line):
            continue
        if re.match(r'Workgroup\s+Master', line):
            break
        words = line.split()
        hostname = words[0].lower()
        debug3('<    %s\n' % hostname)
        check_host(hostname)

    # workgroup list section:
    #   Workgroup  Master
    #   ---------  ------
    while lines:
        line = lines.pop().strip()
        if re.match(r'-+\s+', line):
            continue
        if not line:
            break
        words = line.split()
        (workgroup, hostname) = (words[0].lower(), words[1].lower())
        debug3('<    group(%s) -> %s\n' % (workgroup, hostname))
        check_host(hostname)
        check_workgroup(workgroup)

    if lines:
        assert(0)
开发者ID:dlenski,项目名称:sshuttle,代码行数:56,代码来源:hostwatch.py

示例15: udp_open

 def udp_open(channel, data):
     debug2('Incoming UDP open.\n')
     family = int(data)
     mux.channels[channel] = lambda cmd, data: udp_req(channel, cmd, data)
     if channel in udphandlers:
         raise Fatal('UDP connection channel %d already open' % channel)
     else:
         h = UdpProxy(mux, channel, family)
         handlers.append(h)
         udphandlers[channel] = h
开发者ID:dlenski,项目名称:sshuttle,代码行数:10,代码来源:server.py


注:本文中的sshuttle.helpers.debug2函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。