mirror of
https://github.com/safing/portmaster.git
synced 2026-12-04 09:38:21 +00:00
0761ba7b1e
Portmaster pre-authenticated a randomly chosen local port for its own DNS queries before binding it. When the port could not be bound, for example because it lies in a Hyper-V excluded port range on Windows or is held by another process, the query failed and counted against the resolver. Plain DNS now binds a socket first, with a port chosen by the OS, and pre-authenticates that port before sending. DNS over TCP and TLS retry with another port when binding fails, and the failed port is skipped by port selection for an hour. A bind failure no longer counts against the resolver or the network state, as nothing left the host. Pre-authentication entries that were never consumed are removed again. Co-authored-by: DannyA <11684554+dannyagostinelli@users.noreply.github.com>
15 lines
406 B
Go
15 lines
406 B
Go
package netutils
|
|
|
|
import (
|
|
"errors"
|
|
"os"
|
|
)
|
|
|
|
// IsLocalBindError reports whether err is a failure to bind the local address
|
|
// of a socket. Nothing left the host in that case: the local port was not
|
|
// available, e.g. because it is in use or reserved by the OS.
|
|
func IsLocalBindError(err error) bool {
|
|
var syscallErr *os.SyscallError
|
|
return errors.As(err, &syscallErr) && syscallErr.Syscall == "bind"
|
|
}
|