コード例 #1
0
ファイル: server.py プロジェクト: luckypoem/usocks
    def _process(self):
        rlist, rdict = get_select_list(
            'get_rlist', self.backend, self.tunnels.iterkeys(),
            (frontend
             for frontend, (conn_id, tunnel) in self.frontends.iteritems()
             if tunnel.available))
        wlist, wdict = get_select_list('get_wlist', self.tunnels.iterkeys(),
                                       self.frontends.iterkeys())
        try:
            rlist, wlist, _ = select.select(rlist, wlist, [])
        except select.error as e:
            if e[0] == errno.EINTR:
                return
            raise

        for fileno in rlist:
            conn = rdict[fileno]
            if conn is self.backend:
                self._process_backend()
            elif conn in self.tunnels:
                self._process_tunnel(conn)
            elif conn in self.frontends:
                self._process_frontend(conn)
        written_conns = ObjectSet()
        for fileno in wlist:
            conn = wdict[fileno]
            if conn in written_conns:
                continue
            written_conns.add(conn)
            if conn in self.tunnels:
                self._process_tunnel_sending(conn)
            else:
                conn.send()
コード例 #2
0
ファイル: client.py プロジェクト: upsuper/usocks
    def _process(self):
        rlist, rdict = get_select_list('get_rlist', 
                self.tunnel, self.local_conn,
                self.conns.itervalues() if self.tunnel.available else [])
        wlist, wdict = get_select_list('get_wlist',
                self.tunnel, self.conns.itervalues())
        try:
            rlist, wlist, _ = select.select(rlist, wlist, [])
        except select.error as e:
            if e[0] == errno.EINTR:
                return
            raise

        for fileno in rlist:
            conn = rdict[fileno]
            if conn is self.tunnel:
                self._process_tunnel()
            elif conn is self.local_conn:
                self._process_listening()
            elif conn.conn_id in self.conns:
                self._process_connection(conn)
        written_conns = ObjectSet()
        for fileno in wlist:
            conn = wdict[fileno]
            if conn in written_conns:
                continue
            written_conns.add(conn)
            self._process_sending(conn)
コード例 #3
0
ファイル: server.py プロジェクト: upsuper/usocks
    def _process(self):
        rlist, rdict = get_select_list('get_rlist',
                self.backend, self.tunnels.iterkeys(),
                (frontend for frontend, (conn_id, tunnel)
                    in self.frontends.iteritems()
                    if tunnel.available))
        wlist, wdict = get_select_list('get_wlist',
                self.tunnels.iterkeys(), self.frontends.iterkeys())
        try:
            rlist, wlist, _ = select.select(rlist, wlist, [])
        except select.error as e:
            if e[0] == errno.EINTR:
                return
            raise

        for fileno in rlist:
            conn = rdict[fileno]
            if conn is self.backend:
                self._process_backend()
            elif conn in self.tunnels:
                self._process_tunnel(conn)
            elif conn in self.frontends:
                self._process_frontend(conn)
        written_conns = ObjectSet()
        for fileno in wlist:
            conn = wdict[fileno]
            if conn in written_conns:
                continue
            written_conns.add(conn)
            if conn in self.tunnels:
                self._process_tunnel_sending(conn)
            else:
                conn.send()
コード例 #4
0
ファイル: client.py プロジェクト: luckypoem/usocks
    def _process(self):
        rlist, rdict = get_select_list(
            'get_rlist', self.tunnel, self.local_conn,
            self.conns.itervalues() if self.tunnel.available else [])
        wlist, wdict = get_select_list('get_wlist', self.tunnel,
                                       self.conns.itervalues())
        try:
            rlist, wlist, _ = select.select(rlist, wlist, [])
        except select.error as e:
            if e[0] == errno.EINTR:
                return
            raise

        for fileno in rlist:
            conn = rdict[fileno]
            if conn is self.tunnel:
                self._process_tunnel()
            elif conn is self.local_conn:
                self._process_listening()
            elif conn.conn_id in self.conns:
                self._process_connection(conn)
        written_conns = ObjectSet()
        for fileno in wlist:
            conn = wdict[fileno]
            if conn in written_conns:
                continue
            written_conns.add(conn)
            self._process_sending(conn)