feat: use github.com/wlynxg/anet instead of net
See https://github.com/golang/go/issues/40569
This commit is contained in:
parent
2fbc7186c0
commit
6aec6da078
|
@ -39,6 +39,7 @@ import (
|
|||
"github.com/lestrrat-go/jwx/v2/jwk"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/urfave/cli/v2"
|
||||
"github.com/wlynxg/anet"
|
||||
|
||||
_ "embed"
|
||||
|
||||
|
@ -360,13 +361,13 @@ func findMatchingDeviceAddress(ctx context.Context, from string, defaultAddr str
|
|||
return defaultAddr, nil
|
||||
}
|
||||
|
||||
ifaces, err := net.Interfaces()
|
||||
ifaces, err := anet.Interfaces()
|
||||
if err != nil {
|
||||
return "", errors.WithStack(err)
|
||||
}
|
||||
|
||||
for _, ifa := range ifaces {
|
||||
addrs, err := ifa.Addrs()
|
||||
addrs, err := anet.InterfaceAddrsByInterface(&ifa)
|
||||
if err != nil {
|
||||
logger.Error(
|
||||
ctx, "could not retrieve iface adresses",
|
||||
|
|
2
go.mod
2
go.mod
|
@ -16,6 +16,7 @@ require (
|
|||
github.com/lestrrat-go/jwx/v2 v2.0.8
|
||||
github.com/mitchellh/hashstructure/v2 v2.0.2
|
||||
github.com/ulikunitz/xz v0.5.11
|
||||
github.com/wlynxg/anet v0.0.1
|
||||
go.uber.org/goleak v1.3.0
|
||||
modernc.org/sqlite v1.20.4
|
||||
)
|
||||
|
@ -43,7 +44,6 @@ require (
|
|||
github.com/muesli/reflow v0.3.0 // indirect
|
||||
github.com/muesli/termenv v0.15.2 // indirect
|
||||
github.com/rivo/uniseg v0.4.4 // indirect
|
||||
github.com/wlynxg/anet v0.0.1 // indirect
|
||||
go.opentelemetry.io/otel v1.21.0 // indirect
|
||||
go.opentelemetry.io/otel/trace v1.21.0 // indirect
|
||||
golang.org/x/sync v0.5.0 // indirect
|
||||
|
|
|
@ -3,8 +3,6 @@ package chromecast
|
|||
import (
|
||||
"context"
|
||||
"net"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
@ -15,6 +13,7 @@ import (
|
|||
"github.com/barnybug/go-cast/log"
|
||||
"github.com/hashicorp/mdns"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/wlynxg/anet"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -151,28 +150,11 @@ func (d *Discovery) listener(ctx context.Context) {
|
|||
case d.found <- client:
|
||||
case <-time.After(time.Second):
|
||||
case <-ctx.Done():
|
||||
break
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func decodeDnsEntry(text string) string {
|
||||
text = strings.Replace(text, `\.`, ".", -1)
|
||||
text = strings.Replace(text, `\ `, " ", -1)
|
||||
|
||||
re := regexp.MustCompile(`([\\][0-9][0-9][0-9])`)
|
||||
text = re.ReplaceAllStringFunc(text, func(source string) string {
|
||||
i, err := strconv.Atoi(source[1:])
|
||||
if err != nil {
|
||||
return ""
|
||||
}
|
||||
|
||||
return string([]byte{byte(i)})
|
||||
})
|
||||
|
||||
return text
|
||||
}
|
||||
|
||||
func decodeTxtRecord(txt string) map[string]string {
|
||||
m := make(map[string]string)
|
||||
|
||||
|
@ -196,7 +178,7 @@ func isIPv6(ip net.IP) bool {
|
|||
}
|
||||
|
||||
func findMulticastInterfaces(ctx context.Context) ([]net.Interface, error) {
|
||||
ifaces, err := net.Interfaces()
|
||||
ifaces, err := anet.Interfaces()
|
||||
if err != nil {
|
||||
return nil, nil
|
||||
}
|
||||
|
@ -223,7 +205,7 @@ func findMulticastInterfaces(ctx context.Context) ([]net.Interface, error) {
|
|||
}
|
||||
|
||||
func retrieveSupportedProtocols(iface net.Interface) (bool, bool, error) {
|
||||
adresses, err := iface.Addrs()
|
||||
adresses, err := anet.InterfaceAddrsByInterface(&iface)
|
||||
if err != nil {
|
||||
return false, false, errors.WithStack(err)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue