package iroh
import (
"net/netip"
"time"
"github.com/tmc/go-iroh/internal/netreport"
"github.com/tmc/go-iroh/netaddr"
)
const NetReportTimeout = 5 * time .Second
type NetReport struct {
UDPv4 bool
UDPv6 bool
MappingVariesByDestV4 *bool
MappingVariesByDestV6 *bool
PreferredRelay netaddr .RelayURL
RelayLatencies map [netaddr .RelayURL ]time .Duration
GlobalV4 netip .AddrPort
GlobalV6 netip .AddrPort
CaptivePortal *bool
}
func (r NetReport ) HasUDP () bool { return r .UDPv4 || r .UDPv6 }
func netReportFromInternal(r netreport .Report ) NetReport {
return NetReport {
UDPv4 : r .UDPv4 ,
UDPv6 : r .UDPv6 ,
MappingVariesByDestV4 : boolCopy (r .MappingVariesByDestV4 ),
MappingVariesByDestV6 : boolCopy (r .MappingVariesByDestV6 ),
PreferredRelay : r .PreferredRelay ,
RelayLatencies : cloneRelayLatencies (r .RelayLatency .Snapshot ()),
GlobalV4 : r .GlobalV4 ,
GlobalV6 : r .GlobalV6 ,
CaptivePortal : boolCopy (r .CaptivePortal ),
}
}
func (r NetReport ) clone () NetReport {
r .MappingVariesByDestV4 = boolCopy (r .MappingVariesByDestV4 )
r .MappingVariesByDestV6 = boolCopy (r .MappingVariesByDestV6 )
r .CaptivePortal = boolCopy (r .CaptivePortal )
r .RelayLatencies = cloneRelayLatencies (r .RelayLatencies )
return r
}
func boolCopy(p *bool ) *bool {
if p == nil {
return nil
}
v := *p
return &v
}
func cloneRelayLatencies(in map [netaddr .RelayURL ]time .Duration ) map [netaddr .RelayURL ]time .Duration {
if len (in ) == 0 {
return nil
}
out := make (map [netaddr .RelayURL ]time .Duration , len (in ))
for url , latency := range in {
out [url ] = latency
}
return out
}
The pages are generated with Golds v0.8.4 . (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu .
PR and bug reports are welcome and can be submitted to the issue list .
Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds .