Documentation
¶
Overview ¶
Package util contains various utilities.
TODO(a.garipov): Such packages are widely considered an antipattern. Remove this when we refactor our project structure.
Index ¶
- func CanBindPort(port int) (bool, error)
- func CheckPacketPortAvailable(host net.IP, port int) error
- func CheckPortAvailable(host net.IP, port int) error
- func ContainsString(strs []string, str string) bool
- func DNSUnreverseAddr(s string) net.IP
- func ErrorIsAddrInUse(err error) bool
- func FileExists(fn string) bool
- func GetInterfaceByIP(ip net.IP) string
- func GetSubnet(ifaceName string) *net.IPNet
- func GetValidNetInterfaces() ([]net.Interface, error)
- func InitTLSCiphers() []uint16
- func IsOpenWRT() bool
- func LoadSystemRootCAs() *x509.CertPool
- func RunCommand(command string, arguments ...string) (int, string, error)
- func SplitNext(str *string, splitBy byte) string
- type AutoHosts
- func (a *AutoHosts) Close()
- func (a *AutoHosts) Init(hostsFn string)
- func (a *AutoHosts) List() (ipToHosts map[string][]string)
- func (a *AutoHosts) Process(host string, qtype uint16) []net.IP
- func (a *AutoHosts) ProcessReverse(addr string, qtype uint16) (hosts []string)
- func (a *AutoHosts) SetOnChanged(onChanged onChangedT)
- func (a *AutoHosts) Start()
- type NetInterface
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CanBindPort ¶
CanBindPort - checks if we can bind to this port or not
func CheckPacketPortAvailable ¶
CheckPacketPortAvailable - check if UDP port is available
func CheckPortAvailable ¶
CheckPortAvailable - check if TCP port is available
func ContainsString ¶
ContainsString checks if string is in the slice of strings.
func DNSUnreverseAddr ¶
DNSUnreverseAddr - convert reversed ARPA address to a normal IP address
func ErrorIsAddrInUse ¶
ErrorIsAddrInUse - check if error is "address already in use"
func GetInterfaceByIP ¶
GetInterfaceByIP returns the name of interface containing provided ip.
func GetSubnet ¶
GetSubnet returns pointer to net.IPNet for the specified interface or nil if the search fails.
func GetValidNetInterfaces ¶
GetValidNetInterfaces returns interfaces that are eligible for DNS and/or DHCP invalid interface is a ppp interface or the one that doesn't allow broadcasts
func InitTLSCiphers ¶
func InitTLSCiphers() []uint16
InitTLSCiphers - the same as initDefaultCipherSuites() from src/crypto/tls/common.go
but with the difference that we don't use so many other default ciphers.
func LoadSystemRootCAs ¶
LoadSystemRootCAs - load root CAs from the system Return the x509 certificate pool object Return nil if nothing has been found.
This means that Go.crypto will use its default algorithm to find system root CA list.
https://github.com/AdguardTeam/AdGuardHome/internal/issues/1311
func RunCommand ¶
RunCommand runs shell command.
Types ¶
type AutoHosts ¶
type AutoHosts struct {
// contains filtered or unexported fields
}
AutoHosts - automatic DNS records
func (*AutoHosts) Init ¶
Init - initialize hostsFn: Override default name for the hosts-file (optional)
func (*AutoHosts) Process ¶
Process returns the list of IP addresses for the hostname or nil if nothing found.
func (*AutoHosts) ProcessReverse ¶
ProcessReverse processes a PTR request. It returns nil if nothing is found.
func (*AutoHosts) SetOnChanged ¶
func (a *AutoHosts) SetOnChanged(onChanged onChangedT)
SetOnChanged - set callback function that will be called when the data is changed
type NetInterface ¶
type NetInterface struct { MTU int `json:"mtu"` Name string `json:"name"` HardwareAddr net.HardwareAddr `json:"hardware_address"` Flags net.Flags `json:"flags"` // Array with the network interface addresses. Addresses []net.IP `json:"ip_addresses,omitempty"` // Array with IP networks for this network interface. Subnets []*net.IPNet `json:"-"` }
NetInterface represents an entry of network interfaces map.
func GetValidNetInterfacesForWeb ¶
func GetValidNetInterfacesForWeb() ([]*NetInterface, error)
GetValidNetInterfacesForWeb returns interfaces that are eligible for DNS and WEB only we do not return link-local addresses here
func (*NetInterface) MarshalJSON ¶ added in v0.105.0
func (iface *NetInterface) MarshalJSON() ([]byte, error)
MarshalJSON implements the json.Marshaler interface for *NetInterface.