1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2026-01-03 15:55:20 -05:00

refactor dependency resolution

This commit is contained in:
Darien Raymond
2018-10-21 10:27:13 +02:00
parent d9cdfffc69
commit a5dcb0f13e
36 changed files with 356 additions and 730 deletions

View File

@@ -28,15 +28,16 @@ import (
// Server is an HTTP proxy server.
type Server struct {
config *ServerConfig
v *core.Instance
config *ServerConfig
policyManager policy.Manager
}
// NewServer creates a new HTTP inbound handler.
func NewServer(ctx context.Context, config *ServerConfig) (*Server, error) {
v := core.MustFromContext(ctx)
s := &Server{
config: config,
v: core.MustFromContext(ctx),
config: config,
policyManager: v.GetFeature(policy.ManagerType()).(policy.Manager),
}
return s, nil
@@ -44,7 +45,7 @@ func NewServer(ctx context.Context, config *ServerConfig) (*Server, error) {
func (s *Server) policy() policy.Session {
config := s.config
p := s.v.PolicyManager().ForLevel(config.UserLevel)
p := s.policyManager.ForLevel(config.UserLevel)
if config.Timeout > 0 && config.UserLevel == 0 {
p.Timeouts.ConnectionIdle = time.Duration(config.Timeout) * time.Second
}