diff --git a/.appveyor.yml b/.appveyor.yml index b0bb03bd5c..1cbaf9a0f7 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -49,7 +49,6 @@ for: install: - curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.44.2 - - sudo apt-get install gcc libgtk-3-dev libayatana-appindicator3-dev -y - make dep - sh: ci_scripts/create-ip-aliases.sh diff --git a/internal/vpn/tun_device_unix.go b/internal/vpn/tun_device_unix.go index ea77020b53..423f50a136 100644 --- a/internal/vpn/tun_device_unix.go +++ b/internal/vpn/tun_device_unix.go @@ -12,6 +12,9 @@ import ( func newTUNDevice() (TUNDevice, error) { tun, err := water.New(water.Config{ DeviceType: water.TUN, + PlatformSpecificParams: water.PlatformSpecificParams{ + Name: "utun4", + }, }) if err != nil { return nil, fmt.Errorf("error allocating TUN interface: %w", err) diff --git a/pkg/router/network_stats.go b/pkg/router/network_stats.go index 919975503b..62c84f5308 100644 --- a/pkg/router/network_stats.go +++ b/pkg/router/network_stats.go @@ -20,12 +20,12 @@ type networkStats struct { func newNetworkStats() *networkStats { return &networkStats{ - bandwidthReceivedRecStart: time.Now(), + bandwidthReceivedRecStart: time.Now().UTC(), } } -func (s *networkStats) SetLatency(latency time.Duration) { - atomic.StoreUint32(&s.latency, uint32(latency.Milliseconds())) +func (s *networkStats) SetLatency(latency uint32) { + atomic.StoreUint32(&s.latency, latency) } func (s *networkStats) Latency() time.Duration { @@ -69,8 +69,8 @@ func (s *networkStats) AddBandwidthReceived(amount uint64) { func (s *networkStats) RemoteThroughput() int64 { s.bandwidthReceivedRecStartMu.Lock() - timePassed := time.Since(s.bandwidthReceivedRecStart) - s.bandwidthReceivedRecStart = time.Now() + timePassed := time.Now().UTC().Sub(s.bandwidthReceivedRecStart) //nolint:gosimple + s.bandwidthReceivedRecStart = time.Now().UTC() s.bandwidthReceivedRecStartMu.Unlock() bandwidth := atomic.SwapUint64(&s.bandwidthReceived, 0) diff --git a/pkg/router/route_group.go b/pkg/router/route_group.go index f88da51678..280d3f4c07 100644 --- a/pkg/router/route_group.go +++ b/pkg/router/route_group.go @@ -362,7 +362,7 @@ func (rg *RouteGroup) writePacket(ctx context.Context, tp *transport.ManagedTran err := tp.WritePacket(ctx, packet) // note equality here. update activity only if there was NO error if err == nil { - if packet.Type() == routing.DataPacket { + if packet.Type() != routing.ClosePacket || packet.Type() != routing.HandshakePacket { rg.networkStats.AddBandwidthSent(uint64(packet.Size())) } @@ -425,8 +425,7 @@ func (rg *RouteGroup) sendNetworkProbe() error { } throughput := rg.networkStats.RemoteThroughput() - timestamp := time.Now().UnixNano() / int64(time.Millisecond) - + timestamp := time.Now().UTC().UnixNano() / int64(time.Millisecond) rg.networkStats.SetDownloadSpeed(uint32(throughput)) packet := routing.MakeNetworkProbePacket(rule.NextRouteID(), timestamp, throughput) @@ -610,9 +609,12 @@ func (rg *RouteGroup) handleNetworkProbePacket(packet routing.Packet) error { throughput := binary.BigEndian.Uint64(payload[8:]) ms := sentAtMs % 1000 - sentAt := time.Unix(int64(sentAtMs/1000), int64(ms)*int64(time.Millisecond)) + sentAt := time.Unix(int64(sentAtMs/1000), int64(ms)*int64(time.Millisecond)).UTC() + + latency := time.Now().UTC().Sub(sentAt).Milliseconds() + rg.logger.Debugf("Latency is around %d ms", latency) - rg.networkStats.SetLatency(time.Since(sentAt)) + rg.networkStats.SetLatency(uint32(latency)) rg.networkStats.SetUploadSpeed(uint32(throughput)) return nil diff --git a/pkg/router/route_group_test.go b/pkg/router/route_group_test.go index 11b9db29e1..8465ea6c0c 100644 --- a/pkg/router/route_group_test.go +++ b/pkg/router/route_group_test.go @@ -3,6 +3,7 @@ package router import ( "testing" + "github.com/skycoin/skycoin/src/util/logging" "github.com/stretchr/testify/require" "github.com/skycoin/skywire-utilities/pkg/cipher" @@ -30,6 +31,7 @@ func TestRouteGroup_RemoteAddr(t *testing.T) { } func createRouteGroup(cfg *RouteGroupConfig) *RouteGroup { + l := logging.NewMasterLogger() rt := routing.NewTable() pk1, _ := cipher.GenerateKeyPair() @@ -38,7 +40,6 @@ func createRouteGroup(cfg *RouteGroupConfig) *RouteGroup { port2 := routing.Port(2) desc := routing.NewRouteDescriptor(pk1, pk2, port1, port2) - rg := NewRouteGroup(cfg, rt, desc, nil) - + rg := NewRouteGroup(cfg, rt, desc, l) return rg }