2016-01-15 11:43:06 +00:00
|
|
|
package socks
|
|
|
|
|
|
|
|
import (
|
2017-01-13 23:27:45 +00:00
|
|
|
"v2ray.com/core/common/net"
|
2016-09-25 20:54:18 +00:00
|
|
|
"v2ray.com/core/common/protocol"
|
2016-01-15 11:43:06 +00:00
|
|
|
)
|
|
|
|
|
2016-11-27 20:39:09 +00:00
|
|
|
func (v *Account) Equals(another protocol.Account) bool {
|
2016-09-25 20:54:18 +00:00
|
|
|
if account, ok := another.(*Account); ok {
|
2016-11-27 20:39:09 +00:00
|
|
|
return v.Username == account.Username
|
2016-09-25 20:54:18 +00:00
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2016-11-27 20:39:09 +00:00
|
|
|
func (v *Account) AsAccount() (protocol.Account, error) {
|
|
|
|
return v, nil
|
2016-09-25 20:54:18 +00:00
|
|
|
}
|
|
|
|
|
2016-11-27 20:39:09 +00:00
|
|
|
func (v *ServerConfig) HasAccount(username, password string) bool {
|
|
|
|
if v.Accounts == nil {
|
2016-09-25 20:54:18 +00:00
|
|
|
return false
|
|
|
|
}
|
2016-11-27 20:39:09 +00:00
|
|
|
storedPassed, found := v.Accounts[username]
|
2016-09-25 20:54:18 +00:00
|
|
|
if !found {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
return storedPassed == password
|
|
|
|
}
|
|
|
|
|
2017-01-13 23:27:45 +00:00
|
|
|
func (v *ServerConfig) GetNetAddress() net.Address {
|
2016-11-27 20:39:09 +00:00
|
|
|
if v.Address == nil {
|
2017-01-13 23:27:45 +00:00
|
|
|
return net.LocalHostIP
|
2016-09-25 20:54:18 +00:00
|
|
|
}
|
2016-11-27 20:39:09 +00:00
|
|
|
return v.Address.AsAddress()
|
2016-09-25 20:54:18 +00:00
|
|
|
}
|