mirror of https://github.com/v2ray/v2ray-core
refactor
parent
1c2b6d9536
commit
7392bb495b
|
@ -2,18 +2,12 @@ package protocol
|
|||
|
||||
import "time"
|
||||
|
||||
var (
|
||||
ErrAccountMissing = newError("Account is not specified.")
|
||||
ErrNonMessageType = newError("Not a protobuf message.")
|
||||
ErrUnknownAccountType = newError("Unknown account type.")
|
||||
)
|
||||
|
||||
func (v *User) GetTypedAccount() (Account, error) {
|
||||
if v.GetAccount() == nil {
|
||||
return nil, ErrAccountMissing
|
||||
func (u *User) GetTypedAccount() (Account, error) {
|
||||
if u.GetAccount() == nil {
|
||||
return nil, newError("Account missing").AtWarning()
|
||||
}
|
||||
|
||||
rawAccount, err := v.Account.GetInstance()
|
||||
rawAccount, err := u.Account.GetInstance()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -23,12 +17,12 @@ func (v *User) GetTypedAccount() (Account, error) {
|
|||
if account, ok := rawAccount.(Account); ok {
|
||||
return account, nil
|
||||
}
|
||||
return nil, newError("Unknown account type: ", v.Account.Type)
|
||||
return nil, newError("Unknown account type: ", u.Account.Type)
|
||||
}
|
||||
|
||||
func (v *User) GetSettings() UserSettings {
|
||||
func (u *User) GetSettings() UserSettings {
|
||||
settings := UserSettings{}
|
||||
switch v.Level {
|
||||
switch u.Level {
|
||||
case 0:
|
||||
settings.PayloadTimeout = time.Second * 30
|
||||
case 1:
|
||||
|
|
Loading…
Reference in New Issue