1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2026-02-17 13:45:22 -05:00

interface for inbound connection handler manager

This commit is contained in:
v2ray
2016-01-01 23:44:11 +01:00
parent 6344369eb4
commit 3baa1f5bc5
24 changed files with 269 additions and 167 deletions

View File

@@ -12,6 +12,7 @@ import (
"github.com/v2ray/v2ray-core/common/log"
v2net "github.com/v2ray/v2ray-core/common/net"
"github.com/v2ray/v2ray-core/common/retry"
"github.com/v2ray/v2ray-core/proxy"
"github.com/v2ray/v2ray-core/proxy/common/connhandler"
"github.com/v2ray/v2ray-core/proxy/vmess"
"github.com/v2ray/v2ray-core/proxy/vmess/protocol"
@@ -139,20 +140,17 @@ func handleOutput(request *protocol.VMessRequest, writer io.Writer, output <-cha
finish.Unlock()
}
type VMessInboundHandlerFactory struct {
}
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
}
func init() {
connhandler.RegisterInboundConnectionHandlerFactory("vmess", &VMessInboundHandlerFactory{})
if err := proxy.RegisterInboundConnectionHandlerFactory("vmess", func(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
}); err != nil {
panic(err)
}
}