示例#1
0
    async def init_server(self, user):
        # TODO remove this
        from shadowsocks import current_app

        self.is_running and self.check_user_server(user)

        if self.is_running or user.enable is False:
            return
        loop = asyncio.get_event_loop()
        try:
            tcp_server = await loop.create_server(LocalTCP(user), self.HOST,
                                                  user.port)
            udp_server, _ = await loop.create_datagram_endpoint(
                LocalUDP(user), (self.HOST, user.port))
            self.tcp_server = tcp_server
            self.udp_server = udp_server
            self.traffic_limiter = TrafficRateLimit(user.speed_limit)
            self.tcp_limiter = TcpConnRateLimit(
                current_app.user_tcp_conn_limit)
            self.metrics = self.init_new_metric()
            self.update_from_dict(user.to_dict())
            self.save()
            logging.info("user:{} method:{} password:{} port:{} 已启动".format(
                user, user.method, user.password, user.port))
        except OSError as e:
            logging.warning(e)
示例#2
0
    async def init_server(self, user: User):

        running_server = self.get_server_by_port(user.port)
        if running_server:
            return

        tcp_server = await self.loop.create_server(LocalTCP(user.port),
                                                   self.listen_host, user.port)
        udp_server, _ = await self.loop.create_datagram_endpoint(
            LocalUDP(user.port), (self.listen_host, user.port))
        self.__running_servers__[user.port] = {
            "tcp": tcp_server,
            "udp": udp_server,
        }
        logging.info("user:{} method:{} password:{} {}:{} 已启动".format(
            user, user.method, user.password, self.listen_host, user.port))
示例#3
0
    async def init_server(self, user):
        self.is_running and self.check_user_server(user)

        if self.is_running or not user.enable:
            return
        loop = asyncio.get_event_loop()
        try:
            tcp_server = await loop.create_server(LocalTCP(user), self.HOST,
                                                  user.port)
            udp_server, _ = await loop.create_datagram_endpoint(
                LocalUDP(user), (self.HOST, user.port))
            self.tcp_server = tcp_server
            self.udp_server = udp_server
            logging.info("user_id:{} method:{} password:{} port:{} 已启动".format(
                user.user_id, user.method, user.password, user.port))
        except OSError as e:
            logging.warning(e)
示例#4
0
    async def __init_server(self, user: User):
        running_server = await self.__get_server_by_port(user.port)
        if running_server:
            return

        tcp_server = await self.loop.create_server(LocalTCP(user.port),
                                                   self.listen_host,
                                                   user.port,
                                                   reuse_port=True)
        udp_server, _ = await self.loop.create_datagram_endpoint(
            LocalUDP(user.port), (self.listen_host, user.port),
            reuse_port=True)
        self.__running_servers__[user.port] = {
            "tcp": tcp_server,
            "udp": udp_server,
        }
        logger.info(
            f"user:{user} method:{user.method} password:{user.password} {self.listen_host}:{user.port} 已启动"
        )
示例#5
0
    async def init_server(self, user: User):

        running_server = self.get_server_by_port(user.port)
        if running_server:
            if user.method in self.AEAD_METHOD_LIST:
                logging.info("user:{} method:{} password:{} 共享端口:{}".format(
                    user, user.method, user.password, user.port))
            return

        tcp_server = await self.loop.create_server(LocalTCP(user.port),
                                                   self.HOST, user.port)
        udp_server, _ = await self.loop.create_datagram_endpoint(
            LocalUDP(user.port), (self.HOST, user.port))
        self.__running_servers__[user.port] = {
            "tcp": tcp_server,
            "udp": udp_server,
        }
        logging.info("user:{} method:{} password:{} port:{} 已启动".format(
            user, user.method, user.password, user.port))