-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.go
46 lines (38 loc) · 942 Bytes
/
config.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package socks
import (
v2net "v2ray.com/core/common/net"
"v2ray.com/core/common/protocol"
"github.com/golang/protobuf/ptypes"
google_protobuf "github.com/golang/protobuf/ptypes/any"
)
func (v *Account) Equals(another protocol.Account) bool {
if account, ok := another.(*Account); ok {
return v.Username == account.Username
}
return false
}
func (v *Account) AsAccount() (protocol.Account, error) {
return v, nil
}
func NewAccount() protocol.AsAccount {
return &Account{}
}
func (v *Account) AsAny() (*google_protobuf.Any, error) {
return ptypes.MarshalAny(v)
}
func (v *ServerConfig) HasAccount(username, password string) bool {
if v.Accounts == nil {
return false
}
storedPassed, found := v.Accounts[username]
if !found {
return false
}
return storedPassed == password
}
func (v *ServerConfig) GetNetAddress() v2net.Address {
if v.Address == nil {
return v2net.LocalHostIP
}
return v.Address.AsAddress()
}