adjust init sequence

pull/861/head
Darien Raymond 7 years ago
parent 0273b36027
commit cf832a4272
No known key found for this signature in database
GPG Key ID: 7251FFA14BB18169

@ -82,13 +82,6 @@ type Handler struct {
// New creates a new VMess inbound handler.
func New(ctx context.Context, config *Config) (*Handler, error) {
allowedClients := vmess.NewTimedUserValidator(ctx, protocol.DefaultIDHash)
for _, user := range config.User {
if err := allowedClients.Add(user); err != nil {
return nil, newError("failed to initiate user").Base(err)
}
}
v := core.FromContext(ctx)
if v == nil {
return nil, newError("V is not in context.")
@ -97,12 +90,18 @@ func New(ctx context.Context, config *Config) (*Handler, error) {
handler := &Handler{
policyManager: v.PolicyManager(),
inboundHandlerManager: v.InboundHandlerManager(),
clients: allowedClients,
clients: vmess.NewTimedUserValidator(ctx, protocol.DefaultIDHash),
detours: config.Detour,
usersByEmail: newUserByEmail(config.User, config.GetDefaultValue()),
sessionHistory: encoding.NewSessionHistory(ctx),
}
for _, user := range config.User {
if err := handler.AddUser(ctx, user); err != nil {
return nil, newError("failed to initiate user").Base(err)
}
}
return handler, nil
}
@ -121,6 +120,10 @@ func (h *Handler) GetUser(email string) *protocol.User {
return user
}
func (h *Handler) AddUser(ctx context.Context, user *protocol.User) error {
return h.clients.Add(user)
}
func transferRequest(timer signal.ActivityUpdater, session *encoding.ServerSession, request *protocol.RequestHeader, input io.Reader, output ray.OutputStream) error {
defer output.Close()

Loading…
Cancel
Save