From 52cf52b7403a5d055ce93ddeaa6e22bdc7cfcebf Mon Sep 17 00:00:00 2001 From: Sir Darkrengarius Date: Thu, 4 Feb 2021 13:39:10 +0300 Subject: [PATCH 1/4] Add debug logs --- pkg/visor/hypervisor.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pkg/visor/hypervisor.go b/pkg/visor/hypervisor.go index a89364dbce..2b6bd2010e 100644 --- a/pkg/visor/hypervisor.go +++ b/pkg/visor/hypervisor.go @@ -394,18 +394,24 @@ func (hv *Hypervisor) getVisors() http.HandlerFunc { wg := new(sync.WaitGroup) wg.Add(len(hv.visors)) + log.Infof("ADDING TO WG %d", len(hv.visors)) + i := 0 if hv.visor != nil { i++ } + log.Infof("CREATING %d SUMMARIES", len(hv.visors)+i) summaries := make([]summaryResp, len(hv.visors)+i) if hv.visor != nil { + log.Infoln("GETTING SUMMARY FOR LOCAL VISOR") summary, err := hv.visor.Summary() if err != nil { log.WithError(err).Warn("Failed to obtain summary of this visor.") summary = &Summary{PubKey: hv.visor.conf.PK} + } else { + log.Infoln("GOT LOCAL VISOR SUMMARY") } addr := dmsg.Addr{PK: hv.c.PK, Port: hv.c.DmsgPort} @@ -442,7 +448,9 @@ func (hv *Hypervisor) getVisors() http.HandlerFunc { i++ } + log.Infoln("WAITING FOR ROUTINES") wg.Wait() + log.Infoln("ROUTINES DONE") hv.mu.RUnlock() httputil.WriteJSON(w, r, http.StatusOK, summaries) From 0477cfba101e93a016686c07aacd8184d7eba457 Mon Sep 17 00:00:00 2001 From: Sir Darkrengarius Date: Thu, 4 Feb 2021 20:31:31 +0300 Subject: [PATCH 2/4] Properly pass uptime tracker IP to VPN client --- internal/vpn/client.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/internal/vpn/client.go b/internal/vpn/client.go index b3327068bf..bb57b8bb50 100644 --- a/internal/vpn/client.go +++ b/internal/vpn/client.go @@ -78,6 +78,11 @@ func NewClient(cfg ClientConfig, appCl *app.Client) (*Client, error) { return nil, fmt.Errorf("error getting RF IP: %w", err) } + utIP, err := uptimeTrackerIPFromEnv() + if err != nil { + return nil, fmt.Errorf("error getting UT IP: %w") + } + stcpEntities, err := stcpEntitiesFromEnv() if err != nil { return nil, fmt.Errorf("error getting STCP entities: %w", err) @@ -99,6 +104,10 @@ func NewClient(cfg ClientConfig, appCl *app.Client) (*Client, error) { directIPs = append(directIPs, arIP) } + if utIP != nil { + directIPs = append(directIPs, utIP) + } + const ( serverDialInitBO = 1 * time.Second serverDialMaxBO = 10 * time.Second @@ -552,6 +561,10 @@ func rfIPFromEnv() (net.IP, error) { return ipFromEnv(RFAddrEnvKey) } +func uptimeTrackerIPFromEnv() (net.IP, error) { + return ipFromEnv(UptimeTrackerAddrEnvKey) +} + func tpRemoteIPsFromEnv() ([]net.IP, error) { var ips []net.IP ipsLenStr := os.Getenv(TPRemoteIPsLenEnvKey) From 769111a1cc60efd79bb97e3a6ab77ccd350cf0a8 Mon Sep 17 00:00:00 2001 From: Sir Darkrengarius Date: Thu, 4 Feb 2021 20:35:37 +0300 Subject: [PATCH 3/4] Remove debug logs --- pkg/visor/hypervisor.go | 8 -------- 1 file changed, 8 deletions(-) diff --git a/pkg/visor/hypervisor.go b/pkg/visor/hypervisor.go index 2b6bd2010e..a89364dbce 100644 --- a/pkg/visor/hypervisor.go +++ b/pkg/visor/hypervisor.go @@ -394,24 +394,18 @@ func (hv *Hypervisor) getVisors() http.HandlerFunc { wg := new(sync.WaitGroup) wg.Add(len(hv.visors)) - log.Infof("ADDING TO WG %d", len(hv.visors)) - i := 0 if hv.visor != nil { i++ } - log.Infof("CREATING %d SUMMARIES", len(hv.visors)+i) summaries := make([]summaryResp, len(hv.visors)+i) if hv.visor != nil { - log.Infoln("GETTING SUMMARY FOR LOCAL VISOR") summary, err := hv.visor.Summary() if err != nil { log.WithError(err).Warn("Failed to obtain summary of this visor.") summary = &Summary{PubKey: hv.visor.conf.PK} - } else { - log.Infoln("GOT LOCAL VISOR SUMMARY") } addr := dmsg.Addr{PK: hv.c.PK, Port: hv.c.DmsgPort} @@ -448,9 +442,7 @@ func (hv *Hypervisor) getVisors() http.HandlerFunc { i++ } - log.Infoln("WAITING FOR ROUTINES") wg.Wait() - log.Infoln("ROUTINES DONE") hv.mu.RUnlock() httputil.WriteJSON(w, r, http.StatusOK, summaries) From adc84fd983e12dc677fb925e8a82680815d02a89 Mon Sep 17 00:00:00 2001 From: Erich Kaestner <36450093+jdknives@users.noreply.github.com> Date: Thu, 4 Feb 2021 14:49:29 -0300 Subject: [PATCH 4/4] fix linter --- internal/vpn/client.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/vpn/client.go b/internal/vpn/client.go index bb57b8bb50..675bbac269 100644 --- a/internal/vpn/client.go +++ b/internal/vpn/client.go @@ -80,7 +80,7 @@ func NewClient(cfg ClientConfig, appCl *app.Client) (*Client, error) { utIP, err := uptimeTrackerIPFromEnv() if err != nil { - return nil, fmt.Errorf("error getting UT IP: %w") + return nil, fmt.Errorf("error getting UT IP: %w", err) } stcpEntities, err := stcpEntitiesFromEnv()