1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2025-11-23 12:02:58 -05:00

fix lint warnings

This commit is contained in:
Darien Raymond
2018-05-31 11:55:11 +02:00
parent fe3ddb0ef5
commit adade2bffd
19 changed files with 159 additions and 80 deletions

View File

@@ -5,6 +5,7 @@ import (
"sync"
"v2ray.com/core/common"
"v2ray.com/core/common/serial"
"v2ray.com/core/common/uuid"
)
@@ -53,13 +54,13 @@ func New(config *Config) (*Instance, error) {
if err != nil {
return nil, err
}
if _, err := server.CreateObject(settings); err != nil {
if _, err := CreateObject(server, settings); err != nil {
return nil, err
}
}
for _, inbound := range config.Inbound {
rawHandler, err := server.CreateObject(inbound)
rawHandler, err := CreateObject(server, inbound)
if err != nil {
return nil, err
}
@@ -73,7 +74,7 @@ func New(config *Config) (*Instance, error) {
}
for _, outbound := range config.Outbound {
rawHandler, err := server.CreateObject(outbound)
rawHandler, err := CreateObject(server, outbound)
if err != nil {
return nil, err
}
@@ -89,11 +90,6 @@ func New(config *Config) (*Instance, error) {
return server, nil
}
func (s *Instance) CreateObject(config interface{}) (interface{}, error) {
ctx := context.WithValue(context.Background(), v2rayKey, s)
return common.CreateObject(ctx, config)
}
// ID returns a unique ID for this V2Ray instance.
func (s *Instance) ID() uuid.UUID {
return s.id
@@ -105,8 +101,15 @@ func (s *Instance) Close() error {
defer s.access.Unlock()
s.running = false
var errors []interface{}
for _, f := range s.allFeatures() {
f.Close()
if err := f.Close(); err != nil {
errors = append(errors, err)
}
}
if len(errors) > 0 {
return newError("failed to close all features").Base(newError(serial.Concat(errors...)))
}
return nil