2016-01-15 06:43:06 -05:00
|
|
|
package socks
|
|
|
|
|
|
|
|
import (
|
2016-08-20 14:55:45 -04:00
|
|
|
v2net "v2ray.com/core/common/net"
|
2016-09-25 16:54:18 -04:00
|
|
|
"v2ray.com/core/common/protocol"
|
|
|
|
|
|
|
|
"github.com/golang/protobuf/ptypes"
|
|
|
|
google_protobuf "github.com/golang/protobuf/ptypes/any"
|
2016-01-15 06:43:06 -05:00
|
|
|
)
|
|
|
|
|
2016-09-25 16:54:18 -04:00
|
|
|
func (this *Account) Equals(another protocol.Account) bool {
|
|
|
|
if account, ok := another.(*Account); ok {
|
|
|
|
return this.Username == account.Username
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
func (this *Account) AsAccount() (protocol.Account, error) {
|
|
|
|
return this, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewAccount() protocol.AsAccount {
|
|
|
|
return &Account{}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (this *Account) AsAny() (*google_protobuf.Any, error) {
|
|
|
|
return ptypes.MarshalAny(this)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (this *ServerConfig) HasAccount(username, password string) bool {
|
|
|
|
if this.Accounts == nil {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
storedPassed, found := this.Accounts[username]
|
|
|
|
if !found {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
return storedPassed == password
|
|
|
|
}
|
|
|
|
|
|
|
|
func (this *ServerConfig) GetNetAddress() v2net.Address {
|
|
|
|
if this.Address == nil {
|
|
|
|
return v2net.LocalHostIP
|
|
|
|
}
|
|
|
|
return this.Address.AsAddress()
|
|
|
|
}
|