1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-11-02 17:27:50 -04:00
v2fly/proxy/socks/config.go
2016-11-27 21:39:09 +01:00

47 lines
942 B
Go

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()
}