예제 #1
0
파일: base.py 프로젝트: Jancehk/TcpRoute
    def __init__(self, config):
        self.type = config.get('type', None)
        self.config = config

        import upstream as upstream_mod

        upconfig = config.get('upstream', None)

        if upconfig:
            uptype = upconfig.get("type", None)
            if uptype is None:
                raise ConfigError(u'[配置错误] upstream 未配置 type !')

            Upstream = upstream_mod.get_upstream(uptype)
            if Upstream is None:
                raise ConfigError(u'[配置错误] upstream type %s 不被支持!' % uptype)

            self.upstream = Upstream(upconfig)
            pass
        else:
            if self.type != 'direct':
                self.upstream = upstream_mod.get_upstream('direct')({'type':'direct'})
            else:
                self.upstream = _socket

        self.http_pool = HttpPool(self,lock=BoundedSemaphore)
예제 #2
0
    def __init__(self, config):
        self.type = config.get('type', None)
        self.config = config

        import upstream as upstream_mod

        upconfig = config.get('upstream', None)

        if upconfig:
            uptype = upconfig.get("type", None)
            if uptype is None:
                raise ConfigError(u'[配置错误] upstream 未配置 type !')

            Upstream = upstream_mod.get_upstream(uptype)
            if Upstream is None:
                raise ConfigError(u'[配置错误] upstream type %s 不被支持!' % uptype)

            self.upstream = Upstream(upconfig)
            pass
        else:
            if self.type != 'direct':
                self.upstream = upstream_mod.get_upstream('direct')({
                    'type':
                    'direct'
                })
            else:
                self.upstream = _socket
예제 #3
0
    def __init__(self, config):
        u""" 初始化直连 socket 环境 """
        UpstreamBase.__init__(self, config)

        self.route_cache = LRUCacheDict(500, 10 * 60 * 1000)

        self._list = config.get('list', [{'type': 'direct'}])
        self.upstream_dict = {}
        for i in self._list:
            type = i.get('type')
            if not type:
                raise ConfigError(u'[upstream]代理类型不能为空! ')
            Upstream = upstream.get_upstream(type)
            u = Upstream(i)
            self.upstream_dict[u.get_name()] = u
예제 #4
0
    def __init__(self, config):
        u""" 初始化直连 socket 环境 """
        UpstreamBase.__init__(self, config)

        self.route_cache = LRUCacheDict(500, 10 * 60 * 1000)

        self._list = config.get('list', [{'type': 'direct'}])
        self.upstream_dict = {}
        for i in self._list:
            type = i.get('type')
            if not type:
                raise ConfigError(u'[upstream]代理类型不能为空! ')
            Upstream = upstream.get_upstream(type)
            u = Upstream(i)
            self.upstream_dict[u.get_name()] = u
예제 #5
0
파일: server.py 프로젝트: Jancehk/TcpRoute
    def __init__(self, config):
        self.config = config
        self.upstream = None

        listener = ("0.0.0.0", config.get("port", 7070))
        StreamServer.__init__(self, listener, backlog=1024, )

        config_upstream = config.get("upstream", {'type': 'direct'})
        type = config_upstream.get('type', None)
        if type is None:
            raise ConfigError(u'[upstream]未配置代理类型!详细信息:%s' % config_upstream)
        Upstream = upstream.get_upstream(type)
        if Upstream is None:
            raise ConfigError(u'[upstream]不支持 %s 类型代理!' % type)

        self.upstream = Upstream(config_upstream)
예제 #6
0
    def __init__(self, config):
        self.config = config
        self.upstream = None

        listener = ("0.0.0.0", config.get("port", 7070))
        StreamServer.__init__(
            self,
            listener,
            backlog=1024,
        )

        config_upstream = config.get("upstream", {'type': 'direct'})
        type = config_upstream.get('type', None)
        if type is None:
            raise ConfigError(u'[upstream]未配置代理类型!详细信息:%s' % config_upstream)
        Upstream = upstream.get_upstream(type)
        if Upstream is None:
            raise ConfigError(u'[upstream]不支持 %s 类型代理!' % type)

        self.upstream = Upstream(config_upstream)