mirror of
https://github.com/DNSCrypt/dnscrypt-proxy.git
synced 2025-04-04 13:47:39 +03:00
Support relays in static entries
This commit is contained in:
parent
7f46f4820c
commit
a384011e71
2 changed files with 16 additions and 2 deletions
|
@ -766,6 +766,15 @@ func (config *Config) loadSources(proxy *Proxy) error {
|
|||
return err
|
||||
}
|
||||
}
|
||||
for name, config := range config.StaticsConfig {
|
||||
if stamp, err := stamps.NewServerStampFromString(config.Stamp); err == nil {
|
||||
if stamp.Proto == stamps.StampProtoTypeDNSCryptRelay || stamp.Proto == stamps.StampProtoTypeODoHRelay {
|
||||
dlog.Debugf("Adding [%s] to the set of available static relays", name)
|
||||
registeredServer := RegisteredServer{name: name, stamp: stamp, description: "static relay"}
|
||||
proxy.registeredRelays = append(proxy.registeredRelays, registeredServer)
|
||||
}
|
||||
}
|
||||
}
|
||||
if len(config.ServerNames) == 0 {
|
||||
for serverName := range config.StaticsConfig {
|
||||
config.ServerNames = append(config.ServerNames, serverName)
|
||||
|
@ -830,7 +839,7 @@ func (config *Config) loadSource(proxy *Proxy, requiredProps stamps.ServerInform
|
|||
dlog.Warnf("Error in source [%s]: [%s] -- Continuing with reduced server count [%d]", cfgSourceName, err, len(registeredServers))
|
||||
}
|
||||
for _, registeredServer := range registeredServers {
|
||||
if registeredServer.stamp.Proto != stamps.StampProtoTypeDNSCryptRelay {
|
||||
if registeredServer.stamp.Proto != stamps.StampProtoTypeDNSCryptRelay && registeredServer.stamp.Proto != stamps.StampProtoTypeODoHRelay {
|
||||
if len(config.ServerNames) > 0 {
|
||||
if !includesName(config.ServerNames, registeredServer.name) {
|
||||
continue
|
||||
|
@ -854,7 +863,7 @@ func (config *Config) loadSource(proxy *Proxy, requiredProps stamps.ServerInform
|
|||
continue
|
||||
}
|
||||
}
|
||||
if registeredServer.stamp.Proto == stamps.StampProtoTypeDNSCryptRelay {
|
||||
if registeredServer.stamp.Proto == stamps.StampProtoTypeDNSCryptRelay || registeredServer.stamp.Proto == stamps.StampProtoTypeODoHRelay {
|
||||
dlog.Debugf("Adding [%s] to the set of available relays", registeredServer.name)
|
||||
proxy.registeredRelays = append(proxy.registeredRelays, registeredServer)
|
||||
} else {
|
||||
|
|
|
@ -99,6 +99,8 @@ func (LBStrategyRandom) getCandidate(serversCount int) int {
|
|||
|
||||
var DefaultLBStrategy = LBStrategyP2{}
|
||||
|
||||
type ODoHRelay struct{}
|
||||
|
||||
type DNSCryptRelay struct {
|
||||
RelayUDPAddr *net.UDPAddr
|
||||
RelayTCPAddr *net.TCPAddr
|
||||
|
@ -311,6 +313,9 @@ func route(proxy *Proxy, name string) (*Relay, error) {
|
|||
return nil, err
|
||||
}
|
||||
return &Relay{Proto: stamps.StampProtoTypeDNSCryptRelay, Dnscrypt: &DNSCryptRelay{RelayUDPAddr: relayUDPAddr, RelayTCPAddr: relayTCPAddr}}, nil
|
||||
case stamps.StampProtoTypeODoHRelay:
|
||||
dlog.Debugf("Ignoring relay [%v]: ODoH relays are currently unsupported", relayName)
|
||||
return nil, nil
|
||||
}
|
||||
return nil, fmt.Errorf("Invalid relay [%v] for server [%v]", relayName, name)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue