Skip to content

Commit

Permalink
Merge branch 'develop' into fix/improve-windows-installer
Browse files Browse the repository at this point in the history
  • Loading branch information
mrpalide committed May 11, 2022
2 parents bc156b6 + fee9cad commit 7528870
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 17 deletions.
1 change: 0 additions & 1 deletion .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
5 changes: 1 addition & 4 deletions internal/gui/gui.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,8 @@ func GetOnGUIReady(icon []byte, conf *visorconfig.V1) func() {
logger := logging.NewMasterLogger()
logger.SetLevel(logrus.InfoLevel)

go func() {

}()

httpC := getHTTPClient(conf, context.Background(), logger)

if isRoot() {
return func() {
systray.SetTemplateIcon(icon, icon)
Expand Down
3 changes: 3 additions & 0 deletions internal/vpn/tun_device_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
10 changes: 5 additions & 5 deletions pkg/router/network_stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
Expand Down
12 changes: 7 additions & 5 deletions pkg/router/route_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()))
}

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions pkg/router/route_group_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -30,6 +31,7 @@ func TestRouteGroup_RemoteAddr(t *testing.T) {
}

func createRouteGroup(cfg *RouteGroupConfig) *RouteGroup {
l := logging.NewMasterLogger()
rt := routing.NewTable()

pk1, _ := cipher.GenerateKeyPair()
Expand All @@ -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
}

0 comments on commit 7528870

Please sign in to comment.