2018-04-12 09:41:07 +08:00
|
|
|
package torrent
|
|
|
|
|
2018-04-12 13:21:31 +08:00
|
|
|
import "strings"
|
|
|
|
|
2018-04-12 09:41:07 +08:00
|
|
|
type peerNetworks struct {
|
|
|
|
tcp4, tcp6 bool
|
|
|
|
utp4, utp6 bool
|
|
|
|
}
|
|
|
|
|
|
|
|
func handleErr(h func(), fs ...func() error) error {
|
|
|
|
for _, f := range fs {
|
|
|
|
err := f()
|
|
|
|
if err != nil {
|
|
|
|
h()
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
2018-04-12 13:21:31 +08:00
|
|
|
|
|
|
|
func LoopbackListenHost(network string) string {
|
|
|
|
if strings.Contains(network, "4") {
|
|
|
|
return "127.0.0.1"
|
|
|
|
} else {
|
|
|
|
return "::1"
|
|
|
|
}
|
|
|
|
}
|