remove use of any

This commit is contained in:
Darien Raymond committed 2016-10-16 14:22:21 +02:00
1 parent 5d9e6b0799
commit e33b7df34c
72 files changed
+728 -792

No files matched your search

+1 -1
View File
@@ -22,7 +22,7 @@ func (this *VMessInboundHandler) generateCommand(request *protocol.RequestHeader
if user == nil {
return nil
}
account, _ := user.GetTypedAccount(&vmess.Account{})
account, _ := user.GetTypedAccount()
return &protocol.CommandSwitchAccount{
Port: inboundHandler.Port(),
ID: account.(*vmess.InternalAccount).ID.UUID(),
+2 -15
View File
@@ -6,13 +6,9 @@ import (
"encoding/json"
"errors"
"v2ray.com/core/common"
"v2ray.com/core/common/log"
"v2ray.com/core/common/loader"
"v2ray.com/core/common/protocol"
"v2ray.com/core/proxy/registry"
"v2ray.com/core/proxy/vmess"
"github.com/golang/protobuf/ptypes"
)
func (this *DetourConfig) UnmarshalJSON(data []byte) error {
@@ -81,18 +77,9 @@ func (this *Config) UnmarshalJSON(data []byte) error {
if err := json.Unmarshal(rawData, account); err != nil {
return errors.New("VMess|Inbound: Invalid user: " + err.Error())
}
anyAccount, err := ptypes.MarshalAny(account)
if err != nil {
log.Error("VMess|Inbound: Failed to create account: ", err)
return common.ErrBadConfiguration
}
user.Account = anyAccount
user.Account = loader.NewTypedSettings(account)
this.User[idx] = user
}
return nil
}
func init() {
registry.RegisterInboundConfig("vmess", func() interface{} { return new(Config) })
}
+3 -5
View File
@@ -10,6 +10,7 @@ import (
"v2ray.com/core/common"
"v2ray.com/core/common/alloc"
v2io "v2ray.com/core/common/io"
"v2ray.com/core/common/loader"
"v2ray.com/core/common/log"
v2net "v2ray.com/core/common/net"
"v2ray.com/core/common/protocol"
@@ -20,8 +21,6 @@ import (
"v2ray.com/core/proxy/vmess/encoding"
vmessio "v2ray.com/core/proxy/vmess/io"
"v2ray.com/core/transport/internet"
"github.com/golang/protobuf/ptypes"
)
type userByEmail struct {
@@ -57,11 +56,10 @@ func (this *userByEmail) Get(email string) (*protocol.User, bool) {
Id: uuid.New().String(),
AlterId: uint32(this.defaultAlterIDs),
}
anyAccount, _ := ptypes.MarshalAny(account)
user = &protocol.User{
Level: this.defaultLevel,
Email: email,
Account: anyAccount,
Account: loader.NewTypedSettings(account),
}
this.cache[email] = user
}
@@ -282,5 +280,5 @@ func (this *Factory) Create(space app.Space, rawConfig interface{}, meta *proxy.
}
func init() {
registry.MustRegisterInboundHandlerCreator("vmess", new(Factory))
registry.MustRegisterInboundHandlerCreator(loader.GetType(new(Config)), new(Factory))
}