Send an empty packet to the probe

This seems to be required on Windows.

Also add the ability to wait for up to an hour.
This commit is contained in:
Frank Denis 2019-05-28 13:22:11 +02:00
parent da2e4b0b4b
commit 578c090890
2 changed files with 17 additions and 5 deletions

View File

@ -20,6 +20,10 @@ import (
netproxy "golang.org/x/net/proxy"
)
const (
MaxTimeout = 3600
)
type Config struct {
LogLevel int `toml:"log_level"`
LogFile *string `toml:"log_file"`
@ -539,13 +543,13 @@ func (config *Config) loadSource(proxy *Proxy, requiredProps stamps.ServerInform
source, sourceUrlsToPrefetch, err := NewSource(proxy.xTransport, cfgSource.URLs, cfgSource.MinisignKeyStr, cfgSource.CacheFile, cfgSource.FormatStr, time.Duration(cfgSource.RefreshDelay)*time.Hour)
proxy.urlsToPrefetch = append(proxy.urlsToPrefetch, sourceUrlsToPrefetch...)
if err != nil {
dlog.Criticalf("Unable to use source [%s]: [%s]", cfgSourceName, err)
return nil
dlog.Criticalf("Unable to retrieve source [%s]: [%s]", cfgSourceName, err)
return err
}
registeredServers, err := source.Parse(cfgSource.Prefix)
if err != nil {
dlog.Criticalf("Unable to use source [%s]: [%s]", cfgSourceName, err)
return nil
return err
}
for _, registeredServer := range registeredServers {
if len(config.ServerNames) > 0 {
@ -611,8 +615,16 @@ func netProbe(address string, timeout int) error {
return err
}
retried := false
if timeout < 0 {
timeout = MaxTimeout
} else {
timeout = Max(MaxTimeout, timeout)
}
for tries := timeout; tries > 0; tries-- {
pc, err := net.DialUDP("udp", nil, remoteUDPAddr)
if err == nil {
_, err = pc.Write([]byte{})
}
if err != nil {
if !retried {
retried = true

View File

@ -198,8 +198,8 @@ ignore_system_dns = false
## initializing the proxy.
## Useful if the proxy is automatically started at boot, and network
## connectivity is not guaranteed to be immediately available.
## Use 0 to disable.
## Use 0 to not test for connectivity at all,
## and -1 to wait as much as possible.
netprobe_timeout = 60