mirror of
https://github.com/AdguardTeam/AdGuardHome.git
synced 2024-12-15 03:02:07 +03:00
784bc318ca
Merge in DNS/adguard-home from 3444-dhcp-again to master
Closes #3444.
Squashed commit of the following:
commit 5459ded7d58f219ab5417977e0df17c177c73a4a
Merge: d6559090 8e667d3c
Author: Eugene Burkov <e.burkov@adguard.com>
Date: Mon Aug 16 15:35:30 2021 +0300
Merge branch 'master' into 3444-dhcp-again
commit d6559090a21b6b13be6970a3839db1106fb539b8
Author: Eugene Burkov <e.burkov@adguard.com>
Date: Mon Aug 16 15:28:38 2021 +0300
aghnet: fix linux
commit 262f729224d73a70d61a4b29d5a4d34502b7b094
Author: Eugene Burkov <e.burkov@adguard.com>
Date: Mon Aug 16 14:30:09 2021 +0300
aghnet: rm debug
commit c54b107264f792ec7f17f8d790908408070307d3
Author: Eugene Burkov <e.burkov@adguard.com>
Date: Mon Aug 16 14:21:07 2021 +0300
aghnet: imp bsd compat, fix openbsd static ip
commit f9871a4c51d1f5d2c799a8d1308a4d30a47485f6
Author: Eugene Burkov <e.burkov@adguard.com>
Date: Sat Aug 14 00:17:46 2021 +0300
aghnet: setsockopt
44 lines
973 B
Go
44 lines
973 B
Go
//go:build openbsd
|
|
// +build openbsd
|
|
|
|
package aghnet
|
|
|
|
import (
|
|
"bufio"
|
|
"fmt"
|
|
"io"
|
|
"net"
|
|
"strings"
|
|
|
|
"github.com/AdguardTeam/AdGuardHome/internal/aghos"
|
|
)
|
|
|
|
func canBindPrivilegedPorts() (can bool, err error) {
|
|
return aghos.HaveAdminRights()
|
|
}
|
|
|
|
func ifaceHasStaticIP(ifaceName string) (ok bool, err error) {
|
|
filename := fmt.Sprintf("/etc/hostname.%s", ifaceName)
|
|
|
|
return aghos.FileWalker(hostnameIfStaticConfig).Walk(filename)
|
|
}
|
|
|
|
// hostnameIfStaticConfig checks if the interface is configured by
|
|
// /etc/hostname.* to have a static IP.
|
|
func hostnameIfStaticConfig(r io.Reader) (_ []string, ok bool, err error) {
|
|
s := bufio.NewScanner(r)
|
|
for s.Scan() {
|
|
line := strings.TrimSpace(s.Text())
|
|
fields := strings.Fields(line)
|
|
if len(fields) >= 2 && fields[0] == "inet" && net.ParseIP(fields[1]) != nil {
|
|
return nil, false, s.Err()
|
|
}
|
|
}
|
|
|
|
return nil, true, s.Err()
|
|
}
|
|
|
|
func ifaceSetStaticIP(string) (err error) {
|
|
return aghos.Unsupported("setting static ip")
|
|
}
|