Пример #1
0
func (factory *VMessInboundHandlerFactory) Create(dispatcher app.PacketDispatcher, rawConfig interface{}) (proxy.InboundConnectionHandler, error) {
	config := rawConfig.(config.Inbound)

	allowedClients := user.NewTimedUserSet()
	for _, user := range config.AllowedUsers() {
		allowedClients.AddUser(user)
	}

	return NewVMessInboundHandler(dispatcher, allowedClients, config.UDPEnabled()), nil
}
Пример #2
0
func (this *VMessInboundHandlerFactory) Create(space app.Space, rawConfig interface{}) (connhandler.InboundConnectionHandler, error) {
	config := rawConfig.(Config)

	allowedClients := user.NewTimedUserSet()
	for _, user := range config.AllowedUsers() {
		allowedClients.AddUser(user)
	}

	return NewVMessInboundHandler(space, allowedClients), nil
}
Пример #3
0
func (factory *VMessInboundHandlerFactory) Create(vp *core.Point, rawConfig interface{}) (core.InboundConnectionHandler, error) {
	config := rawConfig.(*VMessInboundConfig)

	allowedClients := user.NewTimedUserSet()
	for _, client := range config.AllowedClients {
		user, err := client.ToUser()
		if err != nil {
			panic(log.Error("VMessIn: Failed to parse user id %s: %v", client.Id, err))
		}
		allowedClients.AddUser(user)
	}

	return NewVMessInboundHandler(vp, allowedClients, config.UDPEnabled), nil
}
Пример #4
0
func init() {
	if err := internal.RegisterInboundConnectionHandlerFactory("vmess", func(space app.Space, rawConfig interface{}) (proxy.InboundConnectionHandler, error) {
		config := rawConfig.(Config)

		allowedClients := user.NewTimedUserSet()
		for _, user := range config.AllowedUsers() {
			allowedClients.AddUser(user)
		}

		return NewVMessInboundHandler(space, allowedClients), nil
	}); err != nil {
		panic(err)
	}
}
Пример #5
0
func (factory *VMessInboundHandlerFactory) Create(vp *core.Point, rawConfig []byte) (core.InboundConnectionHandler, error) {
	config, err := loadInboundConfig(rawConfig)
	if err != nil {
		panic(log.Error("VMessIn: Failed to load VMess inbound config: %v", err))
	}
	allowedClients := user.NewTimedUserSet()
	for _, client := range config.AllowedClients {
		user, err := client.ToUser()
		if err != nil {
			panic(log.Error("VMessIn: Failed to parse user id %s: %v", client.Id, err))
		}
		allowedClients.AddUser(user)
	}
	return NewVMessInboundHandler(vp, allowedClients), nil
}