diff --git a/CHANGELOG.md b/CHANGELOG.md index 3de4e84b8a..20bd499b88 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - remove transports cache from visor initialization and check them before make route - `run-source` makefile directive write config to stdout & read config from stdin - fixed skywire-visor uses skywire-config.json (default config name) without needing to specify +- changed the log levels of most of the logs making info level clutter free ### Added - added `add-rhv` and `disable-rhv` flags to `skywire-visor` for adding remote hypervisor PK and disable remote hypervisor PK(s) on config file @@ -53,6 +54,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - `run-vpnsrv-dmsghttp` makefile directive - `run-vpnsrv -dmsghttp-test` makefile directive - `install-system-linux` and `install-system-linux-systray` makefile directives +- `trace` log level is added ## 0.6.0 diff --git a/cmd/apps/skychat/skychat.go b/cmd/apps/skychat/skychat.go index b0fe5af836..ad6854f100 100644 --- a/cmd/apps/skychat/skychat.go +++ b/cmd/apps/skychat/skychat.go @@ -18,7 +18,6 @@ import ( "time" ipc "github.com/james-barrow/golang-ipc" - "github.com/skycoin/skycoin/src/util/logging" "github.com/skycoin/skywire-utilities/pkg/buildinfo" "github.com/skycoin/skywire-utilities/pkg/cipher" @@ -35,9 +34,8 @@ const ( port = routing.Port(1) ) -var log = logging.MustGetLogger("chat") var addr = flag.String("addr", ":8001", "address to bind") -var r = netutil.NewRetrier(log, 50*time.Millisecond, netutil.DefaultMaxBackoff, 5, 2) +var r = netutil.NewRetrier(nil, 50*time.Millisecond, netutil.DefaultMaxBackoff, 5, 2) var ( appCl *app.Client @@ -56,11 +54,11 @@ func main() { defer appCl.Close() if _, err := buildinfo.Get().WriteTo(os.Stdout); err != nil { - fmt.Printf("Failed to output build info: %v", err) + print(fmt.Sprintf("Failed to output build info: %v\n", err)) } flag.Parse() - fmt.Print("Successfully started skychat.") + fmt.Println("Successfully started skychat.") clientCh = make(chan string) defer close(clientCh) @@ -71,7 +69,7 @@ func main() { if runtime.GOOS == "windows" { ipcClient, err := ipc.StartClient(skyenv.SkychatName, nil) if err != nil { - fmt.Printf("Error creating ipc server for skychat client: %v\n", err) + print(fmt.Sprintf("Error creating ipc server for skychat client: %v\n", err)) setAppError(appCl, err) os.Exit(1) } @@ -84,13 +82,14 @@ func main() { http.HandleFunc("/message", messageHandler(ctx)) http.HandleFunc("/sse", sseHandler) - fmt.Print("Serving HTTP on", *addr) + fmt.Println("Serving HTTP on", *addr) setAppStatus(appCl, launcher.AppDetailedStatusRunning) err := http.ListenAndServe(*addr, nil) if err != nil { - fmt.Println(err) + print(err) + setAppError(appCl, err) os.Exit(1) } } @@ -98,18 +97,19 @@ func main() { func listenLoop() { l, err := appCl.Listen(netType, port) if err != nil { - fmt.Printf("Error listening network %v on port %d: %v\n", netType, port, err) + print(fmt.Sprintf("Error listening network %v on port %d: %v\n", netType, port, err)) + setAppError(appCl, err) return } for { - fmt.Print("Accepting skychat conn...") + fmt.Println("Accepting skychat conn...") conn, err := l.Accept() if err != nil { - fmt.Print("Failed to accept conn:", err) + print(fmt.Sprintf("Failed to accept conn: %v", err)) return } - fmt.Print("Accepted skychat conn") + fmt.Println("Accepted skychat conn") raddr := conn.RemoteAddr().(appnet.Addr) connsMu.Lock() @@ -127,7 +127,7 @@ func handleConn(conn net.Conn) { buf := make([]byte, 32*1024) n, err := conn.Read(buf) if err != nil { - fmt.Print("Failed to read packet:", err) + fmt.Println("Failed to read packet:", err) raddr := conn.RemoteAddr().(appnet.Addr) connsMu.Lock() delete(conns, raddr.PubKey) @@ -137,7 +137,7 @@ func handleConn(conn net.Conn) { clientMsg, err := json.Marshal(map[string]string{"sender": raddr.PubKey.Hex(), "message": string(buf[:n])}) if err != nil { - fmt.Printf("Failed to marshal json: %v", err) + print(fmt.Sprintf("Failed to marshal json: %v\n", err)) } select { case clientCh <- string(clientMsg): @@ -255,12 +255,12 @@ func handleIPCSignal(client *ipc.Client) { func setAppStatus(appCl *app.Client, status launcher.AppDetailedStatus) { if err := appCl.SetDetailedStatus(string(status)); err != nil { - fmt.Printf("Failed to set status %v: %v\n", status, err) + print(fmt.Sprintf("Failed to set status %v: %v\n", status, err)) } } func setAppError(appCl *app.Client, appErr error) { if err := appCl.SetError(appErr.Error()); err != nil { - fmt.Printf("Failed to set error %v: %v\n", appErr, err) + print(fmt.Sprintf("Failed to set error %v: %v\n", appErr, err)) } } diff --git a/cmd/apps/skysocks-client/skysocks-client.go b/cmd/apps/skysocks-client/skysocks-client.go index e6d10298e0..a5ec435a86 100644 --- a/cmd/apps/skysocks-client/skysocks-client.go +++ b/cmd/apps/skysocks-client/skysocks-client.go @@ -5,20 +5,21 @@ package main import ( "context" + "errors" "flag" + "fmt" "io" "net" "os" "time" - "github.com/skycoin/skycoin/src/util/logging" - "github.com/skycoin/skywire-utilities/pkg/buildinfo" "github.com/skycoin/skywire-utilities/pkg/cipher" "github.com/skycoin/skywire-utilities/pkg/netutil" "github.com/skycoin/skywire/internal/skysocks" "github.com/skycoin/skywire/pkg/app" "github.com/skycoin/skywire/pkg/app/appnet" + "github.com/skycoin/skywire/pkg/app/launcher" "github.com/skycoin/skywire/pkg/routing" "github.com/skycoin/skywire/pkg/skyenv" ) @@ -28,9 +29,7 @@ const ( socksPort = routing.Port(3) ) -var log = logging.MustGetLogger("skysocks-client") - -var r = netutil.NewRetrier(log, time.Second, netutil.DefaultMaxBackoff, 0, 1) +var r = netutil.NewRetrier(nil, time.Second, netutil.DefaultMaxBackoff, 0, 1) func dialServer(ctx context.Context, appCl *app.Client, pk cipher.PubKey) (net.Conn, error) { var conn net.Conn @@ -54,13 +53,11 @@ func main() { appCl := app.NewClient(nil) defer appCl.Close() - skysocks.Log = log - ctx, cancel := context.WithCancel(context.Background()) defer cancel() if _, err := buildinfo.Get().WriteTo(os.Stdout); err != nil { - log.Printf("Failed to output build info: %v", err) + print(fmt.Sprintf("Failed to output build info: %v\n", err)) } var addr = flag.String("addr", skyenv.SkysocksClientAddr, "Client address to listen on") @@ -68,39 +65,60 @@ func main() { flag.Parse() if *serverPK == "" { - log.Warn("Empty server PubKey. Exiting") + err := errors.New("Empty server PubKey. Exiting") + print(err) + setAppErr(appCl, err) return } pk := cipher.PubKey{} if err := pk.UnmarshalText([]byte(*serverPK)); err != nil { - log.Fatal("Invalid server PubKey: ", err) + print(fmt.Sprintf("Invalid server PubKey: %v\n", err)) + setAppErr(appCl, err) + os.Exit(1) } for { conn, err := dialServer(ctx, appCl, pk) if err != nil { - log.Fatalf("Failed to dial to a server: %v", err) + print(fmt.Sprintf("Failed to dial to a server: %v\n", err)) + setAppErr(appCl, err) + os.Exit(1) } - log.Printf("Connected to %v\n", pk) + fmt.Printf("Connected to %v\n", pk) client, err := skysocks.NewClient(conn, appCl) if err != nil { - log.Fatal("Failed to create a new client: ", err) + print(fmt.Sprintf("Failed to create a new client: %v\n", err)) + setAppErr(appCl, err) + os.Exit(1) } - log.Printf("Serving proxy client %v\n", *addr) + fmt.Printf("Serving proxy client %v\n", *addr) if err := client.ListenAndServe(*addr); err != nil { - log.Errorf("Error serving proxy client: %v\n", err) + print(fmt.Sprintf("Error serving proxy client: %v\n", err)) } // need to filter this out, cause usually client failure means app conn is already closed if err := conn.Close(); err != nil && err != io.ErrClosedPipe { - log.Errorf("Error closing app conn: %v\n", err) + print(fmt.Sprintf("Error closing app conn: %v\n", err)) } - log.Println("Reconnecting to skysocks server") + fmt.Println("Reconnecting to skysocks server") + setAppStatus(appCl, launcher.AppDetailedStatusReconnecting) + } +} + +func setAppErr(appCl *app.Client, err error) { + if appErr := appCl.SetError(err.Error()); appErr != nil { + fmt.Printf("Failed to set error %v: %v\n", err, appErr) + } +} + +func setAppStatus(appCl *app.Client, status launcher.AppDetailedStatus) { + if err := appCl.SetDetailedStatus(string(status)); err != nil { + fmt.Printf("Failed to set status %v: %v\n", status, err) } } diff --git a/cmd/apps/skysocks/skysocks.go b/cmd/apps/skysocks/skysocks.go index faaebc19a2..76a524da84 100644 --- a/cmd/apps/skysocks/skysocks.go +++ b/cmd/apps/skysocks/skysocks.go @@ -6,12 +6,12 @@ package main import ( "flag" "fmt" + "log" "os" "os/signal" "runtime" ipc "github.com/james-barrow/golang-ipc" - "github.com/sirupsen/logrus" "github.com/skycoin/skywire-utilities/pkg/buildinfo" "github.com/skycoin/skywire/internal/skysocks" @@ -26,14 +26,10 @@ const ( port routing.Port = 3 ) -var log = logrus.New() - func main() { appCl := app.NewClient(nil) defer appCl.Close() - skysocks.Log = log - if _, err := buildinfo.Get().WriteTo(os.Stdout); err != nil { fmt.Printf("Failed to output build info: %v", err) } @@ -41,7 +37,7 @@ func main() { var passcode = flag.String("passcode", "", "Authorize user against this passcode") flag.Parse() - srv, err := skysocks.NewServer(*passcode, appCl, log) + srv, err := skysocks.NewServer(*passcode, appCl) if err != nil { log.Fatal("Failed to create a new server: ", err) } diff --git a/cmd/apps/vpn-client/vpn-client.go b/cmd/apps/vpn-client/vpn-client.go index 7cc9499f37..0bc19cf875 100644 --- a/cmd/apps/vpn-client/vpn-client.go +++ b/cmd/apps/vpn-client/vpn-client.go @@ -1,6 +1,7 @@ package main import ( + "errors" "flag" "fmt" "net" @@ -11,6 +12,7 @@ import ( ipc "github.com/james-barrow/golang-ipc" + "github.com/skycoin/skywire-utilities/pkg/buildinfo" "github.com/skycoin/skywire-utilities/pkg/cipher" "github.com/skycoin/skywire/internal/vpn" "github.com/skycoin/skywire/pkg/app" @@ -29,35 +31,6 @@ var ( func main() { flag.Parse() - if *serverPKStr == "" { - // TODO(darkrengarius): fix args passage for Windows - //*serverPKStr = "03e9019b3caa021dbee1c23e6295c6034ab4623aec50802fcfdd19764568e2958d" - fmt.Println("VPN server pub key is missing") - os.Exit(1) - } - - serverPK := cipher.PubKey{} - if err := serverPK.UnmarshalText([]byte(*serverPKStr)); err != nil { - fmt.Printf("Invalid VPN server pub key: %v\n", err) - os.Exit(1) - } - - localPK := cipher.PubKey{} - if *localPKStr != "" { - if err := localPK.UnmarshalText([]byte(*localPKStr)); err != nil { - fmt.Printf("Invalid local PK: %v\n", err) - os.Exit(1) - } - } - - localSK := cipher.SecKey{} - if *localSKStr != "" { - if err := localSK.UnmarshalText([]byte(*localSKStr)); err != nil { - fmt.Printf("Invalid local SK: %v\n", err) - os.Exit(1) - } - } - var directIPsCh, nonDirectIPsCh = make(chan net.IP, 100), make(chan net.IP, 100) defer close(directIPsCh) defer close(nonDirectIPsCh) @@ -67,11 +40,11 @@ func main() { parseIP := func(addr string) net.IP { ip, ok, err := vpn.ParseIP(addr) if err != nil { - fmt.Printf("Failed to parse IP %s: %v\n", addr, err) + print(fmt.Sprintf("Failed to parse IP %s: %v\n", addr, err)) return nil } if !ok { - fmt.Printf("Failed to parse IP %s\n", addr) + print(fmt.Sprintf("Failed to parse IP %s\n", addr)) return nil } @@ -93,6 +66,44 @@ func main() { appCl := app.NewClient(eventSub) defer appCl.Close() + if _, err := buildinfo.Get().WriteTo(os.Stdout); err != nil { + print(fmt.Sprintf("Failed to output build info: %v\n", err)) + } + + if *serverPKStr == "" { + // TODO(darkrengarius): fix args passage for Windows + //*serverPKStr = "03e9019b3caa021dbee1c23e6295c6034ab4623aec50802fcfdd19764568e2958d" + err := errors.New("VPN server pub key is missing") + print(err) + setAppErr(appCl, err) + os.Exit(1) + } + + serverPK := cipher.PubKey{} + if err := serverPK.UnmarshalText([]byte(*serverPKStr)); err != nil { + print(fmt.Sprintf("Invalid VPN server pub key: %v\n", err)) + setAppErr(appCl, err) + os.Exit(1) + } + + localPK := cipher.PubKey{} + if *localPKStr != "" { + if err := localPK.UnmarshalText([]byte(*localPKStr)); err != nil { + print(fmt.Sprintf("Invalid local PK: %v\n", err)) + setAppErr(appCl, err) + os.Exit(1) + } + } + + localSK := cipher.SecKey{} + if *localSKStr != "" { + if err := localSK.UnmarshalText([]byte(*localSKStr)); err != nil { + print(fmt.Sprintf("Invalid local SK: %v\n", err)) + setAppErr(appCl, err) + os.Exit(1) + } + } + fmt.Printf("Connecting to VPN server %s\n", serverPK.String()) vpnClientCfg := vpn.ClientConfig{ @@ -103,7 +114,8 @@ func main() { vpnClient, err := vpn.NewClient(vpnClientCfg, appCl) if err != nil { - fmt.Printf("Error creating VPN client: %v\n", err) + print(fmt.Sprintf("Error creating VPN client: %v\n", err)) + setAppErr(appCl, err) } var directRoutesDone bool @@ -111,7 +123,8 @@ func main() { select { case ip := <-directIPsCh: if err := vpnClient.AddDirectRoute(ip); err != nil { - fmt.Printf("Failed to setup direct route to %s: %v\n", ip.String(), err) + print(fmt.Sprintf("Failed to setup direct route to %s: %v\n", ip.String(), err)) + setAppErr(appCl, err) } default: directRoutesDone = true @@ -121,7 +134,8 @@ func main() { go func() { for ip := range directIPsCh { if err := vpnClient.AddDirectRoute(ip); err != nil { - fmt.Printf("Failed to setup direct route to %s: %v\n", ip.String(), err) + print(fmt.Sprintf("Failed to setup direct route to %s: %v\n", ip.String(), err)) + setAppErr(appCl, err) } } }() @@ -129,7 +143,8 @@ func main() { go func() { for ip := range nonDirectIPsCh { if err := vpnClient.RemoveDirectRoute(ip); err != nil { - fmt.Printf("Failed to remove direct route to %s: %v\n", ip.String(), err) + print(fmt.Sprintf("Failed to remove direct route to %s: %v\n", ip.String(), err)) + setAppErr(appCl, err) } } }() @@ -148,13 +163,20 @@ func main() { } else { ipcClient, err := ipc.StartClient(skyenv.VPNClientName, nil) if err != nil { - fmt.Printf("Error creating ipc server for VPN client: %v\n", err) + print(fmt.Sprintf("Error creating ipc server for VPN client: %v\n", err)) + setAppErr(appCl, err) os.Exit(1) } go vpnClient.ListenIPC(ipcClient) } if err := vpnClient.Serve(); err != nil { - fmt.Printf("Failed to serve VPN: %v\n", err) + print(fmt.Sprintf("Failed to serve VPN: %v", err)) + } +} + +func setAppErr(appCl *app.Client, err error) { + if appErr := appCl.SetError(err.Error()); appErr != nil { + fmt.Printf("Failed to set error %v: %v\n", err, appErr) } } diff --git a/cmd/apps/vpn-server/vpn-server.go b/cmd/apps/vpn-server/vpn-server.go index 859c8bcce0..dcbdf96d57 100644 --- a/cmd/apps/vpn-server/vpn-server.go +++ b/cmd/apps/vpn-server/vpn-server.go @@ -1,14 +1,15 @@ package main import ( + "errors" "flag" + "fmt" "os" "os/signal" "runtime" "syscall" - "github.com/sirupsen/logrus" - + "github.com/skycoin/skywire-utilities/pkg/buildinfo" "github.com/skycoin/skywire-utilities/pkg/cipher" "github.com/skycoin/skywire/internal/vpn" "github.com/skycoin/skywire/pkg/app" @@ -22,10 +23,6 @@ const ( vpnPort = routing.Port(skyenv.VPNServerPort) ) -var ( - log = logrus.New() -) - var ( localPKStr = flag.String("pk", "", "Local PubKey") localSKStr = flag.String("sk", "", "Local SecKey") @@ -35,8 +32,19 @@ var ( ) func main() { + + appCl := app.NewClient(nil) + defer appCl.Close() + + if _, err := buildinfo.Get().WriteTo(os.Stdout); err != nil { + print(fmt.Sprintf("Failed to output build info: %v\n", err)) + } + if runtime.GOOS != "linux" { - log.Fatalln("OS is not supported") + err := errors.New("OS is not supported") + print(err) + setAppErr(appCl, err) + os.Exit(1) } flag.Parse() @@ -44,20 +52,21 @@ func main() { localPK := cipher.PubKey{} if *localPKStr != "" { if err := localPK.UnmarshalText([]byte(*localPKStr)); err != nil { - log.WithError(err).Fatalln("Invalid local PK") + print(fmt.Sprintf("Invalid local PK: %v", err)) + setAppErr(appCl, err) + os.Exit(1) } } localSK := cipher.SecKey{} if *localSKStr != "" { if err := localSK.UnmarshalText([]byte(*localSKStr)); err != nil { - log.WithError(err).Fatalln("Invalid local SK") + print(fmt.Sprintf("Invalid local SK: %v", err)) + setAppErr(appCl, err) + os.Exit(1) } } - appCl := app.NewClient(nil) - defer appCl.Close() - osSigs := make(chan os.Signal, 2) sigs := []os.Signal{syscall.SIGTERM, syscall.SIGINT} @@ -67,24 +76,27 @@ func main() { l, err := appCl.Listen(netType, vpnPort) if err != nil { - log.WithError(err).Errorf("Error listening network %v on port %d", netType, vpnPort) - return + print(fmt.Sprintf("Error listening network %v on port %d: %v", netType, vpnPort, err)) + setAppErr(appCl, err) + os.Exit(1) } - log.Infof("Got app listener, bound to %d", vpnPort) + fmt.Printf("Got app listener, bound to %d\n", vpnPort) srvCfg := vpn.ServerConfig{ Passcode: *passcode, Secure: *secure, NetworkInterface: *networkIfc, } - srv, err := vpn.NewServer(srvCfg, log, appCl) + srv, err := vpn.NewServer(srvCfg, appCl) if err != nil { - log.WithError(err).Fatalln("Error creating VPN server") + print(fmt.Sprintf("Error creating VPN server: %v", err)) + setAppErr(appCl, err) + os.Exit(1) } defer func() { if err := srv.Close(); err != nil { - log.WithError(err).Errorln("Error closing server") + print(fmt.Sprintf("Error closing server: %v", err)) } }() @@ -100,6 +112,12 @@ func main() { select { case <-osSigs: case err := <-errCh: - log.WithError(err).Errorln("Error serving") + print(fmt.Sprintf("Error serving: %v", err)) + } +} + +func setAppErr(appCl *app.Client, err error) { + if appErr := appCl.SetError(err.Error()); appErr != nil { + fmt.Printf("Failed to set error %v: %v\n", err, appErr) } } diff --git a/cmd/setup-node/commands/root.go b/cmd/setup-node/commands/root.go index b42724fbd8..041c8581c1 100644 --- a/cmd/setup-node/commands/root.go +++ b/cmd/setup-node/commands/root.go @@ -10,11 +10,11 @@ import ( cc "github.com/ivanpirog/coloredcobra" "github.com/sirupsen/logrus" - "github.com/skycoin/skycoin/src/util/logging" "github.com/spf13/cobra" "github.com/skycoin/skywire-utilities/pkg/buildinfo" "github.com/skycoin/skywire-utilities/pkg/cmdutil" + "github.com/skycoin/skywire-utilities/pkg/logging" "github.com/skycoin/skywire-utilities/pkg/metricsutil" "github.com/skycoin/skywire/pkg/setup" "github.com/skycoin/skywire/pkg/setup/setupmetrics" diff --git a/cmd/skywire-cli/commands/config/gen.go b/cmd/skywire-cli/commands/config/gen.go index 1b6a72c4ed..d55e68425d 100644 --- a/cmd/skywire-cli/commands/config/gen.go +++ b/cmd/skywire-cli/commands/config/gen.go @@ -11,10 +11,10 @@ import ( "github.com/bitfield/script" "github.com/sirupsen/logrus" - "github.com/skycoin/skycoin/src/util/logging" "github.com/spf13/cobra" "github.com/skycoin/skywire-utilities/pkg/cipher" + "github.com/skycoin/skywire-utilities/pkg/logging" "github.com/skycoin/skywire-utilities/pkg/netutil" utilenv "github.com/skycoin/skywire-utilities/pkg/skyenv" "github.com/skycoin/skywire/pkg/app/launcher" diff --git a/cmd/skywire-cli/commands/config/root.go b/cmd/skywire-cli/commands/config/root.go index d7f8fef9fb..eb192a9b4d 100644 --- a/cmd/skywire-cli/commands/config/root.go +++ b/cmd/skywire-cli/commands/config/root.go @@ -1,9 +1,9 @@ package config import ( - "github.com/skycoin/skycoin/src/util/logging" "github.com/spf13/cobra" + "github.com/skycoin/skywire-utilities/pkg/logging" "github.com/skycoin/skywire/cmd/skywire-cli/commands/config/update" ) diff --git a/cmd/skywire-cli/commands/config/update/root.go b/cmd/skywire-cli/commands/config/update/root.go index d4e3df57d4..3b127d4b8b 100644 --- a/cmd/skywire-cli/commands/config/update/root.go +++ b/cmd/skywire-cli/commands/config/update/root.go @@ -8,9 +8,9 @@ import ( "strings" "github.com/sirupsen/logrus" - "github.com/skycoin/skycoin/src/util/logging" "github.com/spf13/cobra" + "github.com/skycoin/skywire-utilities/pkg/logging" utilenv "github.com/skycoin/skywire-utilities/pkg/skyenv" "github.com/skycoin/skywire/pkg/dmsgc" "github.com/skycoin/skywire/pkg/skyenv" diff --git a/cmd/skywire-cli/commands/dmsgpty/root.go b/cmd/skywire-cli/commands/dmsgpty/root.go index 18c80a54a4..441c8825c5 100644 --- a/cmd/skywire-cli/commands/dmsgpty/root.go +++ b/cmd/skywire-cli/commands/dmsgpty/root.go @@ -9,10 +9,10 @@ import ( "time" "github.com/skycoin/dmsg/pkg/dmsgpty" - "github.com/skycoin/skycoin/src/util/logging" "github.com/spf13/cobra" "github.com/skycoin/skywire-utilities/pkg/cmdutil" + "github.com/skycoin/skywire-utilities/pkg/logging" "github.com/skycoin/skywire/cmd/skywire-cli/internal" "github.com/skycoin/skywire/pkg/visor" ) diff --git a/cmd/skywire-cli/commands/mdisc/root.go b/cmd/skywire-cli/commands/mdisc/root.go index 3fd1602211..80897ec2fc 100644 --- a/cmd/skywire-cli/commands/mdisc/root.go +++ b/cmd/skywire-cli/commands/mdisc/root.go @@ -9,9 +9,9 @@ import ( "time" "github.com/skycoin/dmsg/pkg/disc" - "github.com/skycoin/skycoin/src/util/logging" "github.com/spf13/cobra" + "github.com/skycoin/skywire-utilities/pkg/logging" utilenv "github.com/skycoin/skywire-utilities/pkg/skyenv" "github.com/skycoin/skywire/cmd/skywire-cli/internal" ) diff --git a/cmd/skywire-cli/commands/visor/root.go b/cmd/skywire-cli/commands/visor/root.go index 4350e54dcc..55a963b0f8 100644 --- a/cmd/skywire-cli/commands/visor/root.go +++ b/cmd/skywire-cli/commands/visor/root.go @@ -4,9 +4,9 @@ import ( "net" "time" - "github.com/skycoin/skycoin/src/util/logging" "github.com/spf13/cobra" + "github.com/skycoin/skywire-utilities/pkg/logging" "github.com/skycoin/skywire/cmd/skywire-cli/commands/visor/vapps" "github.com/skycoin/skywire/cmd/skywire-cli/commands/visor/vroute" "github.com/skycoin/skywire/cmd/skywire-cli/commands/visor/vtp" diff --git a/cmd/skywire-cli/commands/visor/vapps/root.go b/cmd/skywire-cli/commands/visor/vapps/root.go index d3882a969a..907cc2218d 100644 --- a/cmd/skywire-cli/commands/visor/vapps/root.go +++ b/cmd/skywire-cli/commands/visor/vapps/root.go @@ -4,9 +4,9 @@ import ( "net" "time" - "github.com/skycoin/skycoin/src/util/logging" "github.com/spf13/cobra" + "github.com/skycoin/skywire-utilities/pkg/logging" "github.com/skycoin/skywire/pkg/visor" ) diff --git a/cmd/skywire-cli/commands/visor/vroute/root.go b/cmd/skywire-cli/commands/visor/vroute/root.go index 6a82000b4b..bbdc9b6c5c 100644 --- a/cmd/skywire-cli/commands/visor/vroute/root.go +++ b/cmd/skywire-cli/commands/visor/vroute/root.go @@ -4,9 +4,9 @@ import ( "net" "time" - "github.com/skycoin/skycoin/src/util/logging" "github.com/spf13/cobra" + "github.com/skycoin/skywire-utilities/pkg/logging" "github.com/skycoin/skywire/pkg/visor" ) diff --git a/cmd/skywire-cli/commands/visor/vtp/root.go b/cmd/skywire-cli/commands/visor/vtp/root.go index e0059693ed..bed54a89aa 100644 --- a/cmd/skywire-cli/commands/visor/vtp/root.go +++ b/cmd/skywire-cli/commands/visor/vtp/root.go @@ -4,9 +4,9 @@ import ( "net" "time" - "github.com/skycoin/skycoin/src/util/logging" "github.com/spf13/cobra" + "github.com/skycoin/skywire-utilities/pkg/logging" "github.com/skycoin/skywire/pkg/visor" ) diff --git a/cmd/skywire-cli/commands/visor/vvpn/root.go b/cmd/skywire-cli/commands/visor/vvpn/root.go index d4e2edd64d..b4d9af6015 100644 --- a/cmd/skywire-cli/commands/visor/vvpn/root.go +++ b/cmd/skywire-cli/commands/visor/vvpn/root.go @@ -4,9 +4,9 @@ import ( "net" "time" - "github.com/skycoin/skycoin/src/util/logging" "github.com/spf13/cobra" + "github.com/skycoin/skywire-utilities/pkg/logging" "github.com/skycoin/skywire/pkg/visor" ) diff --git a/cmd/skywire-cli/internal/internal.go b/cmd/skywire-cli/internal/internal.go index ed1cc9e5ef..549f7d17a6 100644 --- a/cmd/skywire-cli/internal/internal.go +++ b/cmd/skywire-cli/internal/internal.go @@ -4,9 +4,9 @@ import ( "fmt" "github.com/google/uuid" - "github.com/skycoin/skycoin/src/util/logging" "github.com/skycoin/skywire-utilities/pkg/cipher" + "github.com/skycoin/skywire-utilities/pkg/logging" ) var log = logging.MustGetLogger("skywire-cli") diff --git a/cmd/skywire-visor/commands/nosystray.go b/cmd/skywire-visor/commands/nosystray.go index 0a61b983ab..998f9b2f2c 100644 --- a/cmd/skywire-visor/commands/nosystray.go +++ b/cmd/skywire-visor/commands/nosystray.go @@ -6,7 +6,7 @@ package commands import ( "context" - "github.com/skycoin/skycoin/src/util/logging" + "github.com/skycoin/skywire-utilities/pkg/logging" ) func runApp() { diff --git a/cmd/skywire-visor/commands/root.go b/cmd/skywire-visor/commands/root.go index d39220d725..e1e36bc4c7 100644 --- a/cmd/skywire-visor/commands/root.go +++ b/cmd/skywire-visor/commands/root.go @@ -21,13 +21,13 @@ import ( "github.com/bitfield/script" cc "github.com/ivanpirog/coloredcobra" "github.com/pkg/profile" - "github.com/skycoin/skycoin/src/util/logging" "github.com/spf13/cobra" "github.com/toqueteos/webbrowser" "github.com/skycoin/skywire-utilities/pkg/buildinfo" "github.com/skycoin/skywire-utilities/pkg/cipher" "github.com/skycoin/skywire-utilities/pkg/cmdutil" + "github.com/skycoin/skywire-utilities/pkg/logging" "github.com/skycoin/skywire/pkg/restart" "github.com/skycoin/skywire/pkg/skyenv" "github.com/skycoin/skywire/pkg/syslog" @@ -378,7 +378,6 @@ func initConfig(mLog *logging.MasterLogger, confPath string) *visorconfig.V1 { / case "": fallthrough default: - log.Info("Reading config from file.") log.WithField("filepath", confPath).Info() f, err := os.ReadFile(filepath.Clean(confPath)) if err != nil { diff --git a/cmd/skywire-visor/commands/systray.go b/cmd/skywire-visor/commands/systray.go index f71b36c2f0..90623139bf 100644 --- a/cmd/skywire-visor/commands/systray.go +++ b/cmd/skywire-visor/commands/systray.go @@ -6,7 +6,7 @@ package commands import ( "context" - "github.com/skycoin/skycoin/src/util/logging" + "github.com/skycoin/skywire-utilities/pkg/logging" "github.com/skycoin/systray" "github.com/skycoin/skywire/internal/gui" diff --git a/go.mod b/go.mod index b11e6ee128..756758caa3 100644 --- a/go.mod +++ b/go.mod @@ -19,7 +19,7 @@ require ( github.com/pkg/profile v1.5.0 github.com/shirou/gopsutil/v3 v3.21.4 github.com/sirupsen/logrus v1.8.1 - github.com/skycoin/dmsg v0.0.0-20220607114207-d4a85dc351ce + github.com/skycoin/dmsg v0.0.0-20220617100223-c17f98a92a47 github.com/skycoin/skycoin v0.27.1 github.com/skycoin/yamux v0.0.0-20200803175205-571ceb89da9f github.com/songgao/water v0.0.0-20200317203138-2b4b6d7c09d8 @@ -47,7 +47,7 @@ require ( github.com/go-chi/chi/v5 v5.0.8-0.20220103230436-7dbe9a0bd10f github.com/ivanpirog/coloredcobra v1.0.0 github.com/james-barrow/golang-ipc v0.0.0-20210227130457-95e7cc81f5e2 - github.com/skycoin/skywire-utilities v0.0.0-20220511053113-3d492e0048c4 + github.com/skycoin/skywire-utilities v0.0.0-20220617085111-5c8c8d3ced14 github.com/skycoin/systray v1.10.1-0.20220509091536-c90eecafd3fd ) diff --git a/go.sum b/go.sum index f4f746b775..15d8082291 100644 --- a/go.sum +++ b/go.sum @@ -474,15 +474,14 @@ github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMB github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= github.com/sirupsen/logrus v1.8.1 h1:dJKuHgqk1NNQlqoA6BTlM1Wf9DOH3NBjQyu0h9+AZZE= github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= -github.com/skycoin/dmsg v0.0.0-20220607114207-d4a85dc351ce h1:a0VlsBW5Ac7D3LflMhv52TWRcC1nbkn3ZRCNEE3hqUE= -github.com/skycoin/dmsg v0.0.0-20220607114207-d4a85dc351ce/go.mod h1:naR6dKKUhc9iDxSUEEw95KO8SEQ1ppJoaHC3osQ5m9k= +github.com/skycoin/dmsg v0.0.0-20220617100223-c17f98a92a47 h1:d/KdILjeiZOj3QFOm8KkOwIr5wwx9zWCl+oGVXPln1o= +github.com/skycoin/dmsg v0.0.0-20220617100223-c17f98a92a47/go.mod h1:7ixxeJVjbe3lxDkI4Yizj/TWoafYxs8cPJfxjlDeG+w= github.com/skycoin/noise v0.0.0-20180327030543-2492fe189ae6 h1:1Nc5EBY6pjfw1kwW0duwyG+7WliWz5u9kgk1h5MnLuA= github.com/skycoin/noise v0.0.0-20180327030543-2492fe189ae6/go.mod h1:UXghlricA7J3aRD/k7p/zBObQfmBawwCxIVPVjz2Q3o= github.com/skycoin/skycoin v0.27.1 h1:HatxsRwVSPaV4qxH6290xPBmkH/HgiuAoY2qC+e8C9I= github.com/skycoin/skycoin v0.27.1/go.mod h1:78nHjQzd8KG0jJJVL/j0xMmrihXi70ti63fh8vXScJw= -github.com/skycoin/skywire-utilities v0.0.0-20220412111240-e8921109e514/go.mod h1:9fOsut+rqCBd33NPF3cuolXrw8uQESYshSvdYMaZNEo= -github.com/skycoin/skywire-utilities v0.0.0-20220511053113-3d492e0048c4 h1:1wnQREqhD+eOek0isH3m1RTKGT+o2aDZtIoiMk4kROw= -github.com/skycoin/skywire-utilities v0.0.0-20220511053113-3d492e0048c4/go.mod h1:9fOsut+rqCBd33NPF3cuolXrw8uQESYshSvdYMaZNEo= +github.com/skycoin/skywire-utilities v0.0.0-20220617085111-5c8c8d3ced14 h1:u8NYb1CX3l3I6wy6RWy2lQM6iqA6XbFex6Q/4MmEyfA= +github.com/skycoin/skywire-utilities v0.0.0-20220617085111-5c8c8d3ced14/go.mod h1:B63p56igl38Ha+zjqi26d2om6XEe9jozwB6kzAWMnm0= github.com/skycoin/systray v1.10.1-0.20220509091536-c90eecafd3fd h1:z2aytJ9vsBpsBrC6nfHuOTS+AUoEbaKs257+AiigUjk= github.com/skycoin/systray v1.10.1-0.20220509091536-c90eecafd3fd/go.mod h1:LvRiIPZbFo8Qqp7Q9C9LXK02CqoVmc9EUGihU6kTRWc= github.com/skycoin/yamux v0.0.0-20200803175205-571ceb89da9f h1:A5dEM1OE9YhN3LciZU9qPjo7fJ46JeHNi3JCroDkK0Y= diff --git a/internal/gui/gui.go b/internal/gui/gui.go index ac92045dc0..6e2e060aa7 100644 --- a/internal/gui/gui.go +++ b/internal/gui/gui.go @@ -23,7 +23,7 @@ import ( "github.com/skycoin/dmsg/pkg/dmsg" "github.com/skycoin/dmsg/pkg/dmsgget" "github.com/skycoin/dmsg/pkg/dmsghttp" - "github.com/skycoin/skycoin/src/util/logging" + "github.com/skycoin/skywire-utilities/pkg/logging" "github.com/skycoin/systray" "github.com/toqueteos/webbrowser" diff --git a/internal/httpauth/client.go b/internal/httpauth/client.go index 8711cebbf8..b15e9e9852 100644 --- a/internal/httpauth/client.go +++ b/internal/httpauth/client.go @@ -15,7 +15,7 @@ import ( "sync" "sync/atomic" - "github.com/skycoin/skycoin/src/util/logging" + "github.com/skycoin/skywire-utilities/pkg/logging" "github.com/skycoin/skywire-utilities/pkg/cipher" ) diff --git a/internal/httpauth/client_test.go b/internal/httpauth/client_test.go index b85455e3ed..f94f56860b 100644 --- a/internal/httpauth/client_test.go +++ b/internal/httpauth/client_test.go @@ -12,11 +12,11 @@ import ( "strconv" "testing" - "github.com/skycoin/skycoin/src/util/logging" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "github.com/skycoin/skywire-utilities/pkg/cipher" + "github.com/skycoin/skywire-utilities/pkg/logging" ) var masterLogger = logging.NewMasterLogger() diff --git a/internal/packetfilter/address-filter.go b/internal/packetfilter/address-filter.go index fb62f94e9a..80bf7c83e3 100644 --- a/internal/packetfilter/address-filter.go +++ b/internal/packetfilter/address-filter.go @@ -3,7 +3,7 @@ package packetfilter import ( "net" - "github.com/skycoin/skycoin/src/util/logging" + "github.com/skycoin/skywire-utilities/pkg/logging" ) // AddressFilter filters packets from specified address. diff --git a/internal/packetfilter/kcp-filter.go b/internal/packetfilter/kcp-filter.go index 0f42fb630d..c6c878054f 100644 --- a/internal/packetfilter/kcp-filter.go +++ b/internal/packetfilter/kcp-filter.go @@ -5,7 +5,8 @@ import ( "net" "sync/atomic" - "github.com/skycoin/skycoin/src/util/logging" + "github.com/skycoin/skywire-utilities/pkg/logging" + "github.com/xtaci/kcp-go" ) diff --git a/internal/skysocks/client.go b/internal/skysocks/client.go index 50993a078e..3de64be714 100644 --- a/internal/skysocks/client.go +++ b/internal/skysocks/client.go @@ -8,8 +8,6 @@ import ( "time" ipc "github.com/james-barrow/golang-ipc" - "github.com/sirupsen/logrus" - "github.com/skycoin/skycoin/src/util/logging" "github.com/skycoin/yamux" "github.com/skycoin/skywire/pkg/app" @@ -18,9 +16,6 @@ import ( "github.com/skycoin/skywire/pkg/skyenv" ) -// Log is skysocks package level logger, it can be replaced with a different one from outside the package -var Log logrus.FieldLogger = logging.MustGetLogger("skysocks") // nolint: gochecknoglobals - // Client implement multiplexing proxy client using yamux. type Client struct { appCl *app.Client @@ -62,7 +57,7 @@ func (c *Client) ListenAndServe(addr string) error { return fmt.Errorf("listen: %w", err) } - Log.Printf("Listening skysocks client on %s", addr) + fmt.Printf("Listening skysocks client on %s", addr) c.listener = l if c.appCl != nil { @@ -78,11 +73,11 @@ func (c *Client) ListenAndServe(addr string) error { conn, err := l.Accept() if err != nil { - Log.Printf("Error accepting: %v\n", err) + fmt.Printf("Error accepting: %v\n", err) return fmt.Errorf("accept: %w", err) } - Log.Println("Accepted skysocks client") + fmt.Println("Accepted skysocks client") stream, err := c.session.Open() if err != nil { @@ -91,7 +86,7 @@ func (c *Client) ListenAndServe(addr string) error { return fmt.Errorf("error opening yamux stream: %w", err) } - Log.Println("Opened session skysocks client") + fmt.Println("Opened session skysocks client") go c.handleStream(conn, stream) } @@ -135,7 +130,7 @@ func (c *Client) handleStream(conn, stream net.Conn) { for err := range errCh { if !connClosed { if err := conn.Close(); err != nil { - Log.WithError(err).Warn("Failed to close connection") + fmt.Printf("Failed to close connection: %v\n", err) } connClosed = true @@ -143,14 +138,14 @@ func (c *Client) handleStream(conn, stream net.Conn) { if !streamClosed { if err := stream.Close(); err != nil { - Log.WithError(err).Warn("Failed to close stream") + fmt.Printf("Failed to close stream: %v\n", err) } streamClosed = true } if err != nil { - Log.Error("Copy error:", err) + print(fmt.Sprintf("Copy error: %v", err)) } } @@ -162,31 +157,31 @@ func (c *Client) handleStream(conn, stream net.Conn) { } func (c *Client) close() { - Log.Error("Session failed, closing skysocks client") + print("Session failed, closing skysocks client") if err := c.Close(); err != nil { - Log.WithError(err).Error("Error closing skysocks client") + print(fmt.Sprintf("Error closing skysocks client: %v", err)) } } // ListenIPC starts named-pipe based connection server for windows or unix socket for other OSes -func (c *Client) ListenIPC(client *ipc.Client, log *logrus.Logger) { +func (c *Client) ListenIPC(client *ipc.Client) { listenIPC(client, skyenv.SkychatName+"-client", func() { client.Close() if err := c.Close(); err != nil { - log.Errorf("Error closing skysocks-client: %v", err) + print(fmt.Sprintf("Error closing skysocks-client: %v", err)) } }) } func (c *Client) setAppStatus(status launcher.AppDetailedStatus) { if err := c.appCl.SetDetailedStatus(string(status)); err != nil { - fmt.Printf("Failed to set status %v: %v\n", status, err) + print(fmt.Sprintf("Failed to set status %v: %v\n", status, err)) } } func (c *Client) setAppError(appErr error) { if err := c.appCl.SetError(appErr.Error()); err != nil { - fmt.Printf("Failed to set error %v: %v\n", appErr, err) + print(fmt.Sprintf("Failed to set error %v: %v\n", appErr, err)) } } @@ -198,7 +193,7 @@ func (c *Client) Close() error { var err error c.once.Do(func() { - Log.Infoln("Closing proxy client") + fmt.Println("Closing proxy client") close(c.closeC) diff --git a/internal/skysocks/server.go b/internal/skysocks/server.go index b7f8c0991a..4d9e09ac28 100644 --- a/internal/skysocks/server.go +++ b/internal/skysocks/server.go @@ -9,7 +9,6 @@ import ( "github.com/armon/go-socks5" ipc "github.com/james-barrow/golang-ipc" - "github.com/sirupsen/logrus" "github.com/skycoin/yamux" "github.com/skycoin/skywire/pkg/app" @@ -23,12 +22,11 @@ type Server struct { sMu sync.Mutex socks *socks5.Server listener net.Listener - log logrus.FieldLogger closed uint32 } // NewServer constructs a new Server. -func NewServer(passcode string, appCl *app.Client, l logrus.FieldLogger) (*Server, error) { +func NewServer(passcode string, appCl *app.Client) (*Server, error) { var credentials socks5.CredentialStore if passcode != "" { credentials = passcodeCredentials(passcode) @@ -42,7 +40,6 @@ func NewServer(passcode string, appCl *app.Client, l logrus.FieldLogger) (*Serve server := &Server{ appCl: appCl, socks: s, - log: l, } return server, nil @@ -67,16 +64,16 @@ func (s *Server) Serve(l net.Listener) error { conn, err := l.Accept() if err != nil { if s.isClosed() { - s.log.WithError(err).Debugln("Failed to accept skysocks connection, but server is closed") + fmt.Printf("Failed to accept skysocks connection, but server is closed: %v\n", err) return nil } - s.log.WithError(err).Debugln("Failed to accept skysocks connection") + fmt.Printf("Failed to accept skysocks connection: %v\n", err) return fmt.Errorf("accept: %w", err) } - s.log.Infoln("Accepted new skysocks connection") + fmt.Println("Accepted new skysocks connection") sessionCfg := yamux.DefaultConfig() sessionCfg.EnableKeepAlive = false @@ -87,7 +84,7 @@ func (s *Server) Serve(l net.Listener) error { go func() { if err := s.socks.Serve(session); err != nil { - s.log.Error("Failed to start SOCKS5 server:", err) + print(fmt.Sprintf("Failed to start SOCKS5 server: %v", err)) } }() } @@ -106,7 +103,7 @@ func (s *Server) ListenIPC(client *ipc.Client) { func (s *Server) setAppStatus(status launcher.AppDetailedStatus) { if err := s.appCl.SetDetailedStatus(string(status)); err != nil { - fmt.Printf("Failed to set status %v: %v\n", status, err) + print(fmt.Sprintf("Failed to set status %v: %v\n", status, err)) } } diff --git a/internal/skysocks/server_test.go b/internal/skysocks/server_test.go index 5166721044..6bb5cad100 100644 --- a/internal/skysocks/server_test.go +++ b/internal/skysocks/server_test.go @@ -10,7 +10,8 @@ import ( "testing" "time" - "github.com/skycoin/skycoin/src/util/logging" + "github.com/skycoin/skywire-utilities/pkg/logging" + "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "golang.org/x/net/nettest" @@ -22,7 +23,8 @@ func TestMain(m *testing.M) { if ok { lvl, err := logging.LevelFromString(loggingLevel) if err != nil { - Log.Fatal(err) + print(err) + os.Exit(1) } logging.SetLevel(lvl) @@ -34,7 +36,7 @@ func TestMain(m *testing.M) { } func TestProxy(t *testing.T) { - srv, err := NewServer("", nil, logging.NewMasterLogger()) + srv, err := NewServer("", nil) require.NoError(t, err) l, err := nettest.NewLocalListener("tcp") diff --git a/internal/vpn/client.go b/internal/vpn/client.go index e27a2795a2..05f0d78d02 100644 --- a/internal/vpn/client.go +++ b/internal/vpn/client.go @@ -14,7 +14,6 @@ import ( "time" ipc "github.com/james-barrow/golang-ipc" - "github.com/sirupsen/logrus" "github.com/skycoin/skywire-utilities/pkg/cipher" "github.com/skycoin/skywire-utilities/pkg/netutil" @@ -33,7 +32,6 @@ const ( // Client is a VPN client. type Client struct { - log *logrus.Logger cfg ClientConfig appCl *app.Client directIPSMu sync.Mutex @@ -112,8 +110,6 @@ func NewClient(cfg ClientConfig, appCl *app.Client) (*Client, error) { directIPs = append(directIPs, utIP) } - log := logrus.New() - defaultGateway, err := DefaultNetworkGateway() if err != nil { return nil, fmt.Errorf("error getting default network gateway: %w", err) @@ -122,7 +118,6 @@ func NewClient(cfg ClientConfig, appCl *app.Client) (*Client, error) { fmt.Printf("Got default network gateway IP: %s\n", defaultGateway) return &Client{ - log: log, cfg: cfg, appCl: appCl, directIPs: filterOutEqualIPs(directIPs), @@ -135,12 +130,14 @@ func NewClient(cfg ClientConfig, appCl *app.Client) (*Client, error) { func (c *Client) Serve() error { c.setAppStatus(launcher.AppDetailedStatusStarting) if err := c.setSysPrivileges(); err != nil { + c.setAppError(err) return fmt.Errorf("failed to setup system privileges: %w", err) } // we setup direct routes to skywire services once for all the client lifetime since routes don't change. // but if they change, new routes get delivered to the app via callbacks. if err := c.setupDirectRoutes(); err != nil { c.releaseSysPrivileges() + c.setAppError(err) return fmt.Errorf("error setting up direct routes: %w", err) } c.releaseSysPrivileges() @@ -160,7 +157,7 @@ func (c *Client) Serve() error { if c.cfg.Killswitch { err := c.setSysPrivileges() if err != nil { - fmt.Printf("Error setting up system privileges: %v\n", err) + print(fmt.Sprintf("Error setting up system privileges: %v\n", err)) } else { c.prevTUNGatewayMu.Lock() if len(c.prevTUNGateway) > 0 { @@ -175,10 +172,10 @@ func (c *Client) Serve() error { } if err := c.closeTUN(); err != nil { - fmt.Printf("Failed to close TUN: %v\n", err) + print(fmt.Sprintf("Failed to close TUN: %v\n", err)) } - c.log.Info("Closing TUN") + fmt.Println("Closing TUN") }() defer func() { @@ -188,7 +185,7 @@ func (c *Client) Serve() error { c.setAppStatus(launcher.AppDetailedStatusVPNConnecting) - r := netutil.NewRetrier(c.log, netutil.DefaultInitBackoff, netutil.DefaultMaxBackoff, 3, netutil.DefaultFactor). + r := netutil.NewRetrier(nil, netutil.DefaultInitBackoff, netutil.DefaultMaxBackoff, 3, netutil.DefaultFactor). WithErrWhitelist(errHandshakeStatusForbidden, errHandshakeStatusInternalError, errHandshakeNoFreeIPs, errHandshakeStatusBadRequest, errNoTransportFound, errTransportNotFound, errErrSetupNode, errNotPermited) @@ -206,7 +203,7 @@ func (c *Client) Serve() error { return err default: c.resetConnDuration() - c.setAppStatus(launcher.AppDetailedStatusVPNReconnecting) + c.setAppStatus(launcher.AppDetailedStatusReconnecting) c.setAppError(errTimeout) fmt.Println("\nConnection broke, reconnecting...") return fmt.Errorf("dialServeConn: %w", err) @@ -225,18 +222,18 @@ func (c *Client) Serve() error { // ListenIPC starts named-pipe based connection server for windows or unix socket in Linux/Mac func (c *Client) ListenIPC(client *ipc.Client) { if client == nil { - fmt.Println("Unable to create IPC Client: server is non-existent") + print(fmt.Sprintln("Unable to create IPC Client: server is non-existent")) return } for { m, err := client.Read() if err != nil { - fmt.Printf("%s IPC received error: %v", skyenv.VPNClientName, err) + print(fmt.Sprintf("%s IPC received error: %v\n", skyenv.VPNClientName, err)) } if m != nil { if m.MsgType == skyenv.IPCShutdownMessageType { - fmt.Println("Stopping " + skyenv.VPNClientName + " via IPC") + print(fmt.Sprintln("Stopping " + skyenv.VPNClientName + " via IPC")) break } } @@ -368,7 +365,7 @@ func (c *Client) setupTUN(tunIP, tunGateway net.IP) error { func (c *Client) serveConn(conn net.Conn) error { tunIP, tunGateway, err := c.shakeHands(conn) if err != nil { - fmt.Printf("error during client/server handshake: %s", err) + fmt.Printf("error during client/server handshake: %s\n", err) return err } @@ -400,7 +397,7 @@ func (c *Client) serveConn(conn net.Conn) error { fmt.Printf("Allocated TUN %s: %v\n", tun.Name(), err) - fmt.Printf("Setting up TUN device with: %s and Gateway %s", tunIP, tunGateway) + fmt.Printf("Setting up TUN device with: %s and Gateway %s\n", tunIP, tunGateway) if err := c.setupTUN(tunIP, tunGateway); err != nil { return fmt.Errorf("error setting up TUN %s: %w", tun.Name(), err) } @@ -413,7 +410,7 @@ func (c *Client) serveConn(conn net.Conn) error { time.Sleep(13 * time.Second) } - fmt.Printf("TUN %s all sets", tunIP) + fmt.Printf("TUN %s all sets\n", tunIP) isNewRoute := true if c.cfg.Killswitch { @@ -451,10 +448,12 @@ func (c *Client) serveConn(conn net.Conn) error { defer close(connToTunDoneCh) if _, err := io.Copy(tun, conn); err != nil { - fmt.Printf("Error resending traffic from TUN %s to VPN server: %v\n", tun.Name(), err) - // when the vpn-server is closed we get the error EOF - if err.Error() == io.EOF.Error() { - c.setAppError(errVPNServerClosed) + if !c.isClosed() { + print(fmt.Sprintf("Error resending traffic from TUN %s to VPN server: %v\n", tun.Name(), err)) + // when the vpn-server is closed we get the error EOF + if err.Error() == io.EOF.Error() { + c.setAppError(errVPNServerClosed) + } } } }() @@ -462,7 +461,9 @@ func (c *Client) serveConn(conn net.Conn) error { defer close(tunToConnCh) if _, err := io.Copy(conn, tun); err != nil { - fmt.Printf("Error resending traffic from VPN server to TUN %s: %v\n", tun.Name(), err) + if !c.isClosed() { + print(fmt.Sprintf("Error resending traffic from VPN server to TUN %s: %v\n", tun.Name(), err)) + } } }() @@ -484,7 +485,7 @@ serveLoop: // here we setup system privileges again, so deferred calls may be done safely if err := c.setSysPrivileges(); err != nil { - fmt.Printf("Failed to setup system privileges for cleanup: %v\n", err) + print(fmt.Sprintf("Failed to setup system privileges for cleanup: %v\n", err)) } return nil @@ -501,7 +502,7 @@ func (c *Client) dialServeConn() error { defer func() { if err := conn.Close(); err != nil { - fmt.Printf("Error closing app conn: %v\n", err) + print(fmt.Sprintf("Error closing app conn: %v\n", err)) } }() @@ -543,10 +544,10 @@ func (c *Client) routeTrafficDirectly(tunGateway net.IP) { // remove main route if err := DeleteRoute(ipv4FirstHalfAddr, tunGateway.String()); err != nil { - fmt.Printf("Error routing traffic through default network gateway: %v\n", err) + print(fmt.Sprintf("Error routing traffic through default network gateway: %v\n", err)) } if err := DeleteRoute(ipv4SecondHalfAddr, tunGateway.String()); err != nil { - fmt.Printf("Error routing traffic through default network gateway: %v\n", err) + print(fmt.Sprintf("Error routing traffic through default network gateway: %v\n", err)) } } @@ -565,7 +566,7 @@ func (c *Client) setupDirectRoutes() error { func (c *Client) setupDirectRoute(ip net.IP) error { if !ip.IsLoopback() { - fmt.Printf("Adding direct route to %s, via %s", ip.String(), c.defaultGateway.String()) + fmt.Printf("Adding direct route to %s, via %s\n", ip.String(), c.defaultGateway.String()) if err := AddRoute(ip.String()+directRouteNetmaskCIDR, c.defaultGateway.String()); err != nil { return fmt.Errorf("error adding direct route to %s: %w", ip.String(), err) } @@ -592,7 +593,7 @@ func (c *Client) removeDirectRoutes() { for _, ip := range c.directIPs { if err := c.removeDirectRoute(ip); err != nil { // shouldn't return, just keep on trying the other IPs - fmt.Printf("Error removing direct route to %s: %v\n", ip.String(), err) + print(fmt.Sprintf("Error removing direct route to %s: %v\n", ip.String(), err)) } } } @@ -764,19 +765,19 @@ func (c *Client) dialServer(appCl *app.Client, pk cipher.PubKey) (net.Conn, erro func (c *Client) setAppStatus(status launcher.AppDetailedStatus) { if err := c.appCl.SetDetailedStatus(string(status)); err != nil { - fmt.Printf("Failed to set status %v: %v\n", status, err) + print(fmt.Sprintf("Failed to set status %v: %v\n", status, err)) } } func (c *Client) setConnectionDuration() { if err := c.appCl.SetConnectionDuration(atomic.LoadInt64(&c.connectedDuration)); err != nil { - fmt.Printf("Failed to set connection duration: %v\n", err) + print(fmt.Sprintf("Failed to set connection duration: %v\n", err)) } } func (c *Client) setAppError(appErr error) { if err := c.appCl.SetError(appErr.Error()); err != nil { - fmt.Printf("Failed to set error %v: %v\n", appErr, err) + print(fmt.Sprintf("Failed to set error %v: %v\n", appErr, err)) } } diff --git a/internal/vpn/errors.go b/internal/vpn/errors.go index 5660b8b505..beeedf9de2 100644 --- a/internal/vpn/errors.go +++ b/internal/vpn/errors.go @@ -18,6 +18,7 @@ var ( errTimeout = errors.New("Internal error: Timeout") errNotPermited = errors.New("ioctl: operation not permitted") errVPNServerClosed = errors.New("Vpn-server closed") + errPermissionDenied = errors.New("Permission denied") //nolint errNoTransportFound = appserver.RPCErr{ Err: router.ErrNoTransportFound.Error(), diff --git a/internal/vpn/os_linux.go b/internal/vpn/os_linux.go index 37ef0b8a0d..37caaa00fa 100644 --- a/internal/vpn/os_linux.go +++ b/internal/vpn/os_linux.go @@ -55,6 +55,12 @@ func AddRoute(ip, gateway string) error { } } + if errors.As(err, &e) { + if strings.Contains(string(e.Stderr), "Operation not permitted") { + return errPermissionDenied + } + } + return err } diff --git a/internal/vpn/os_server_linux.go b/internal/vpn/os_server_linux.go index 885446bc11..c2050374ea 100644 --- a/internal/vpn/os_server_linux.go +++ b/internal/vpn/os_server_linux.go @@ -31,14 +31,20 @@ func GetIPTablesForwardPolicy() (string, error) { if err != nil { return "", err } - return strings.TrimRight(string(outputBytes), "\n"), nil } // SetIPTablesForwardPolicy sets `policy` for iptables `forward` chain. func SetIPTablesForwardPolicy(policy string) error { cmd := fmt.Sprintf(setIPTablesForwardPolicyCMDFmt, policy) - return osutil.Run("sh", "-c", cmd) + outBytes, err := osutil.RunWithResult("sh", "-c", cmd) + if err != nil { + return err + } + if len(outBytes) == 0 { + return errPermissionDenied + } + return nil } // SetIPTablesForwardAcceptPolicy sets ACCEPT policy for iptables `forward` chain. @@ -74,13 +80,27 @@ func GetIPv6ForwardingValue() (string, error) { // SetIPv4ForwardingValue sets `val` value of IPv4 forwarding. func SetIPv4ForwardingValue(val string) error { cmd := fmt.Sprintf(setIPv4ForwardingCMDFmt, val) - return osutil.Run("sh", "-c", cmd) + outBytes, err := osutil.RunWithResult("sh", "-c", cmd) + if err != nil { + return err + } + if len(outBytes) == 0 { + return errPermissionDenied + } + return nil } // SetIPv6ForwardingValue sets `val` value of IPv6 forwarding. func SetIPv6ForwardingValue(val string) error { cmd := fmt.Sprintf(setIPv6ForwardingCMDFmt, val) - return osutil.Run("sh", "-c", cmd) + outBytes, err := osutil.RunWithResult("sh", "-c", cmd) + if err != nil { + return err + } + if len(outBytes) == 0 { + return errPermissionDenied + } + return nil } // EnableIPv4Forwarding enables IPv4 forwarding. diff --git a/internal/vpn/server.go b/internal/vpn/server.go index 096dd8b7b2..4d9ab7decb 100644 --- a/internal/vpn/server.go +++ b/internal/vpn/server.go @@ -8,8 +8,6 @@ import ( "strings" "sync" - "github.com/sirupsen/logrus" - "github.com/skycoin/skywire-utilities/pkg/netutil" "github.com/skycoin/skywire/pkg/app" "github.com/skycoin/skywire/pkg/app/launcher" @@ -20,7 +18,6 @@ type Server struct { cfg ServerConfig lisMx sync.Mutex lis net.Listener - log logrus.FieldLogger serveOnce sync.Once ipGen *IPGenerator defaultNetworkInterface string @@ -32,11 +29,10 @@ type Server struct { } // NewServer creates VPN server instance. -func NewServer(cfg ServerConfig, l logrus.FieldLogger, appCl *app.Client) (*Server, error) { +func NewServer(cfg ServerConfig, appCl *app.Client) (*Server, error) { var defaultNetworkIfc string s := &Server{ cfg: cfg, - log: l, ipGen: NewIPGenerator(), appCl: appCl, } @@ -57,14 +53,14 @@ func NewServer(cfg ServerConfig, l logrus.FieldLogger, appCl *app.Client) (*Serv defaultNetworkIfc = defaultNetworkIfcs } - l.Infof("Got default network interface: %s", defaultNetworkIfc) + fmt.Printf("Got default network interface: %s\n", defaultNetworkIfc) defaultNetworkIfcIPs, err := netutil.NetworkInterfaceIPs(defaultNetworkIfc) if err != nil { return nil, fmt.Errorf("error getting IPs of interface %s: %w", defaultNetworkIfc, err) } - l.Infof("Got IPs of interface %s: %v", defaultNetworkIfc, defaultNetworkIfcIPs) + fmt.Printf("Got IPs of interface %s: %v\n", defaultNetworkIfc, defaultNetworkIfcIPs) ipv4ForwardingVal, err := GetIPv4ForwardingValue() if err != nil { @@ -75,15 +71,15 @@ func NewServer(cfg ServerConfig, l logrus.FieldLogger, appCl *app.Client) (*Serv return nil, fmt.Errorf("error getting IPv6 forwarding value") } - l.Infoln("Old IP forwarding values:") - l.Infof("IPv4: %s, IPv6: %s", ipv4ForwardingVal, ipv6ForwardingVal) + fmt.Println("Old IP forwarding values:") + fmt.Printf("IPv4: %s, IPv6: %s\n", ipv4ForwardingVal, ipv6ForwardingVal) iptablesForwarPolicy, err := GetIPTablesForwardPolicy() if err != nil { return nil, fmt.Errorf("error getting iptables forward policy: %w", err) } - l.Infof("Old iptables forward policy: %s", iptablesForwarPolicy) + fmt.Printf("Old iptables forward policy: %s\n", iptablesForwarPolicy) s.defaultNetworkInterface = defaultNetworkIfc s.defaultNetworkInterfaceIPs = defaultNetworkIfcIPs @@ -103,7 +99,7 @@ func (s *Server) Serve(l net.Listener) error { serveErr = fmt.Errorf("error enabling IPv4 forwarding: %w", err) return } - s.log.Infoln("Set IPv4 forwarding = 1") + fmt.Println("Set IPv4 forwarding = 1") defer func() { s.revertIPv4ForwardingValue() }() @@ -112,7 +108,7 @@ func (s *Server) Serve(l net.Listener) error { serveErr = fmt.Errorf("error enabling IPv6 forwarding: %w", err) return } - s.log.Infoln("Set IPv6 forwarding = 1") + fmt.Println("Set IPv6 forwarding = 1") defer func() { s.revertIPv6ForwardingValue() }() @@ -122,7 +118,7 @@ func (s *Server) Serve(l net.Listener) error { return } - s.log.Infoln("Enabled IP masquerading") + fmt.Println("Enabled IP masquerading") defer func() { s.disableIPMasquerading() @@ -132,7 +128,7 @@ func (s *Server) Serve(l net.Listener) error { serveErr = fmt.Errorf("error settings iptables forward policy to ACCEPT") return } - s.log.Infoln("Set iptables forward policy to ACCEPT") + fmt.Println("Set iptables forward policy to ACCEPT") defer func() { s.restoreIPTablesForwardPolicy() @@ -179,39 +175,39 @@ func (s *Server) Close() error { func (s *Server) revertIPv4ForwardingValue() { if err := SetIPv4ForwardingValue(s.ipv4ForwardingVal); err != nil { - s.log.WithError(err).Errorln("Error reverting IPv4 forwarding") + print(fmt.Sprintf("Error reverting IPv4 forwarding: %v", err)) } else { - s.log.Infof("Set IPv4 forwarding = %s", s.ipv4ForwardingVal) + fmt.Printf("Set IPv4 forwarding = %s\n", s.ipv4ForwardingVal) } } func (s *Server) revertIPv6ForwardingValue() { if err := SetIPv6ForwardingValue(s.ipv6ForwardingVal); err != nil { - s.log.WithError(err).Errorln("Error reverting IPv6 forwarding") + print(fmt.Sprintf("Error reverting IPv6 forwarding: %v", err)) } else { - s.log.Infof("Set IPv6 forwarding = %s", s.ipv6ForwardingVal) + fmt.Printf("Set IPv6 forwarding = %s\n", s.ipv6ForwardingVal) } } func (s *Server) disableIPMasquerading() { if err := DisableIPMasquerading(s.defaultNetworkInterface); err != nil { - s.log.WithError(err).Errorf("Error disabling IP masquerading for %s", s.defaultNetworkInterface) + print(fmt.Sprintf("Error disabling IP masquerading for %s: %v", s.defaultNetworkInterface, err)) } else { - s.log.Infof("Disabled IP masquerading for %s", s.defaultNetworkInterface) + fmt.Printf("Disabled IP masquerading for %s\n", s.defaultNetworkInterface) } } func (s *Server) restoreIPTablesForwardPolicy() { if err := SetIPTablesForwardPolicy(s.iptablesForwardPolicy); err != nil { - s.log.WithError(err).Errorf("Error restoring iptables forward policy to %s", s.iptablesForwardPolicy) + print(fmt.Sprintf("Error restoring iptables forward policy to %s: %v", s.iptablesForwardPolicy, err)) } else { - s.log.Infof("Restored iptables forward policy to %s", s.iptablesForwardPolicy) + fmt.Printf("Restored iptables forward policy to %s\n", s.iptablesForwardPolicy) } } func (s *Server) closeConn(conn net.Conn) { if err := conn.Close(); err != nil { - s.log.WithError(err).Errorf("Error closing client %s connection", conn.RemoteAddr()) + print(fmt.Sprintf("Error closing client %s connection: %v", conn.RemoteAddr(), err)) } } @@ -220,27 +216,26 @@ func (s *Server) serveConn(conn net.Conn) { tunIP, tunGateway, allowTrafficToLocalNet, err := s.shakeHands(conn) if err != nil { - s.log.WithError(err).Errorf("Error negotiating with client %s", conn.RemoteAddr()) + print(fmt.Sprintf("Error negotiating with client %s: %v", conn.RemoteAddr(), err)) return } defer allowTrafficToLocalNet() tun, err := newTUNDevice() if err != nil { - s.log.WithError(err).Errorln("Error allocating TUN interface") + print(fmt.Sprintf("Error allocating TUN interface: %v", err)) return } defer func() { - tunName := tun.Name() if err := tun.Close(); err != nil { - s.log.WithError(err).Errorf("Error closing TUN %s", tunName) + print(fmt.Sprintf("Error closing TUN %s: %v", tun.Name(), err)) } }() - s.log.Infof("Allocated TUN %s", tun.Name()) + fmt.Printf("Allocated TUN %s", tun.Name()) if err := SetupTUN(tun.Name(), tunIP.String()+TUNNetmaskCIDR, tunGateway.String(), TUNMTU); err != nil { - s.log.WithError(err).Errorf("Error setting up TUN %s", tun.Name()) + print(fmt.Sprintf("Error setting up TUN %s: %v", tun.Name(), err)) return } @@ -250,14 +245,14 @@ func (s *Server) serveConn(conn net.Conn) { defer close(connToTunDoneCh) if _, err := io.Copy(tun, conn); err != nil { - s.log.WithError(err).Errorf("Error resending traffic from VPN client to TUN %s", tun.Name()) + print(fmt.Sprintf("Error resending traffic from VPN client to TUN %s: %v", tun.Name(), err)) } }() go func() { defer close(tunToConnCh) if _, err := io.Copy(conn, tun); err != nil { - s.log.WithError(err).Errorf("Error resending traffic from TUN %s to VPN client", tun.Name()) + print(fmt.Sprintf("Error resending traffic from TUN %s to VPN client: %v", tun.Name(), err)) } }() @@ -277,7 +272,7 @@ func (s *Server) shakeHands(conn net.Conn) (tunIP, tunGateway net.IP, unsecureVP // default value unsecureVPN = func() {} - s.log.Debugf("Got client hello: %v", cHello) + fmt.Printf("Got client hello: %v", cHello) if s.cfg.Passcode != "" && cHello.Passcode != s.cfg.Passcode { s.sendServerErrHello(conn, HandshakeStatusForbidden) @@ -327,7 +322,7 @@ func (s *Server) shakeHands(conn net.Conn) (tunIP, tunGateway net.IP, unsecureVP unsecureVPN = func() { if err := AllowIPToLocalNetwork(cTUNIP, sTUNIP); err != nil { - s.log.WithError(err).Errorln("Error allowing traffic to local network") + print(fmt.Sprintf("Error allowing traffic to local network: %v", err)) } } } @@ -364,7 +359,7 @@ func (s *Server) sendServerErrHello(conn net.Conn, status HandshakeStatus) { } if err := WriteJSON(conn, &sHello); err != nil { - s.log.WithError(err).Errorln("Error sending server hello") + print(fmt.Sprintf("Error sending server hello: %v", err)) } } diff --git a/pkg/app/appcommon/log_store.go b/pkg/app/appcommon/log_store.go index c608576835..39c33523d1 100644 --- a/pkg/app/appcommon/log_store.go +++ b/pkg/app/appcommon/log_store.go @@ -10,8 +10,9 @@ import ( "time" log "github.com/sirupsen/logrus" - "github.com/skycoin/skycoin/src/util/logging" "go.etcd.io/bbolt" + + "github.com/skycoin/skywire-utilities/pkg/logging" ) const ( diff --git a/pkg/app/appdisc/factory.go b/pkg/app/appdisc/factory.go index b17b623654..fd0e94fab3 100644 --- a/pkg/app/appdisc/factory.go +++ b/pkg/app/appdisc/factory.go @@ -4,9 +4,9 @@ import ( "net/http" "github.com/sirupsen/logrus" - "github.com/skycoin/skycoin/src/util/logging" "github.com/skycoin/skywire-utilities/pkg/cipher" + "github.com/skycoin/skywire-utilities/pkg/logging" utilenv "github.com/skycoin/skywire-utilities/pkg/skyenv" "github.com/skycoin/skywire/pkg/app/appcommon" "github.com/skycoin/skywire/pkg/servicedisc" diff --git a/pkg/app/appevent/broadcaster.go b/pkg/app/appevent/broadcaster.go index 664bf27114..6032c90d2a 100644 --- a/pkg/app/appevent/broadcaster.go +++ b/pkg/app/appevent/broadcaster.go @@ -6,7 +6,8 @@ import ( "time" "github.com/sirupsen/logrus" - "github.com/skycoin/skycoin/src/util/logging" + + "github.com/skycoin/skywire-utilities/pkg/logging" ) // Broadcaster combines multiple RPCClients (which connects to the RPCGateway of the apps). diff --git a/pkg/app/appevent/rpc.go b/pkg/app/appevent/rpc.go index 3da1c9fad5..59cf366e75 100644 --- a/pkg/app/appevent/rpc.go +++ b/pkg/app/appevent/rpc.go @@ -7,8 +7,8 @@ import ( "net/rpc" "github.com/sirupsen/logrus" - "github.com/skycoin/skycoin/src/util/logging" + "github.com/skycoin/skywire-utilities/pkg/logging" "github.com/skycoin/skywire/pkg/app/appcommon" ) diff --git a/pkg/app/appnet/skywire_networker.go b/pkg/app/appnet/skywire_networker.go index 4f86e6dc05..dd89cd4996 100644 --- a/pkg/app/appnet/skywire_networker.go +++ b/pkg/app/appnet/skywire_networker.go @@ -113,14 +113,14 @@ func (r *SkywireNetworker) serveRouteGroup(ctx context.Context) error { conn, err := r.r.AcceptRoutes(ctx) if err != nil { - log.WithError(err).Info("Stopped accepting routes.") + log.WithError(err).Debug("Stopped accepting routes.") return err } log. WithField("local", conn.LocalAddr()). WithField("remote", conn.RemoteAddr()). - Info("Accepted route group.") + Debug("Accepted route group.") go r.serve(conn) } diff --git a/pkg/app/appserver/proc.go b/pkg/app/appserver/proc.go index c11dd10e5e..75ff5a4dec 100644 --- a/pkg/app/appserver/proc.go +++ b/pkg/app/appserver/proc.go @@ -14,8 +14,9 @@ import ( "time" ipc "github.com/james-barrow/golang-ipc" - "github.com/skycoin/skycoin/src/util/logging" + "github.com/sirupsen/logrus" + "github.com/skycoin/skywire-utilities/pkg/logging" "github.com/skycoin/skywire/pkg/app/appcommon" "github.com/skycoin/skywire/pkg/app/appdisc" "github.com/skycoin/skywire/pkg/app/appnet" @@ -84,8 +85,8 @@ func NewProc(mLog *logging.MasterLogger, conf appcommon.ProcConfig, disc appdisc cmd.Dir = conf.ProcWorkDir appLog, appLogDB := appcommon.NewProcLogger(conf, mLog) - cmd.Stdout = appLog.WithField("_module", moduleName).WithField("func", "(STDOUT)").Writer() - cmd.Stderr = appLog.WithField("_module", moduleName).WithField("func", "(STDERR)").Writer() + cmd.Stdout = appLog.WithField("_module", moduleName).WithField("func", "(STDOUT)").WriterLevel(logrus.DebugLevel) + cmd.Stderr = appLog.WithField("_module", moduleName).WithField("func", "(STDERR)").WriterLevel(logrus.ErrorLevel) p := &Proc{ disc: disc, @@ -157,7 +158,7 @@ func (p *Proc) awaitConn() bool { go rpcS.ServeConn(p.conn) - p.log.Info("Associated and serving proc conn.") + p.log.Debug("Associated and serving proc conn.") return true } diff --git a/pkg/app/appserver/proc_manager.go b/pkg/app/appserver/proc_manager.go index dc359b97d4..7d1e9dcbb4 100644 --- a/pkg/app/appserver/proc_manager.go +++ b/pkg/app/appserver/proc_manager.go @@ -10,7 +10,7 @@ import ( "sync" "time" - "github.com/skycoin/skycoin/src/util/logging" + "github.com/skycoin/skywire-utilities/pkg/logging" "github.com/skycoin/skywire/pkg/app/appcommon" "github.com/skycoin/skywire/pkg/app/appdisc" @@ -122,7 +122,7 @@ func (m *procManager) serve() { if err != nil { if !isDone(m.done) { m.log.WithError(err).WithField("remote_addr", conn.RemoteAddr()). - Info("Unexpected error occurred when accepting app conn.") + Debug("Unexpected error occurred when accepting app conn.") } return } @@ -167,7 +167,7 @@ func (m *procManager) handleConn(conn net.Conn) bool { log.Error("Failed to associate conn with proc.") return false } - log.Info("Accepted proc conn.") + log.Debug("Accepted proc conn.") return true } @@ -350,7 +350,7 @@ func (m *procManager) stopAll() { log.WithError(err).Error("App stopped with unexpected error.") continue } - log.Infof("App stopped successfully.") + log.Debug("App stopped successfully.") } m.procs = make(map[string]*Proc) diff --git a/pkg/app/appserver/rpc_ingress_gateway.go b/pkg/app/appserver/rpc_ingress_gateway.go index 881d5f6bff..d50dc78fe8 100644 --- a/pkg/app/appserver/rpc_ingress_gateway.go +++ b/pkg/app/appserver/rpc_ingress_gateway.go @@ -7,7 +7,7 @@ import ( "net" "time" - "github.com/skycoin/skycoin/src/util/logging" + "github.com/skycoin/skywire-utilities/pkg/logging" "github.com/skycoin/skywire/pkg/app/appnet" "github.com/skycoin/skywire/pkg/app/idmanager" diff --git a/pkg/app/appserver/rpc_ingress_gateway_test.go b/pkg/app/appserver/rpc_ingress_gateway_test.go index 9655e5da7e..6249a1b784 100644 --- a/pkg/app/appserver/rpc_ingress_gateway_test.go +++ b/pkg/app/appserver/rpc_ingress_gateway_test.go @@ -11,11 +11,11 @@ import ( "time" "github.com/skycoin/dmsg/pkg/dmsg" - "github.com/skycoin/skycoin/src/util/logging" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" "github.com/skycoin/skywire-utilities/pkg/cipher" + "github.com/skycoin/skywire-utilities/pkg/logging" "github.com/skycoin/skywire/internal/testhelpers" "github.com/skycoin/skywire/pkg/app/appcommon" "github.com/skycoin/skywire/pkg/app/appnet" diff --git a/pkg/app/client_test.go b/pkg/app/client_test.go index 81b575aec7..5755bef9a5 100644 --- a/pkg/app/client_test.go +++ b/pkg/app/client_test.go @@ -4,10 +4,10 @@ import ( "errors" "testing" - "github.com/skycoin/skycoin/src/util/logging" "github.com/stretchr/testify/require" "github.com/skycoin/skywire-utilities/pkg/cipher" + "github.com/skycoin/skywire-utilities/pkg/logging" "github.com/skycoin/skywire/pkg/app/appcommon" "github.com/skycoin/skywire/pkg/app/appnet" "github.com/skycoin/skywire/pkg/app/appserver" diff --git a/pkg/app/conn_test.go b/pkg/app/conn_test.go index 5b25497d76..fd3506cee6 100644 --- a/pkg/app/conn_test.go +++ b/pkg/app/conn_test.go @@ -7,11 +7,11 @@ import ( "net/rpc" "testing" - "github.com/skycoin/skycoin/src/util/logging" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" "golang.org/x/net/nettest" + "github.com/skycoin/skywire-utilities/pkg/logging" "github.com/skycoin/skywire/internal/testhelpers" "github.com/skycoin/skywire/pkg/app/appcommon" "github.com/skycoin/skywire/pkg/app/appnet" diff --git a/pkg/app/launcher/app_state.go b/pkg/app/launcher/app_state.go index d52165fdd0..ea457fc7fd 100644 --- a/pkg/app/launcher/app_state.go +++ b/pkg/app/launcher/app_state.go @@ -37,8 +37,8 @@ const ( // AppDetailedStatusVPNConnecting is set during VPN-client session establishment (including handshake). AppDetailedStatusVPNConnecting = "Connecting" - // AppDetailedStatusVPNReconnecting is set after connection failure in VPN-client, during reconnection. - AppDetailedStatusVPNReconnecting = "Connection failed, reconnecting" + // AppDetailedStatusReconnecting is set after connection failure, during reconnection. + AppDetailedStatusReconnecting = "Connection failed, reconnecting" // AppDetailedStatusShuttingDown is set during shutdown. AppDetailedStatusShuttingDown = "Shutting down" diff --git a/pkg/app/launcher/launcher.go b/pkg/app/launcher/launcher.go index 3725cbc21e..ee6ddcf2b2 100644 --- a/pkg/app/launcher/launcher.go +++ b/pkg/app/launcher/launcher.go @@ -191,7 +191,7 @@ func (l *Launcher) AppState(name string) (*AppState, bool) { state.Status = AppStatusStarting } switch state.DetailedStatus { - case AppDetailedStatusVPNConnecting, AppDetailedStatusStarting, AppDetailedStatusVPNReconnecting: + case AppDetailedStatusVPNConnecting, AppDetailedStatusStarting, AppDetailedStatusReconnecting: state.Status = AppStatusStarting } } diff --git a/pkg/app/listener_test.go b/pkg/app/listener_test.go index 911d479ebe..a9fda207e8 100644 --- a/pkg/app/listener_test.go +++ b/pkg/app/listener_test.go @@ -4,10 +4,10 @@ import ( "errors" "testing" - "github.com/skycoin/skycoin/src/util/logging" "github.com/stretchr/testify/require" "github.com/skycoin/skywire-utilities/pkg/cipher" + "github.com/skycoin/skywire-utilities/pkg/logging" "github.com/skycoin/skywire/pkg/app/appnet" "github.com/skycoin/skywire/pkg/app/appserver" "github.com/skycoin/skywire/pkg/app/idmanager" diff --git a/pkg/dmsgc/dmsgc.go b/pkg/dmsgc/dmsgc.go index 5cb1f2fa1b..7c95d823c8 100644 --- a/pkg/dmsgc/dmsgc.go +++ b/pkg/dmsgc/dmsgc.go @@ -6,9 +6,9 @@ import ( "github.com/skycoin/dmsg/pkg/disc" "github.com/skycoin/dmsg/pkg/dmsg" - "github.com/skycoin/skycoin/src/util/logging" "github.com/skycoin/skywire-utilities/pkg/cipher" + "github.com/skycoin/skywire-utilities/pkg/logging" "github.com/skycoin/skywire/pkg/app/appevent" ) diff --git a/pkg/restart/restart_test.go b/pkg/restart/restart_test.go index 487b1e1515..2f7e27b4ae 100644 --- a/pkg/restart/restart_test.go +++ b/pkg/restart/restart_test.go @@ -11,9 +11,10 @@ import ( "testing" "time" - "github.com/skycoin/skycoin/src/util/logging" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + + "github.com/skycoin/skywire-utilities/pkg/logging" ) func TestCaptureContext(t *testing.T) { diff --git a/pkg/routefinder/rfclient/client.go b/pkg/routefinder/rfclient/client.go index 36bffad2e0..9fb7da0203 100644 --- a/pkg/routefinder/rfclient/client.go +++ b/pkg/routefinder/rfclient/client.go @@ -11,7 +11,7 @@ import ( "strings" "time" - "github.com/skycoin/skycoin/src/util/logging" + "github.com/skycoin/skywire-utilities/pkg/logging" "github.com/skycoin/skywire/pkg/routing" ) diff --git a/pkg/router/route_group.go b/pkg/router/route_group.go index 280d3f4c07..93a6344fbe 100644 --- a/pkg/router/route_group.go +++ b/pkg/router/route_group.go @@ -13,8 +13,8 @@ import ( "time" "github.com/skycoin/dmsg/pkg/ioutil" - "github.com/skycoin/skycoin/src/util/logging" + "github.com/skycoin/skywire-utilities/pkg/logging" "github.com/skycoin/skywire/pkg/routing" "github.com/skycoin/skywire/pkg/transport" "github.com/skycoin/skywire/pkg/util/deadline" @@ -124,6 +124,7 @@ func NewRouteGroup(cfg *RouteGroupConfig, rt routing.Table, desc routing.RouteDe if mLoggger != nil { logger = mLoggger.PackageLogger(fmt.Sprintf("RouteGroup %s", desc.String())) } + rg := &RouteGroup{ cfg: cfg, logger: logger, @@ -318,7 +319,7 @@ func (rg *RouteGroup) write(data []byte, tp *transport.ManagedTransport, rule ro return 0, err } - rg.logger.Debugf("Writing packet of type %s, route ID %d and next ID %d", packet.Type(), + rg.logger.WithField("func", "RouteGroup.write").Tracef("Writing packet of type %s, route ID %d and next ID %d", packet.Type(), rule.KeyRouteID(), rule.NextRouteID()) ctx, cancel := context.WithCancel(context.Background()) @@ -367,7 +368,9 @@ func (rg *RouteGroup) writePacket(ctx context.Context, tp *transport.ManagedTran } if err := rg.rt.UpdateActivity(ruleID); err != nil { - rg.logger.WithError(err).Errorf("error updating activity of rule %d", ruleID) + if !rg.isClosed() { + rg.logger.WithError(err).Errorf("error updating activity of rule %d", ruleID) + } } } @@ -446,7 +449,7 @@ func (rg *RouteGroup) servicePacketLoop(name string, interval time.Duration, f s for { select { case <-rg.remoteClosed: - rg.logger.Infof("Remote got closed, stopping %s loop", name) + rg.logger.Debugf("Remote got closed, stopping %s loop", name) return case <-ticker.C: f(interval) @@ -514,11 +517,11 @@ func (rg *RouteGroup) sendHandshake(encrypt bool) error { err := rg.writePacket(context.Background(), tp, packet, rule.KeyRouteID()) if err == nil { - rg.logger.Infof("Sent handshake via transport %v", tp.Entry.ID) + rg.logger.Debugf("Sent handshake via transport %v", tp.Entry.ID) return nil } - rg.logger.Infof("Failed to send handshake via transport %v: %v [%v/%v]", + rg.logger.Debugf("Failed to send handshake via transport %v: %v [%v/%v]", tp.Entry.ID, err, i+1, len(rg.tps)) } @@ -640,7 +643,7 @@ func (rg *RouteGroup) handleDataPacket(packet routing.Packet) error { } func (rg *RouteGroup) handleClosePacket(code routing.CloseCode) error { - rg.logger.Infof("Got close packet with code %d", code) + rg.logger.Debugf("Got close packet with code %d", code) if rg.isCloseInitiator() { // this route group initiated close loop and got response diff --git a/pkg/router/route_group_test.go b/pkg/router/route_group_test.go index 8465ea6c0c..c3eba2c0f0 100644 --- a/pkg/router/route_group_test.go +++ b/pkg/router/route_group_test.go @@ -3,10 +3,10 @@ package router import ( "testing" - "github.com/skycoin/skycoin/src/util/logging" "github.com/stretchr/testify/require" "github.com/skycoin/skywire-utilities/pkg/cipher" + "github.com/skycoin/skywire-utilities/pkg/logging" "github.com/skycoin/skywire/pkg/routing" ) diff --git a/pkg/router/router.go b/pkg/router/router.go index 415d61a0b9..a78422e2a1 100644 --- a/pkg/router/router.go +++ b/pkg/router/router.go @@ -14,9 +14,9 @@ import ( "github.com/skycoin/dmsg/pkg/dmsg" "github.com/skycoin/dmsg/pkg/noise" - "github.com/skycoin/skycoin/src/util/logging" "github.com/skycoin/skywire-utilities/pkg/cipher" + "github.com/skycoin/skywire-utilities/pkg/logging" "github.com/skycoin/skywire/pkg/routefinder/rfclient" "github.com/skycoin/skywire/pkg/routing" "github.com/skycoin/skywire/pkg/setup/setupclient" @@ -299,7 +299,7 @@ func (r *router) DialRoutes( nrg.rg.startOffServiceLoops() - r.logger.Infof("Created new routes to %s on port %d", rPK, lPort) + r.logger.Debugf("Created new routes to %s on port %d", rPK, lPort) return nrg, nil } @@ -355,7 +355,7 @@ func (r *router) AcceptRoutes(ctx context.Context) (net.Conn, error) { // Serve starts transport listening loop. func (r *router) Serve(ctx context.Context) error { - r.logger.Info("Starting router") + r.logger.Debug("Starting router") go r.serveTransportManager(ctx) @@ -369,7 +369,7 @@ func (r *router) serveTransportManager(ctx context.Context) { packet, err := r.tm.ReadPacket() if err != nil { if err == transport.ErrNotServing { - r.logger.WithError(err).Info("Stopped reading packets") + r.logger.WithError(err).Debug("Stopped reading packets") return } @@ -394,7 +394,7 @@ func (r *router) serveSetup() { if err != nil { log := r.logger.WithError(err) if errors.Is(err, dmsg.ErrEntityClosed) { - log.Info("Setup client stopped serving.") + log.Debug("Setup client stopped serving.") return } log.Error("Setup client stopped serving due to unexpected error.") @@ -407,14 +407,14 @@ func (r *router) serveSetup() { continue } - r.logger.Infof("handling setup request: setupPK(%s)", remotePK) + r.logger.Debugf("handling setup request: setupPK(%s)", remotePK) go r.rpcSrv.ServeConn(conn) } } func (r *router) saveRouteGroupRules(rules routing.EdgeRules, nsConf noise.Config) (*NoiseRouteGroup, error) { - r.logger.Infof("Saving route group rules with desc: %s", &rules.Desc) + r.logger.Debugf("Saving route group rules with desc: %s", &rules.Desc) // When route group is wrapped with noise, it's put into `nrgs`. but before that, // in the process of wrapping we still need to use this route group to handle @@ -433,7 +433,7 @@ func (r *router) saveRouteGroupRules(rules routing.EdgeRules, nsConf noise.Confi // we need to close currently existing wrapped rg if there's one nrg, ok := r.rgsNs[rules.Desc] - r.logger.Infof("Creating new route group rule with desc: %s", &rules.Desc) + r.logger.Debugf("Creating new route group rule with desc: %s", &rules.Desc) rg := NewRouteGroup(DefaultRouteGroupConfig(), r.rt, rules.Desc, r.mLogger) rg.appendRules(rules.Forward, rules.Reverse, r.tm.Transport(rules.Forward.NextTransportID())) // we put raw rg so it can be accessible to the router when handshake packets come in @@ -481,7 +481,7 @@ func (r *router) saveRouteGroupRules(rules routing.EdgeRules, nsConf noise.Confi if ok && nrg != nil { // if already functioning wrapped rg exists, we safely close it here - r.logger.Infof("Noise route group with desc %s already exists, closing the old one and replacing...", &rules.Desc) + r.logger.Debugf("Noise route group with desc %s already exists, closing the old one and replacing...", &rules.Desc) if err := nrg.Close(); err != nil { r.logger.Errorf("Error closing already existing noise route group: %v", err) @@ -542,19 +542,19 @@ func (r *router) handleDataHandshakePacket(ctx context.Context, packet routing.P if err != nil { return err } - + log := r.logger.WithField("func", "router.handleDataHandshakePacket") if rt := rule.Type(); rt == routing.RuleForward || rt == routing.RuleIntermediary { - r.logger.Debugf("Handling packet of type %s with route ID %d and next ID %d", packet.Type(), + log.Tracef("Handling packet of type %s with route ID %d and next ID %d", packet.Type(), packet.RouteID(), rule.NextRouteID()) return r.forwardPacket(ctx, packet, rule) } - r.logger.Debugf("Handling packet of type %s with route ID %d", packet.Type(), packet.RouteID()) + log.Tracef("Handling packet of type %s with route ID %d", packet.Type(), packet.RouteID()) desc := rule.RouteDescriptor() nrg, ok := r.noiseRouteGroup(desc) - r.logger.Debugf("Handling packet with descriptor %s", &desc) + log.Tracef("Handling packet with descriptor %s", &desc) if ok { if nrg == nil { @@ -562,7 +562,7 @@ func (r *router) handleDataHandshakePacket(ctx context.Context, packet routing.P } // in this case we have already initialized nrg and may use it straightforward - r.logger.Debugf("Got new remote packet with size %d and route ID %d. Using rule: %s", + log.Tracef("Got new remote packet with size %d and route ID %d. Using rule: %s", len(packet.Payload()), packet.RouteID(), rule) return nrg.handlePacket(packet) @@ -574,7 +574,7 @@ func (r *router) handleDataHandshakePacket(ctx context.Context, packet routing.P rg, ok := r.initializingRouteGroup(desc) if !ok { // no route, just return error - r.logger.Infof("Descriptor not found for rule with type %s, descriptor: %s", rule.Type(), &desc) + log.Tracef("Descriptor not found for rule with type %s, descriptor: %s", rule.Type(), &desc) return errors.New("route descriptor does not exist") } @@ -583,7 +583,7 @@ func (r *router) handleDataHandshakePacket(ctx context.Context, packet routing.P } // handshake packet, handling with the raw rg - r.logger.Debugf("Got new remote packet with size %d and route ID %d. Using rule: %s", + log.Tracef("Got new remote packet with size %d and route ID %d. Using rule: %s", len(packet.Payload()), packet.RouteID(), rule) return rg.handlePacket(packet) @@ -592,7 +592,8 @@ func (r *router) handleDataHandshakePacket(ctx context.Context, packet routing.P func (r *router) handleClosePacket(ctx context.Context, packet routing.Packet) error { routeID := packet.RouteID() - r.logger.Debugf("Received close packet for route ID %v", routeID) + log := r.logger.WithField("func", "router.handleClosePacket") + log.Tracef("Received close packet for route ID %v", routeID) rule, err := r.GetRule(routeID) if err != nil { @@ -600,9 +601,9 @@ func (r *router) handleClosePacket(ctx context.Context, packet routing.Packet) e } if rule.Type() == routing.RuleReverse { - r.logger.Debugf("Handling packet of type %s with route ID %d", packet.Type(), packet.RouteID()) + log.Tracef("Handling packet of type %s with route ID %d", packet.Type(), packet.RouteID()) } else { - r.logger.Debugf("Handling packet of type %s with route ID %d and next ID %d", packet.Type(), + log.Tracef("Handling packet of type %s with route ID %d and next ID %d", packet.Type(), packet.RouteID(), rule.NextRouteID()) } @@ -612,17 +613,17 @@ func (r *router) handleClosePacket(ctx context.Context, packet routing.Packet) e }() if t := rule.Type(); t == routing.RuleIntermediary { - r.logger.Debugln("Handling intermediary close packet") + log.Traceln("Handling intermediary close packet") return r.forwardPacket(ctx, packet, rule) } desc := rule.RouteDescriptor() nrg, ok := r.noiseRouteGroup(desc) - r.logger.Debugf("Handling close packet with descriptor %s", &desc) + log.Tracef("Handling close packet with descriptor %s", &desc) if !ok { - r.logger.Infof("Descriptor not found for rule with type %s, descriptor: %s", rule.Type(), &desc) + log.Tracef("Descriptor not found for rule with type %s, descriptor: %s", rule.Type(), &desc) return errors.New("route descriptor does not exist") } @@ -632,7 +633,7 @@ func (r *router) handleClosePacket(ctx context.Context, packet routing.Packet) e return errors.New("noiseRouteGroup is nil") } - r.logger.Debugf("Got new remote close packet with size %d and route ID %d. Using rule: %s", + log.Tracef("Got new remote close packet with size %d and route ID %d. Using rule: %s", len(packet.Payload()), packet.RouteID(), rule) closeCode := routing.CloseCode(packet.Payload()[0]) @@ -654,19 +655,20 @@ func (r *router) handleNetworkProbePacket(ctx context.Context, packet routing.Pa if err != nil { return err } + log := r.logger.WithField("func", "router.handleNetworkProbePacket") if rt := rule.Type(); rt == routing.RuleForward || rt == routing.RuleIntermediary { - r.logger.Debugf("Handling packet of type %s with route ID %d and next ID %d", packet.Type(), + log.Tracef("Handling packet of type %s with route ID %d and next ID %d", packet.Type(), packet.RouteID(), rule.NextRouteID()) return r.forwardPacket(ctx, packet, rule) } - r.logger.Debugf("Handling packet of type %s with route ID %d", packet.Type(), packet.RouteID()) + log.Tracef("Handling packet of type %s with route ID %d", packet.Type(), packet.RouteID()) desc := rule.RouteDescriptor() nrg, ok := r.noiseRouteGroup(desc) - r.logger.Debugf("Handling packet with descriptor %s", &desc) + log.Tracef("Handling packet with descriptor %s", &desc) if ok { if nrg == nil { @@ -674,7 +676,7 @@ func (r *router) handleNetworkProbePacket(ctx context.Context, packet routing.Pa } // in this case we have already initialized nrg and may use it straightforward - r.logger.Debugf("Got new remote packet with size %d and route ID %d. Using rule: %s", + log.Tracef("Got new remote packet with size %d and route ID %d. Using rule: %s", len(packet.Payload()), packet.RouteID(), rule) return nrg.handlePacket(packet) @@ -686,7 +688,7 @@ func (r *router) handleNetworkProbePacket(ctx context.Context, packet routing.Pa rg, ok := r.initializingRouteGroup(desc) if !ok { // no route, just return error - r.logger.Infof("Descriptor not found for rule with type %s, descriptor: %s", rule.Type(), &desc) + log.Tracef("Descriptor not found for rule with type %s, descriptor: %s", rule.Type(), &desc) return errors.New("route descriptor does not exist") } @@ -695,7 +697,7 @@ func (r *router) handleNetworkProbePacket(ctx context.Context, packet routing.Pa } // handshake packet, handling with the raw rg - r.logger.Debugf("Got new remote packet with size %d and route ID %d. Using rule: %s", + log.Tracef("Got new remote packet with size %d and route ID %d. Using rule: %s", len(packet.Payload()), packet.RouteID(), rule) return rg.handlePacket(packet) @@ -704,7 +706,8 @@ func (r *router) handleNetworkProbePacket(ctx context.Context, packet routing.Pa func (r *router) handleKeepAlivePacket(ctx context.Context, packet routing.Packet) error { routeID := packet.RouteID() - r.logger.Debugf("Received keepalive packet for route ID %v", routeID) + log := r.logger.WithField("func", "router.handleKeepAlivePacket") + log.Tracef("Received keepalive packet for route ID %v", routeID) rule, err := r.GetRule(routeID) if err != nil { @@ -712,20 +715,20 @@ func (r *router) handleKeepAlivePacket(ctx context.Context, packet routing.Packe } if rule.Type() == routing.RuleReverse { - r.logger.Debugf("Handling packet of type %s with route ID %d", packet.Type(), packet.RouteID()) + log.Tracef("Handling packet of type %s with route ID %d", packet.Type(), packet.RouteID()) } else { - r.logger.Debugf("Handling packet of type %s with route ID %d and next ID %d", packet.Type(), + log.Tracef("Handling packet of type %s with route ID %d and next ID %d", packet.Type(), packet.RouteID(), rule.NextRouteID()) } // propagate packet only for intermediary rule. forward rule workflow doesn't get here, // consume rules should be omitted, activity is already updated if t := rule.Type(); t == routing.RuleIntermediary { - r.logger.Debugln("Handling intermediary keep-alive packet") + log.Traceln("Handling intermediary keep-alive packet") return r.forwardPacket(ctx, packet, rule) } - r.logger.Debugf("Route ID %v found, updated activity", routeID) + log.Tracef("Route ID %v found, updated activity", routeID) return nil } @@ -766,8 +769,7 @@ func (r *router) Close() error { return nil } - r.logger.Info("Closing all App connections and RouteGroups") - + r.logger.Debug("Closing all App connections and RouteGroups") r.once.Do(func() { close(r.done) r.mx.Lock() @@ -853,7 +855,7 @@ func (r *router) fetchBestRoutes(src, dst cipher.PubKey, opts *DialOptions) (fwd opts = DefaultDialOptions() // nolint } - r.logger.Infof("Requesting new routes from %s to %s", src, dst) + r.logger.Debugf("Requesting new routes from %s to %s", src, dst) timer := time.NewTimer(retryDuration) defer timer.Stop() @@ -881,7 +883,7 @@ fetchRoutesAgain: } } - r.logger.Infof("Found routes Forward: %s. Reverse %s", paths[forward], paths[backward]) + r.logger.Debugf("Found routes Forward: %s. Reverse %s", paths[forward], paths[backward]) return paths[forward][0], paths[backward][0], nil } @@ -900,7 +902,7 @@ func (r *router) SaveRoutingRules(rules ...routing.Rule) error { return fmt.Errorf("routing table: %w", err) } - r.logger.Infof("Save new Routing Rule with ID %d %s", rule.KeyRouteID(), rule) + r.logger.Debugf("Save new Routing Rule with ID %d %s", rule.KeyRouteID(), rule) } return nil @@ -1029,8 +1031,10 @@ func (r *router) rulesGC() { log := r.logger.WithField("func", "router.rulesGC") removedRules := r.rt.CollectGarbage() - log.WithField("rules_count", len(removedRules)). - Debug("Removed rules.") + if len(removedRules) > 0 { + log.WithField("rules_count", len(removedRules)). + Debug("Removed rules.") + } for _, rule := range removedRules { r.removeRouteGroupOfRule(rule) @@ -1047,11 +1051,7 @@ func (r *router) removeRouteGroupOfRule(rule routing.Rule) { // really care about the other ones, other rules removal // doesn't affect our work here if rule.Type() != routing.RuleReverse { - log. - WithField("func", "removeRouteGroupOfRule"). - WithField("rule", rule.Type().String()). - Debug("Nothing to be done") - + log.Debug("Nothing to be done") return } diff --git a/pkg/router/router_test.go b/pkg/router/router_test.go index 5140908b8c..96bb73e0f5 100644 --- a/pkg/router/router_test.go +++ b/pkg/router/router_test.go @@ -7,8 +7,8 @@ import ( "testing" "github.com/sirupsen/logrus" - "github.com/skycoin/skycoin/src/util/logging" + "github.com/skycoin/skywire-utilities/pkg/logging" "github.com/skycoin/skywire/pkg/transport" ) diff --git a/pkg/router/routerclient/client.go b/pkg/router/routerclient/client.go index 252eccd7f7..722426a46f 100644 --- a/pkg/router/routerclient/client.go +++ b/pkg/router/routerclient/client.go @@ -7,9 +7,9 @@ import ( "net/rpc" "github.com/sirupsen/logrus" - "github.com/skycoin/skycoin/src/util/logging" "github.com/skycoin/skywire-utilities/pkg/cipher" + "github.com/skycoin/skywire-utilities/pkg/logging" "github.com/skycoin/skywire/pkg/routing" "github.com/skycoin/skywire/pkg/skyenv" "github.com/skycoin/skywire/pkg/transport/network" diff --git a/pkg/router/routerclient/client_test.go b/pkg/router/routerclient/client_test.go index 3aab610cb2..53256ae166 100644 --- a/pkg/router/routerclient/client_test.go +++ b/pkg/router/routerclient/client_test.go @@ -6,11 +6,11 @@ import ( "net/rpc" "testing" - "github.com/skycoin/skycoin/src/util/logging" "github.com/stretchr/testify/require" "golang.org/x/net/nettest" "github.com/skycoin/skywire-utilities/pkg/cipher" + "github.com/skycoin/skywire-utilities/pkg/logging" "github.com/skycoin/skywire/internal/testhelpers" "github.com/skycoin/skywire/pkg/router" "github.com/skycoin/skywire/pkg/routing" diff --git a/pkg/router/routerclient/map_test.go b/pkg/router/routerclient/map_test.go index 27ff19d625..1678a51838 100644 --- a/pkg/router/routerclient/map_test.go +++ b/pkg/router/routerclient/map_test.go @@ -10,13 +10,13 @@ import ( "time" "github.com/sirupsen/logrus" - "github.com/skycoin/skycoin/src/util/logging" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" "golang.org/x/net/nettest" "github.com/skycoin/skywire-utilities/pkg/cipher" + "github.com/skycoin/skywire-utilities/pkg/logging" "github.com/skycoin/skywire/pkg/router" "github.com/skycoin/skywire/pkg/routing" "github.com/skycoin/skywire/pkg/transport/network" diff --git a/pkg/router/rpc_gateway.go b/pkg/router/rpc_gateway.go index defd1d3363..b566904360 100644 --- a/pkg/router/rpc_gateway.go +++ b/pkg/router/rpc_gateway.go @@ -1,7 +1,7 @@ package router import ( - "github.com/skycoin/skycoin/src/util/logging" + "github.com/skycoin/skywire-utilities/pkg/logging" "github.com/skycoin/skywire/pkg/routing" ) diff --git a/pkg/router/rpc_gateway_test.go b/pkg/router/rpc_gateway_test.go index f8319149ad..1f0e05fd3e 100644 --- a/pkg/router/rpc_gateway_test.go +++ b/pkg/router/rpc_gateway_test.go @@ -3,10 +3,10 @@ package router import ( "testing" - "github.com/skycoin/skycoin/src/util/logging" "github.com/stretchr/testify/require" "github.com/skycoin/skywire-utilities/pkg/cipher" + "github.com/skycoin/skywire-utilities/pkg/logging" "github.com/skycoin/skywire/internal/testhelpers" "github.com/skycoin/skywire/pkg/routing" ) diff --git a/pkg/routing/table_test.go b/pkg/routing/table_test.go index 025b8fb81f..5704486959 100644 --- a/pkg/routing/table_test.go +++ b/pkg/routing/table_test.go @@ -7,9 +7,10 @@ import ( "time" "github.com/google/uuid" - "github.com/skycoin/skycoin/src/util/logging" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + + "github.com/skycoin/skywire-utilities/pkg/logging" ) func TestMain(m *testing.M) { diff --git a/pkg/servicedisc/autoconnect.go b/pkg/servicedisc/autoconnect.go index 78e01152eb..7a62804362 100644 --- a/pkg/servicedisc/autoconnect.go +++ b/pkg/servicedisc/autoconnect.go @@ -8,9 +8,9 @@ import ( "time" "github.com/sirupsen/logrus" - "github.com/skycoin/skycoin/src/util/logging" "github.com/skycoin/skywire-utilities/pkg/cipher" + "github.com/skycoin/skywire-utilities/pkg/logging" "github.com/skycoin/skywire-utilities/pkg/netutil" "github.com/skycoin/skywire/pkg/transport" "github.com/skycoin/skywire/pkg/transport/network" @@ -68,10 +68,12 @@ func (a *autoconnector) Run(ctx context.Context) (err error) { return err } - a.log.Infoln("Fetching public visors") + a.log.Debugln("Fetching public visors") addrs, err := a.fetchPubAddresses(ctx) if err != nil { - a.log.Errorf("Cannot fetch public services: %s", err) + if !errors.Is(context.Canceled, err) { + a.log.Errorf("Cannot fetch public services: %s", err) + } } // filter out any established transports diff --git a/pkg/servicedisc/client.go b/pkg/servicedisc/client.go index e783ad9cba..19a4132059 100644 --- a/pkg/servicedisc/client.go +++ b/pkg/servicedisc/client.go @@ -14,10 +14,10 @@ import ( "time" "github.com/sirupsen/logrus" - "github.com/skycoin/skycoin/src/util/logging" "github.com/skycoin/skywire-utilities/pkg/buildinfo" "github.com/skycoin/skywire-utilities/pkg/cipher" + "github.com/skycoin/skywire-utilities/pkg/logging" "github.com/skycoin/skywire-utilities/pkg/netutil" "github.com/skycoin/skywire/internal/httpauth" ) @@ -175,7 +175,7 @@ func (c *HTTPClient) RegisterEntry(ctx context.Context) error { return err } c.entry = entry - c.log.WithField("entry", c.entry).Debug("Entry registered successfully") + c.log.WithField("entry", c.entry.String()).Debug("Entry registered successfully") return nil } diff --git a/pkg/servicedisc/types.go b/pkg/servicedisc/types.go index e123b79566..4d8c5f58b0 100644 --- a/pkg/servicedisc/types.go +++ b/pkg/servicedisc/types.go @@ -119,3 +119,15 @@ func (p Service) Check() error { } return nil } + +func (p Service) String() string { + var serviceMap map[string]interface{} + + data, _ := json.Marshal(p) // nolint:errcheck + _ = json.Unmarshal(data, &serviceMap) // nolint:errcheck + + serviceMap["address"] = p.Addr.String() + + sString, _ := json.Marshal(serviceMap) // nolint:errcheck + return string(sString) +} diff --git a/pkg/setup/node.go b/pkg/setup/node.go index 8827ed225e..f986762bce 100644 --- a/pkg/setup/node.go +++ b/pkg/setup/node.go @@ -10,9 +10,9 @@ import ( "github.com/sirupsen/logrus" "github.com/skycoin/dmsg/pkg/disc" "github.com/skycoin/dmsg/pkg/dmsg" - "github.com/skycoin/skycoin/src/util/logging" "github.com/skycoin/skywire-utilities/pkg/cipher" + "github.com/skycoin/skywire-utilities/pkg/logging" "github.com/skycoin/skywire/pkg/router/routerclient" "github.com/skycoin/skywire/pkg/routing" "github.com/skycoin/skywire/pkg/setup/setupmetrics" diff --git a/pkg/setup/node_test.go b/pkg/setup/node_test.go index 3b6a48947b..b64ef6aae5 100644 --- a/pkg/setup/node_test.go +++ b/pkg/setup/node_test.go @@ -12,11 +12,11 @@ import ( "github.com/google/uuid" "github.com/sirupsen/logrus" - "github.com/skycoin/skycoin/src/util/logging" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "github.com/skycoin/skywire-utilities/pkg/cipher" + "github.com/skycoin/skywire-utilities/pkg/logging" "github.com/skycoin/skywire/pkg/routing" "github.com/skycoin/skywire/pkg/setup/setupmetrics" ) diff --git a/pkg/setup/rpc_gateway.go b/pkg/setup/rpc_gateway.go index 237a54cbad..ef15ac13d5 100644 --- a/pkg/setup/rpc_gateway.go +++ b/pkg/setup/rpc_gateway.go @@ -5,7 +5,7 @@ import ( "net" "time" - "github.com/skycoin/skycoin/src/util/logging" + "github.com/skycoin/skywire-utilities/pkg/logging" "github.com/skycoin/skywire-utilities/pkg/cipher" "github.com/skycoin/skywire/pkg/routing" diff --git a/pkg/setup/setupclient/client.go b/pkg/setup/setupclient/client.go index 83f4e0ee28..955eb8c1ee 100644 --- a/pkg/setup/setupclient/client.go +++ b/pkg/setup/setupclient/client.go @@ -7,9 +7,9 @@ import ( "net/rpc" "github.com/skycoin/dmsg/pkg/dmsg" - "github.com/skycoin/skycoin/src/util/logging" "github.com/skycoin/skywire-utilities/pkg/cipher" + "github.com/skycoin/skywire-utilities/pkg/logging" "github.com/skycoin/skywire/pkg/routing" "github.com/skycoin/skywire/pkg/skyenv" ) diff --git a/pkg/setup/setupclient/mock_route_group_dialer.go b/pkg/setup/setupclient/mock_route_group_dialer.go index 99df1f7030..281a630a3b 100644 --- a/pkg/setup/setupclient/mock_route_group_dialer.go +++ b/pkg/setup/setupclient/mock_route_group_dialer.go @@ -6,7 +6,7 @@ import ( context "context" dmsg "github.com/skycoin/dmsg/pkg/dmsg" - logging "github.com/skycoin/skycoin/src/util/logging" + logging "github.com/skycoin/skywire-utilities/pkg/logging" mock "github.com/stretchr/testify/mock" cipher "github.com/skycoin/skywire-utilities/pkg/cipher" diff --git a/pkg/setup/setupclient/wrappers.go b/pkg/setup/setupclient/wrappers.go index 9be9a96fbf..4f3fdf3ade 100644 --- a/pkg/setup/setupclient/wrappers.go +++ b/pkg/setup/setupclient/wrappers.go @@ -5,9 +5,9 @@ import ( "fmt" "github.com/skycoin/dmsg/pkg/dmsg" - "github.com/skycoin/skycoin/src/util/logging" "github.com/skycoin/skywire-utilities/pkg/cipher" + "github.com/skycoin/skywire-utilities/pkg/logging" "github.com/skycoin/skywire/pkg/routing" ) diff --git a/pkg/transport/handshake.go b/pkg/transport/handshake.go index b26d4f76b0..f784e7bade 100644 --- a/pkg/transport/handshake.go +++ b/pkg/transport/handshake.go @@ -8,7 +8,7 @@ import ( "io" "net/http" - "github.com/skycoin/skycoin/src/util/logging" + "github.com/skycoin/skywire-utilities/pkg/logging" "github.com/skycoin/skywire-utilities/pkg/cipher" "github.com/skycoin/skywire-utilities/pkg/httputil" diff --git a/pkg/transport/log.go b/pkg/transport/log.go index 3705f9d2da..fbb5c5c73c 100644 --- a/pkg/transport/log.go +++ b/pkg/transport/log.go @@ -13,7 +13,8 @@ import ( "sync/atomic" "github.com/google/uuid" - "github.com/skycoin/skycoin/src/util/logging" + + "github.com/skycoin/skywire-utilities/pkg/logging" ) // LogEntry represents a logging entry for a given Transport. diff --git a/pkg/transport/managed_transport.go b/pkg/transport/managed_transport.go index 8722ba09c5..f34a884449 100644 --- a/pkg/transport/managed_transport.go +++ b/pkg/transport/managed_transport.go @@ -11,7 +11,7 @@ import ( "sync/atomic" "time" - "github.com/skycoin/skycoin/src/util/logging" + "github.com/skycoin/skywire-utilities/pkg/logging" "github.com/skycoin/skywire-utilities/pkg/cipher" "github.com/skycoin/skywire-utilities/pkg/httputil" @@ -105,12 +105,12 @@ func (mt *ManagedTransport) Serve(readCh chan<- routing.Packet) { WithField("remote_pk", mt.rPK). WithField("tp_index", atomic.AddInt32(&mTpCount, 1)) - log.Info("Serving.") + log.Debug("Serving.") defer func() { mt.close() log.WithField("remaining_tps", atomic.AddInt32(&mTpCount, -1)). - Info("Stopped serving.") + Debug("Stopped serving.") }() go mt.readLoop(readCh) @@ -174,7 +174,6 @@ func (mt *ManagedTransport) isServing() bool { // It only returns an error if transport status update fails. func (mt *ManagedTransport) Close() (err error) { mt.close() - mt.log.Debug("Waiting for the waitgroup") mt.wg.Wait() return nil } @@ -196,14 +195,12 @@ func (mt *ManagedTransport) IsClosed() bool { // regular transport close operations should probably call it concurrently // need to find a way to handle this properly (done channel in return?) func (mt *ManagedTransport) close() { - mt.log.Debug("Closing...") select { case <-mt.done: return default: close(mt.done) } - mt.log.Debug("Locking transportMx") mt.transportMx.Lock() close(mt.transportCh) if mt.transport != nil { @@ -213,7 +210,6 @@ func (mt *ManagedTransport) close() { mt.transport = nil } mt.transportMx.Unlock() - mt.log.Debug("Unlocking transportMx") _ = mt.deleteFromDiscovery() //nolint:errcheck } @@ -396,20 +392,20 @@ func (mt *ManagedTransport) readPacket() (packet routing.Packet, err error) { } } - log.Debug("Awaiting packet...") + log.Trace("Awaiting packet...") h := make(routing.Packet, routing.PacketHeaderSize) if _, err = io.ReadFull(transport, h); err != nil { log.WithError(err).Debugf("Failed to read packet header.") return nil, err } - log.WithField("header_len", len(h)).WithField("header_raw", h).Debug("Read packet header.") + log.WithField("header_len", len(h)).WithField("header_raw", h).Trace("Read packet header.") p := make([]byte, h.Size()) if _, err = io.ReadFull(transport, p); err != nil { log.WithError(err).Debugf("Failed to read packet payload.") return nil, err } - log.WithField("payload_len", len(p)).Debug("Read packet payload.") + log.WithField("payload_len", len(p)).Trace("Read packet payload.") packet = append(h, p...) if n := len(packet); n > routing.PacketHeaderSize { @@ -419,7 +415,7 @@ func (mt *ManagedTransport) readPacket() (packet routing.Packet, err error) { log.WithField("type", packet.Type().String()). WithField("rt_id", packet.RouteID()). WithField("size", packet.Size()). - Debug("Received packet.") + Trace("Received packet.") return packet, nil } @@ -441,7 +437,7 @@ func (mt *ManagedTransport) logRecv(b uint64) { // and returns true if it was bigger than 0 func (mt *ManagedTransport) logMod() bool { if ops := atomic.SwapUint32(&mt.logUpdates, 0); ops > 0 { - mt.log.Infof("entry log: recording %d operations", ops) + mt.log.WithField("func", "ManagedTransport.logMod").Tracef("entry log: recording %d operations", ops) return true } return false diff --git a/pkg/transport/manager.go b/pkg/transport/manager.go index 305fd60a10..384efbf945 100644 --- a/pkg/transport/manager.go +++ b/pkg/transport/manager.go @@ -10,9 +10,9 @@ import ( "github.com/google/uuid" "github.com/skycoin/dmsg/pkg/dmsg" - "github.com/skycoin/skycoin/src/util/logging" "github.com/skycoin/skywire-utilities/pkg/cipher" + "github.com/skycoin/skywire-utilities/pkg/logging" "github.com/skycoin/skywire/pkg/app/appevent" "github.com/skycoin/skywire/pkg/routing" "github.com/skycoin/skywire/pkg/skyenv" @@ -94,7 +94,7 @@ func (tm *Manager) Serve(ctx context.Context) { tm.wg.Add(2) go tm.cleanupTransports(ctx) go tm.runReconnectPersistent(ctx) - tm.Logger.Info("transport manager is serving.") + tm.Logger.Debug("transport manager is serving.") } func (tm *Manager) runReconnectPersistent(ctx context.Context) { @@ -173,7 +173,7 @@ func (tm *Manager) runClient(ctx context.Context, netType network.Type) { tm.mx.Lock() client := tm.netClients[netType] tm.mx.Unlock() - tm.Logger.Infof("Serving %s network", client.Type()) + tm.Logger.Debugf("Serving %s network", client.Type()) err := client.Start() if err != nil { tm.Logger.WithError(err).Errorf("Failed to listen on %s network", client.Type()) @@ -184,7 +184,7 @@ func (tm *Manager) runClient(ctx context.Context, netType network.Type) { client.Type(), skyenv.TransportPort) return } - tm.Logger.Infof("listening on network: %s", client.Type()) + tm.Logger.Debugf("listening on network: %s", client.Type()) if client.Type() != network.DMSG { tm.wg.Add(1) } @@ -205,7 +205,7 @@ func (tm *Manager) acceptTransports(ctx context.Context, lis network.Listener, t if err := tm.acceptTransport(ctx, lis); err != nil { log := tm.Logger.WithError(err) if errors.Is(err, dmsg.ErrEntityClosed) { - log.Info("Dmsg client stopped serving.") + log.Debug("Dmsg client stopped serving.") return } if errors.Is(err, io.ErrClosedPipe) { @@ -225,7 +225,6 @@ func (tm *Manager) cleanupTransports(ctx context.Context) { select { case <-ticker.C: tm.mx.Lock() - tm.Logger.Debugf("Locked in cleanup") var toDelete []*ManagedTransport for _, tp := range tm.tps { if tp.IsClosed() { @@ -236,9 +235,8 @@ func (tm *Manager) cleanupTransports(ctx context.Context) { delete(tm.tps, tp.Entry.ID) } tm.mx.Unlock() - tm.Logger.Debugf("Unlocked in cleanup") if len(toDelete) > 0 { - tm.Logger.Infof("Deleted %d unused transport entries", len(toDelete)) + tm.Logger.Debugf("Deleted %d unused transport entries", len(toDelete)) } case <-ctx.Done(): case <-tm.done: @@ -270,12 +268,10 @@ func (tm *Manager) acceptTransport(ctx context.Context, lis network.Listener) er return err } - tm.Logger.Infof("recv transport request: type(%s) remote(%s)", lis.Network(), transport.RemotePK()) + tm.Logger.Debugf("recv transport request: type(%s) remote(%s)", lis.Network(), transport.RemotePK()) tm.mx.Lock() - tm.Logger.Debugf("Locked in accept") defer tm.mx.Unlock() - defer tm.Logger.Debugf("Unlocked in accept") if tm.isClosing() { return errors.New("transport.Manager is closing. Skipping incoming transport") @@ -308,10 +304,8 @@ func (tm *Manager) acceptTransport(ctx context.Context, lis network.Listener) er mTp.Serve(tm.readCh) tm.mx.Lock() - tm.Logger.Debugf("Locked in deleting after serve in accept") delete(tm.tps, mTp.Entry.ID) tm.mx.Unlock() - tm.Logger.Debugf("Locked in deleting after serve in accept") }() tm.tps[tpID] = mTp @@ -323,7 +317,7 @@ func (tm *Manager) acceptTransport(ctx context.Context, lis network.Listener) er return err } - tm.Logger.Infof("accepted tp: type(%s) remote(%s) tpID(%s) new(%v)", lis.Network(), transport.RemotePK(), tpID, !ok) + tm.Logger.Debugf("accepted tp: type(%s) remote(%s) tpID(%s) new(%v)", lis.Network(), transport.RemotePK(), tpID, !ok) return nil } @@ -444,11 +438,9 @@ func (tm *Manager) saveTransport(ctx context.Context, remote cipher.PubKey, netT } go mTp.Serve(tm.readCh) tm.mx.Lock() - tm.Logger.Debug("Locked in saveTransport") tm.tps[tpID] = mTp tm.mx.Unlock() - tm.Logger.Debug("Unlocked in saveTransport") - tm.Logger.Infof("saved transport: remote(%s) type(%s) tpID(%s)", remote, netType, tpID) + tm.Logger.Debugf("saved transport: remote(%s) type(%s) tpID(%s)", remote, netType, tpID) return mTp, nil } @@ -474,9 +466,7 @@ func (tm *Manager) STCPRRemoteAddrs() []string { // DeleteTransport deregisters the Transport of Transport ID in transport discovery and deletes it locally. func (tm *Manager) DeleteTransport(id uuid.UUID) { tm.mx.Lock() - tm.Logger.Debugf("Locked in DeleteTransport") defer tm.mx.Unlock() - defer tm.Logger.Debug("Unlocked in DeleteTransport") if tm.isClosing() { return @@ -536,8 +526,6 @@ func (tm *Manager) Close() { default: } close(tm.done) - tm.Logger.Info("transport manager is closing.") - defer tm.Logger.Info("transport manager closed.") tm.mx.Lock() defer tm.mx.Unlock() diff --git a/pkg/transport/manager_test.go b/pkg/transport/manager_test.go index e43437d044..77c80d8eae 100644 --- a/pkg/transport/manager_test.go +++ b/pkg/transport/manager_test.go @@ -6,10 +6,10 @@ import ( "os" "testing" - "github.com/skycoin/skycoin/src/util/logging" "github.com/stretchr/testify/require" "github.com/skycoin/skywire-utilities/pkg/cipher" + "github.com/skycoin/skywire-utilities/pkg/logging" "github.com/skycoin/skywire/pkg/transport" ) diff --git a/pkg/transport/network/addrresolver/client.go b/pkg/transport/network/addrresolver/client.go index 6dbbf5625f..f4983ecc85 100644 --- a/pkg/transport/network/addrresolver/client.go +++ b/pkg/transport/network/addrresolver/client.go @@ -16,10 +16,10 @@ import ( "time" "github.com/AudriusButkevicius/pfilter" - "github.com/skycoin/skycoin/src/util/logging" "github.com/xtaci/kcp-go" "github.com/skycoin/skywire-utilities/pkg/cipher" + "github.com/skycoin/skywire-utilities/pkg/logging" "github.com/skycoin/skywire-utilities/pkg/netutil" "github.com/skycoin/skywire/internal/httpauth" "github.com/skycoin/skywire/internal/packetfilter" @@ -115,7 +115,7 @@ func NewHTTP(remoteAddr string, pk cipher.PubKey, sk cipher.SecKey, httpC *http. closed: make(chan struct{}), } - client.log.Infof("Remote UDP server: %q", remoteUDP) + client.log.Debugf("Remote UDP server: %q", remoteUDP) go client.initHTTPClient(httpC) @@ -142,7 +142,7 @@ func (c *httpClient) initHTTPClient(httpC *http.Client) { } } - c.log.Infof("Connected to address resolver. STCPR/SUDPH services are available.") + c.log.Debug("Connected to address resolver. STCPR/SUDPH services are available.") c.httpClient = httpAuthClient close(c.ready) @@ -212,10 +212,11 @@ type LocalAddresses struct { // BindSTCPR binds client PK to IP:port on address resolver. func (c *httpClient) BindSTCPR(ctx context.Context, port string) error { + log := c.log.WithField("func", "httpClient.BindSTCPR") if !c.isReady() { - c.log.Infof("BindSTCPR: Address resolver is not ready yet, waiting...") + log.Debug("Address resolver is not ready yet, waiting...") <-c.ready - c.log.Infof("BindSTCPR: Address resolver became ready, binding") + log.Debug("Address resolver became ready, binding") } addresses, err := netutil.LocalAddresses() @@ -227,7 +228,7 @@ func (c *httpClient) BindSTCPR(ctx context.Context, port string) error { Addresses: addresses, Port: port, } - c.log.Infof("BindSTCPR: Address resolver binding with: %v", addresses) + log.Debugf("Address resolver binding with: %v", addresses) resp, err := c.Post(ctx, stcprBindPath, localAddresses) if err != nil { return err @@ -235,7 +236,7 @@ func (c *httpClient) BindSTCPR(ctx context.Context, port string) error { defer func() { if err := resp.Body.Close(); err != nil { - c.log.WithError(err).Warn("Failed to close response body") + log.WithError(err).Warn("Failed to close response body") } }() @@ -248,13 +249,14 @@ func (c *httpClient) BindSTCPR(ctx context.Context, port string) error { // delBindSTCPR uinbinds STCPR entry PK to IP:port on address resolver. func (c *httpClient) delBindSTCPR(ctx context.Context) error { + log := c.log.WithField("func", "httpClient.delBindSTCPR") if !c.isReady() { - c.log.Debugf("delBindSTCPR: Address resolver is not ready yet, waiting...") + log.Debug("Address resolver is not ready yet, waiting...") <-c.ready - c.log.Debugf("delBindSTCPR: Address resolver became ready, unbinding") + log.Debug("Address resolver became ready, unbinding") } - c.log.Debugf("delBindSTCPR: deleting the binding pk: %v from Address resolver", c.pk.String()) + log.Debugf("Deleting the binding pk: %v from Address resolver", c.pk.String()) resp, err := c.Delete(ctx, stcprBindPath) if err != nil { return err @@ -262,7 +264,7 @@ func (c *httpClient) delBindSTCPR(ctx context.Context) error { defer func() { if err := resp.Body.Close(); err != nil { - c.log.WithError(err).Warn("Failed to close response body") + log.WithError(err).Warn("Failed to close response body") } }() @@ -270,7 +272,7 @@ func (c *httpClient) delBindSTCPR(ctx context.Context) error { return fmt.Errorf("status: %d, error: %w", resp.StatusCode, httpauth.ExtractError(resp.Body)) } - c.log.Debugf("delBindSTCPR: Deleted bind pk: %v from Address resolver successfully", c.pk.String()) + log.Debugf("Deleted bind pk: %v from Address resolver successfully", c.pk.String()) return nil } @@ -278,10 +280,11 @@ func (c *httpClient) delBindSTCPR(ctx context.Context) error { type Handshake func(net.Conn) (net.Conn, error) func (c *httpClient) BindSUDPH(filter *pfilter.PacketFilter, hs Handshake) (<-chan RemoteVisor, error) { + log := c.log.WithField("func", "httpClient.BindSUDPR") if !c.isReady() { - c.log.Infof("BindSUDPR: Address resolver is not ready yet, waiting...") + log.Debug("BindSUDPR: Address resolver is not ready yet, waiting...") <-c.ready - c.log.Infof("BindSUDPR: Address resolver became ready, binding") + log.Debug("BindSUDPR: Address resolver became ready, binding") } rAddr, err := net.ResolveUDPAddr("udp", c.remoteUDPAddr) @@ -296,7 +299,7 @@ func (c *httpClient) BindSUDPH(filter *pfilter.PacketFilter, hs Handshake) (<-ch return nil, err } - c.log.Infof("SUDPH Local port: %v", localPort) + log.Debugf("SUDPH Local port: %v", localPort) kcpConn, err := kcp.NewConn(c.remoteUDPAddr, nil, 0, 0, c.sudphConn) if err != nil { return nil, err @@ -329,13 +332,13 @@ func (c *httpClient) BindSUDPH(filter *pfilter.PacketFilter, hs Handshake) (<-ch go func() { if err := c.keepSudphHeartbeatLoop(arConn); err != nil { - c.log.WithError(err).Errorf("Failed to send UDP heartbeat packet to address-resolver") + log.WithError(err).Errorf("Failed to send UDP heartbeat packet to address-resolver") } }() go func() { if err := c.delBindSUDPH(arConn); err != nil { - c.log.WithError(err).Errorf("Failed to send UDP unbind packet to address-resolver") + log.WithError(err).Errorf("Failed to send UDP unbind packet to address-resolver") } }() @@ -467,14 +470,14 @@ func (c *httpClient) readSUDPHMessages(reader io.Reader) <-chan RemoteVisor { n, err := reader.Read(buf) if err != nil { if c.isClosed() { - c.log.Infof("SUDPH conn closed on shutdown message: %v", err) + c.log.Debugf("SUDPH conn closed on shutdown message: %v", err) return } c.log.Errorf("Failed to read SUDPH message: %v", err) return } - c.log.Infof("New SUDPH message: %v", string(buf[:n])) + c.log.Debugf("New SUDPH message: %v", string(buf[:n])) var remote RemoteVisor if err := json.Unmarshal(buf[:n], &remote); err != nil { @@ -546,7 +549,7 @@ func (c *httpClient) delBindSUDPH(w io.Writer) error { if _, err := w.Write([]byte(UDPDelBindMessage)); err != nil { return err } - c.log.Debugf("delBindSUDPH: Deleted bind pk: %v from Address resolver successfully", c.pk.String()) + c.log.WithField("func", "httpClient.delBindSUDPH").Debugf("Deleted bind pk: %v from Address resolver successfully", c.pk.String()) return nil } diff --git a/pkg/transport/network/addrresolver/client_test.go b/pkg/transport/network/addrresolver/client_test.go index 4e282001af..50c9520b78 100644 --- a/pkg/transport/network/addrresolver/client_test.go +++ b/pkg/transport/network/addrresolver/client_test.go @@ -10,11 +10,11 @@ import ( "testing" "github.com/go-chi/chi/v5" - "github.com/skycoin/skycoin/src/util/logging" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "github.com/skycoin/skywire-utilities/pkg/cipher" + "github.com/skycoin/skywire-utilities/pkg/logging" "github.com/skycoin/skywire/internal/httpauth" ) diff --git a/pkg/transport/network/client.go b/pkg/transport/network/client.go index f7a29dd82b..bdc4d025fc 100644 --- a/pkg/transport/network/client.go +++ b/pkg/transport/network/client.go @@ -10,9 +10,9 @@ import ( "sync" "github.com/skycoin/dmsg/pkg/dmsg" - "github.com/skycoin/skycoin/src/util/logging" "github.com/skycoin/skywire-utilities/pkg/cipher" + "github.com/skycoin/skywire-utilities/pkg/logging" "github.com/skycoin/skywire/pkg/app/appevent" "github.com/skycoin/skywire/pkg/transport/network/addrresolver" "github.com/skycoin/skywire/pkg/transport/network/handshake" @@ -132,7 +132,7 @@ func (c *genericClient) initTransport(ctx context.Context, conn net.Conn, rPK ci } lAddr, rAddr := dmsg.Addr{PK: c.lPK, Port: lPort}, dmsg.Addr{PK: rPK, Port: rPort} remoteAddr := conn.RemoteAddr() - c.log.Infof("Performing handshake with %v", remoteAddr) + c.log.Debugf("Performing handshake with %v", remoteAddr) hs := handshake.InitiatorHandshake(c.lSK, lAddr, rAddr) return c.wrapTransport(conn, hs, true, freePort) } @@ -145,7 +145,7 @@ func (c *genericClient) acceptTransports(lis net.Listener) { c.connListener = lis close(c.listenStarted) c.mu.Unlock() - c.log.Infof("listening on addr: %v", c.connListener.Addr()) + c.log.Debugf("listening on addr: %v", c.connListener.Addr()) for { if err := c.acceptTransport(); err != nil { if errors.Is(err, io.EOF) { @@ -153,7 +153,7 @@ func (c *genericClient) acceptTransports(lis net.Listener) { } if c.isClosed() && (errors.Is(err, io.ErrClosedPipe) || strings.Contains(err.Error(), "use of closed network connection")) { - c.log.Info("Cleanly stopped serving.") + c.log.Debug("Cleanly stopped serving.") return } @@ -175,7 +175,7 @@ func (c *genericClient) wrapTransport(rawConn net.Conn, hs handshake.Handshake, return nil, err } transport.freePort = onClose - c.log.Infof("Sent handshake to %v, local addr %v, remote addr %v", rawConn.RemoteAddr(), transport.lAddr, transport.rAddr) + c.log.Debugf("Sent handshake to %v, local addr %v, remote addr %v", rawConn.RemoteAddr(), transport.lAddr, transport.rAddr) if err := transport.encrypt(c.lPK, c.lSK, initiator); err != nil { return nil, err } @@ -195,7 +195,7 @@ func (c *genericClient) acceptTransport() error { return err } remoteAddr := conn.RemoteAddr() - c.log.Infof("Accepted connection from %v", remoteAddr) + c.log.Debugf("Accepted connection from %v", remoteAddr) onClose := func() {} hs := handshake.ResponderHandshake(handshake.MakeF2PortChecker(c.checkListener)) @@ -326,7 +326,7 @@ func (c *resolvedClient) dialVisor(ctx context.Context, rPK cipher.PubKey, dial if err != nil { return nil, fmt.Errorf("resolve PK: %w", err) } - c.log.Infof("Resolved PK %v to visor data %v", rPK, visorData) + c.log.Debugf("Resolved PK %v to visor data %v", rPK, visorData) if visorData.IsLocal { for _, host := range visorData.Addresses { diff --git a/pkg/transport/network/connection.go b/pkg/transport/network/connection.go index 69576af2ea..ebf96ce644 100644 --- a/pkg/transport/network/connection.go +++ b/pkg/transport/network/connection.go @@ -7,9 +7,9 @@ import ( "github.com/skycoin/dmsg/pkg/dmsg" "github.com/skycoin/dmsg/pkg/noise" - "github.com/skycoin/skycoin/src/util/logging" "github.com/skycoin/skywire-utilities/pkg/cipher" + "github.com/skycoin/skywire-utilities/pkg/logging" "github.com/skycoin/skywire/pkg/transport/network/handshake" ) diff --git a/pkg/transport/network/stcp.go b/pkg/transport/network/stcp.go index a2f3dcd912..fe5f12dbf9 100644 --- a/pkg/transport/network/stcp.go +++ b/pkg/transport/network/stcp.go @@ -37,7 +37,7 @@ func (c *stcpClient) Dial(ctx context.Context, rPK cipher.PubKey, rPort uint16) return nil, io.ErrClosedPipe } - c.log.Infof("Dialing PK %v", rPK) + c.log.Debugf("Dialing PK %v", rPK) var conn net.Conn addr, ok := c.table.Addr(rPK) @@ -51,7 +51,7 @@ func (c *stcpClient) Dial(ctx context.Context, rPK cipher.PubKey, rPort uint16) return nil, err } - c.log.Infof("Dialed %v:%v@%v", rPK, rPort, conn.RemoteAddr()) + c.log.Debugf("Dialed %v:%v@%v", rPK, rPort, conn.RemoteAddr()) return c.initTransport(ctx, conn, rPK, rPort) } diff --git a/pkg/transport/network/stcpr.go b/pkg/transport/network/stcpr.go index 9a7a77706f..e2e80271be 100644 --- a/pkg/transport/network/stcpr.go +++ b/pkg/transport/network/stcpr.go @@ -24,7 +24,7 @@ func (c *stcprClient) Dial(ctx context.Context, rPK cipher.PubKey, rPort uint16) if c.isClosed() { return nil, io.ErrClosedPipe } - c.log.Infof("Dialing PK %v", rPK) + c.log.Debugf("Dialing PK %v", rPK) conn, err := c.dialVisor(ctx, rPK, c.dial) if err != nil { return nil, err @@ -66,14 +66,14 @@ func (c *stcprClient) serve() { c.log.Errorf("Failed to check for public IP: %v", err) } if !hasPublic { - c.log.Infof("Not binding STCPR: no public IP address found") + c.log.Debug("Not binding STCPR: no public IP address found") return } - c.log.Infof("Binding") + c.log.Debug("Binding") if err := c.ar.BindSTCPR(context.Background(), port); err != nil { c.log.Errorf("Failed to bind STCPR: %v", err) return } - c.log.Infof("Successfully bound stcpr to port %s", port) + c.log.Debugf("Successfully bound stcpr to port %s", port) c.acceptTransports(lis) } diff --git a/pkg/transport/network/stun_client.go b/pkg/transport/network/stun_client.go index 90cb85cd8c..6f71dffea0 100644 --- a/pkg/transport/network/stun_client.go +++ b/pkg/transport/network/stun_client.go @@ -2,7 +2,8 @@ package network import ( "github.com/ccding/go-stun/stun" - "github.com/skycoin/skycoin/src/util/logging" + + "github.com/skycoin/skywire-utilities/pkg/logging" ) // StunDetails represents the visors public network details. diff --git a/pkg/transport/network/sudph.go b/pkg/transport/network/sudph.go index 6c98b1f935..1140aa99a3 100644 --- a/pkg/transport/network/sudph.go +++ b/pkg/transport/network/sudph.go @@ -64,7 +64,7 @@ func (c *sudphClient) listen() (net.Listener, error) { c.filter = pfilter.NewPacketFilter(packetListener) sudphVisorsConn := c.filter.NewConn(visorsConnPriority, nil) c.filter.Start() - c.log.Infof("Binding") + c.log.Debug("Binding") addrCh, err := c.ar.BindSUDPH(c.filter, c.makeBindHandshake()) if err != nil { return nil, err @@ -75,7 +75,7 @@ func (c *sudphClient) listen() (net.Listener, error) { return nil, err } - c.log.Infof("Successfully bound sudph to port %s", localPort) + c.log.Debugf("Successfully bound sudph to port %s", localPort) go c.acceptAddresses(sudphVisorsConn, addrCh) return kcp.ServeConn(nil, 0, 0, sudphVisorsConn) @@ -103,13 +103,12 @@ func (c *sudphClient) acceptAddresses(conn net.PacketConn, addrCh <-chan addrres continue } - c.log.Infof("Sending hole punch packet to %v", addr) - + c.log.Debugf("Sending hole punch packet to %v", addr) if _, err := conn.WriteTo([]byte(holePunchMessage), udpAddr); err != nil { c.log.WithError(err).Errorf("Failed to send hole punch packet to %v", udpAddr) continue } - c.log.Infof("Sent hole punch packet to %v", addr) + c.log.Debugf("Sent hole punch packet to %v", addr) } } @@ -130,7 +129,7 @@ func (c *sudphClient) Dial(ctx context.Context, rPK cipher.PubKey, rPort uint16) func (c *sudphClient) dialWithTimeout(ctx context.Context, addr string) (net.Conn, error) { timedCtx, cancel := context.WithTimeout(ctx, dialTimeout) defer cancel() - c.log.Infof("Dialing %v", addr) + c.log.Debugf("Dialing %v", addr) for { select { @@ -139,7 +138,7 @@ func (c *sudphClient) dialWithTimeout(ctx context.Context, addr string) (net.Con default: conn, err := c.dial(addr) if err == nil { - c.log.Infof("Dialed %v", addr) + c.log.Debugf("Dialed %v", addr) return conn, nil } c.log.WithError(err). diff --git a/pkg/transport/setup/rpc.go b/pkg/transport/setup/rpc.go index ebfed4f196..a668fa96f3 100644 --- a/pkg/transport/setup/rpc.go +++ b/pkg/transport/setup/rpc.go @@ -5,9 +5,9 @@ import ( "errors" "github.com/google/uuid" - "github.com/skycoin/skycoin/src/util/logging" "github.com/skycoin/skywire-utilities/pkg/cipher" + "github.com/skycoin/skywire-utilities/pkg/logging" "github.com/skycoin/skywire/pkg/transport" "github.com/skycoin/skywire/pkg/transport/network" ) @@ -63,7 +63,7 @@ var ErrIncorrectType = errors.New("transport was not created by skycoin") // RemoveTransport removes all transports that match given request func (gw *TransportGateway) RemoveTransport(req UUIDRequest, res *BoolResponse) error { - gw.log.WithField("ID", req.ID).Info("Removing transport") + gw.log.WithField("ID", req.ID).Debug("Removing transport") tr, err := gw.tm.GetTransportByID(req.ID) if err != nil { return err diff --git a/pkg/transport/setup/visor.go b/pkg/transport/setup/visor.go index bf8d38d403..7733e2c9fe 100644 --- a/pkg/transport/setup/visor.go +++ b/pkg/transport/setup/visor.go @@ -7,9 +7,9 @@ import ( "net/rpc" "github.com/skycoin/dmsg/pkg/dmsg" - "github.com/skycoin/skycoin/src/util/logging" "github.com/skycoin/skywire-utilities/pkg/cipher" + "github.com/skycoin/skywire-utilities/pkg/logging" "github.com/skycoin/skywire/pkg/skyenv" "github.com/skycoin/skywire/pkg/transport" "github.com/skycoin/skywire/pkg/visor/visorconfig" @@ -26,11 +26,11 @@ type TransportListener struct { // NewTransportListener makes a TransportListener from configuration func NewTransportListener(ctx context.Context, conf *visorconfig.V1, dmsgC *dmsg.Client, tm *transport.Manager, masterLogger *logging.MasterLogger) (*TransportListener, error) { log := masterLogger.PackageLogger("transport_setup") - log.WithField("local_pk", conf.PK).Info("Connecting to the dmsg network.") + log.WithField("local_pk", conf.PK).Debug("Connecting to the dmsg network.") select { case <-dmsgC.Ready(): - log.WithField("local_pk", conf.PK).Info("Connected!") + log.WithField("local_pk", conf.PK).Debug("Connected!") tl := &TransportListener{ dmsgC: dmsgC, log: log, @@ -45,7 +45,7 @@ func NewTransportListener(ctx context.Context, conf *visorconfig.V1, dmsgC *dmsg // Serve transport setup rpc to trusted nodes over dmsg func (ts *TransportListener) Serve(ctx context.Context) { - ts.log.WithField("dmsg_port", skyenv.DmsgTransportSetupPort).Info("starting listener") + ts.log.WithField("dmsg_port", skyenv.DmsgTransportSetupPort).Debug("starting listener") lis, err := ts.dmsgC.Listen(skyenv.DmsgTransportSetupPort) if err != nil { ts.log.WithError(err).Error("failed to listen") @@ -57,13 +57,13 @@ func (ts *TransportListener) Serve(ctx context.Context) { } }() - ts.log.WithField("dmsg_port", skyenv.DmsgTransportSetupPort).Info("Accepting dmsg streams.") + ts.log.WithField("dmsg_port", skyenv.DmsgTransportSetupPort).Debug("Accepting dmsg streams.") for { conn, err := lis.AcceptStream() if err != nil { log := ts.log.WithError(err) if errors.Is(err, dmsg.ErrEntityClosed) { - log.Info("Dmsg client stopped serving.") + log.Debug("Dmsg client stopped serving.") break } log.Error("Failed to accept") @@ -78,7 +78,7 @@ func (ts *TransportListener) Serve(ctx context.Context) { } } if !found { - ts.log.WithField("remote_conn", remotePK).WithField("trusted", ts.tsNodes).Info("Closing connection") + ts.log.WithField("remote_conn", remotePK).WithField("trusted", ts.tsNodes).Debug("Closing connection") if err := conn.Close(); err != nil { ts.log.WithError(err).Error("Failed to close stream") } @@ -88,7 +88,7 @@ func (ts *TransportListener) Serve(ctx context.Context) { if err := rpcS.Register(gw); err != nil { ts.log.WithError(err).Error("failed to register rpc") } - ts.log.WithField("remote_conn", remotePK).Info("Serving rpc") + ts.log.WithField("remote_conn", remotePK).Debug("Serving rpc") go rpcS.ServeConn(conn) } } diff --git a/pkg/transport/tpdclient/client.go b/pkg/transport/tpdclient/client.go index 98173a9eef..b96e9c5356 100644 --- a/pkg/transport/tpdclient/client.go +++ b/pkg/transport/tpdclient/client.go @@ -9,10 +9,10 @@ import ( "net/http" "github.com/google/uuid" - "github.com/skycoin/skycoin/src/util/logging" "github.com/skycoin/skywire-utilities/pkg/cipher" "github.com/skycoin/skywire-utilities/pkg/httputil" + "github.com/skycoin/skywire-utilities/pkg/logging" "github.com/skycoin/skywire/internal/httpauth" "github.com/skycoin/skywire/pkg/transport" ) diff --git a/pkg/transport/tpdclient/client_test.go b/pkg/transport/tpdclient/client_test.go index 690f5ae5f7..52a3298718 100644 --- a/pkg/transport/tpdclient/client_test.go +++ b/pkg/transport/tpdclient/client_test.go @@ -12,11 +12,11 @@ import ( "testing" "github.com/go-chi/chi/v5" - "github.com/skycoin/skycoin/src/util/logging" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "github.com/skycoin/skywire-utilities/pkg/cipher" + "github.com/skycoin/skywire-utilities/pkg/logging" "github.com/skycoin/skywire/internal/httpauth" "github.com/skycoin/skywire/pkg/transport" ) diff --git a/pkg/utclient/client.go b/pkg/utclient/client.go index 33ec45d567..da6eceaa5a 100644 --- a/pkg/utclient/client.go +++ b/pkg/utclient/client.go @@ -8,7 +8,7 @@ import ( "net/http" "time" - "github.com/skycoin/skycoin/src/util/logging" + "github.com/skycoin/skywire-utilities/pkg/logging" "github.com/skycoin/skywire-utilities/pkg/cipher" "github.com/skycoin/skywire-utilities/pkg/netutil" diff --git a/pkg/utclient/client_test.go b/pkg/utclient/client_test.go index ca0e748846..eae1b67f9f 100644 --- a/pkg/utclient/client_test.go +++ b/pkg/utclient/client_test.go @@ -10,11 +10,11 @@ import ( "testing" "github.com/go-chi/chi/v5" - "github.com/skycoin/skycoin/src/util/logging" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "github.com/skycoin/skywire-utilities/pkg/cipher" + "github.com/skycoin/skywire-utilities/pkg/logging" "github.com/skycoin/skywire/internal/httpauth" ) diff --git a/pkg/util/pathutil/configpath.go b/pkg/util/pathutil/configpath.go index 7442af42d0..1beab29b81 100644 --- a/pkg/util/pathutil/configpath.go +++ b/pkg/util/pathutil/configpath.go @@ -6,7 +6,7 @@ import ( "os" "path/filepath" - "github.com/skycoin/skycoin/src/util/logging" + "github.com/skycoin/skywire-utilities/pkg/logging" ) var log = logging.MustGetLogger("pathutil") diff --git a/pkg/util/rpcutil/log_call.go b/pkg/util/rpcutil/log_call.go index 80bbf5c407..767f65c255 100644 --- a/pkg/util/rpcutil/log_call.go +++ b/pkg/util/rpcutil/log_call.go @@ -30,6 +30,6 @@ func LogCall(log logrus.FieldLogger, method string, in interface{}) func(out int if err != nil && *err != nil { log = log.WithError(*err) } - log.Info("Request processed.") + log.Trace("Request processed.") } } diff --git a/pkg/visor/dmsgtracker/dmsg_tracker.go b/pkg/visor/dmsgtracker/dmsg_tracker.go index 19f59130d7..0f15b2a98a 100644 --- a/pkg/visor/dmsgtracker/dmsg_tracker.go +++ b/pkg/visor/dmsgtracker/dmsg_tracker.go @@ -9,9 +9,9 @@ import ( "github.com/skycoin/dmsg/pkg/dmsg" "github.com/skycoin/dmsg/pkg/dmsgctrl" - "github.com/skycoin/skycoin/src/util/logging" "github.com/skycoin/skywire-utilities/pkg/cipher" + "github.com/skycoin/skywire-utilities/pkg/logging" "github.com/skycoin/skywire/pkg/skyenv" ) diff --git a/pkg/visor/hypervisor.go b/pkg/visor/hypervisor.go index c7582f016d..d5eb8f8235 100644 --- a/pkg/visor/hypervisor.go +++ b/pkg/visor/hypervisor.go @@ -20,11 +20,11 @@ import ( "github.com/sirupsen/logrus" "github.com/skycoin/dmsg/pkg/dmsg" "github.com/skycoin/dmsg/pkg/dmsgpty" - "github.com/skycoin/skycoin/src/util/logging" "github.com/skycoin/skywire-utilities/pkg/buildinfo" "github.com/skycoin/skywire-utilities/pkg/cipher" "github.com/skycoin/skywire-utilities/pkg/httputil" + "github.com/skycoin/skywire-utilities/pkg/logging" "github.com/skycoin/skywire/pkg/app/appcommon" "github.com/skycoin/skywire/pkg/app/launcher" "github.com/skycoin/skywire/pkg/routing" @@ -139,7 +139,7 @@ func (hv *Hypervisor) ServeRPC(ctx context.Context, dmsgPort uint16) error { } } - log.Info("Accepted.") + log.Debug("Accepted.") hv.mu.Lock() hv.visor.remoteVisors[addr.PK] = *visorConn @@ -197,8 +197,14 @@ func (hv *Hypervisor) makeMux() chi.Router { r.Use(middleware.RequestID) r.Use(middleware.RealIP) - r.Use(middleware.Logger) - r.Use(middleware.Recoverer) + + if hv.visor != nil { + if hv.visor.MasterLogger().GetLevel() == logrus.DebugLevel || hv.visor.MasterLogger().GetLevel() == logrus.TraceLevel { + r.Use(middleware.Logger) + r.Use(middleware.Recoverer) + } + } + r.Use(httputil.SetLoggerMiddleware(hv.logger)) r.Route("/", func(r chi.Router) { @@ -517,7 +523,7 @@ func (hv *Hypervisor) getAllVisorsSummary() http.HandlerFunc { WithField("visor_addr", c.Addr). WithField("func", "getVisors") - log.Debug("Requesting summary via RPC.") + log.Trace("Requesting summary via RPC.") summary, err := c.API.Summary() if err != nil { @@ -531,7 +537,7 @@ func (hv *Hypervisor) getAllVisorsSummary() http.HandlerFunc { Health: &HealthInfo{}, } } else { - log.Debug("Obtained summary via RPC.") + log.Trace("Obtained summary via RPC.") } resp := makeSummaryResp(err == nil, false, summary) summaries[i] = resp @@ -1421,7 +1427,7 @@ func (hv *Hypervisor) serveDmsg(ctx context.Context, log *logging.Logger) { if err := hv.ServeRPC(ctx, hv.c.DmsgPort); err != nil { log := log.WithError(err) if errors.Is(err, dmsg.ErrEntityClosed) { - log.Info("Dmsg client stopped serving.") + log.Debug("Dmsg client stopped serving.") return } log.Error("Failed to serve RPC client over dmsg.") @@ -1429,7 +1435,7 @@ func (hv *Hypervisor) serveDmsg(ctx context.Context, log *logging.Logger) { } }() log.WithField("addr", dmsg.Addr{PK: hv.c.PK, Port: hv.c.DmsgPort}). - Info("Serving RPC client over dmsg.") + Debug("Serving RPC client over dmsg.") } // dmsgPtyUI servers as a wrapper for `*dmsgpty.UI`. this way source file with diff --git a/pkg/visor/init.go b/pkg/visor/init.go index d6afe9478f..a105f8714d 100644 --- a/pkg/visor/init.go +++ b/pkg/visor/init.go @@ -20,9 +20,9 @@ import ( "github.com/skycoin/dmsg/pkg/dmsgget" "github.com/skycoin/dmsg/pkg/dmsghttp" "github.com/skycoin/dmsg/pkg/dmsgpty" - "github.com/skycoin/skycoin/src/util/logging" "github.com/skycoin/skywire-utilities/pkg/cipher" + "github.com/skycoin/skywire-utilities/pkg/logging" "github.com/skycoin/skywire-utilities/pkg/netutil" utilenv "github.com/skycoin/skywire-utilities/pkg/skyenv" "github.com/skycoin/skywire/internal/vpn" @@ -318,17 +318,17 @@ func initDmsgCtrl(ctx context.Context, v *Visor, _ *logging.Logger) error { const dmsgTimeout = time.Second * 20 logger := dmsgC.Logger().WithField("timeout", dmsgTimeout) - logger.Info("Connecting to the dmsg network...") + logger.Debug("Connecting to the dmsg network...") select { case <-time.After(dmsgTimeout): logger.Warn("Failed to connect to the dmsg network, will try again later.") go func() { <-v.dmsgC.Ready() - logger.Info("Connected to the dmsg network.") + logger.Debug("Connected to the dmsg network.") v.tpM.InitDmsgClient(ctx, dmsgC) }() case <-v.dmsgC.Ready(): - logger.Info("Connected to the dmsg network.") + logger.Debug("Connected to the dmsg network.") v.tpM.InitDmsgClient(ctx, dmsgC) } // dmsgctrl setup @@ -368,7 +368,7 @@ func initSudphClient(ctx context.Context, v *Visor, log *logging.Logger) error { switch v.stunClient.NATType { case stun.NATSymmetric, stun.NATSymmetricUDPFirewall: - log.Infof("SUDPH transport wont be available as visor is under %v", v.stunClient.NATType.String()) + log.Warnf("SUDPH transport wont be available as visor is under %v", v.stunClient.NATType.String()) default: v.tpM.InitClient(ctx, network.SUDPH) } @@ -719,7 +719,7 @@ func vpnEnvMaker(conf *visorconfig.V1, dmsgC, dmsgDC *dmsg.Client, tpRemoteAddrs func initCLI(ctx context.Context, v *Visor, log *logging.Logger) error { if v.conf.CLIAddr == "" { - v.log.Info("'cli_addr' is not configured, skipping.") + v.log.Debug("'cli_addr' is not configured, skipping.") return nil } @@ -781,7 +781,7 @@ func initUptimeTracker(ctx context.Context, v *Visor, log *logging.Logger) error conf := v.conf.UptimeTracker if conf == nil { - v.log.Info("'uptime_tracker' is not configured, skipping.") + v.log.Debug("'uptime_tracker' is not configured, skipping.") return nil } @@ -865,7 +865,7 @@ func initPublicVisor(_ context.Context, v *Visor, log *logging.Logger) error { visorUpdater := v.serviceDisc.VisorUpdater(port) visorUpdater.Start() - v.log.Infof("Sent request to register visor as public") + v.log.Debugf("Sent request to register visor as public") v.pushCloseStack("public visor updater", func() error { visorUpdater.Stop() return nil @@ -877,7 +877,7 @@ func initDmsgpty(ctx context.Context, v *Visor, log *logging.Logger) error { conf := v.conf.Dmsgpty if conf == nil { - log.Info("'dmsgpty' is not configured, skipping.") + log.Debug("'dmsgpty' is not configured, skipping.") return nil } @@ -1003,7 +1003,6 @@ func initPublicAutoconnect(ctx context.Context, v *Visor, log *logging.Logger) e } func initHypervisor(_ context.Context, v *Visor, log *logging.Logger) error { - v.log.Infof("Initializing hypervisor") ctx, cancel := context.WithCancel(context.Background()) @@ -1039,8 +1038,6 @@ func initHypervisor(_ context.Context, v *Visor, log *logging.Logger) error { cancel() }() - v.log.Infof("Hypervisor initialized") - return nil } diff --git a/pkg/visor/rpc_client.go b/pkg/visor/rpc_client.go index aecf8b1776..c9e4bba162 100644 --- a/pkg/visor/rpc_client.go +++ b/pkg/visor/rpc_client.go @@ -14,10 +14,10 @@ import ( "github.com/google/uuid" "github.com/sirupsen/logrus" - "github.com/skycoin/skycoin/src/util/logging" "github.com/skycoin/skywire-utilities/pkg/buildinfo" "github.com/skycoin/skywire-utilities/pkg/cipher" + "github.com/skycoin/skywire-utilities/pkg/logging" "github.com/skycoin/skywire/pkg/app/appcommon" "github.com/skycoin/skywire/pkg/app/appserver" "github.com/skycoin/skywire/pkg/app/launcher" diff --git a/pkg/visor/usermanager/user_manager.go b/pkg/visor/usermanager/user_manager.go index 81a89bc80a..f1cf51123f 100644 --- a/pkg/visor/usermanager/user_manager.go +++ b/pkg/visor/usermanager/user_manager.go @@ -11,9 +11,9 @@ import ( "github.com/google/uuid" "github.com/gorilla/securecookie" - "github.com/skycoin/skycoin/src/util/logging" "github.com/skycoin/skywire-utilities/pkg/httputil" + "github.com/skycoin/skywire-utilities/pkg/logging" "github.com/skycoin/skywire/pkg/visor/hypervisorconfig" ) diff --git a/pkg/visor/visor.go b/pkg/visor/visor.go index 3bea8f2ee1..19af753a9f 100644 --- a/pkg/visor/visor.go +++ b/pkg/visor/visor.go @@ -11,9 +11,9 @@ import ( dmsgdisc "github.com/skycoin/dmsg/pkg/disc" "github.com/skycoin/dmsg/pkg/dmsg" - "github.com/skycoin/skycoin/src/util/logging" "github.com/skycoin/skywire-utilities/pkg/cipher" + "github.com/skycoin/skywire-utilities/pkg/logging" "github.com/skycoin/skywire/pkg/app/appdisc" "github.com/skycoin/skywire/pkg/app/appevent" "github.com/skycoin/skywire/pkg/app/appserver" @@ -177,6 +177,7 @@ func NewVisor(ctx context.Context, conf *visorconfig.V1, restartCtx *restart.Con if !v.processRuntimeErrs() { return nil, false } + log.Info("Startup complete.") return v, true } @@ -226,7 +227,7 @@ func (v *Visor) Close() error { log := v.MasterLogger().PackageLogger(fmt.Sprintf("visor:shutdown:%s", cl.src)). WithField("func", fmt.Sprintf("[%d/%d]", i+1, len(v.closeStack))) - log.Info("Shutting down module...") + log.Debug("Shutting down module...") go func(cl closer) { errCh <- cl.fn() @@ -240,7 +241,7 @@ func (v *Visor) Close() error { log.WithError(err).WithField("elapsed", time.Since(start)).Warn("Module stopped with unexpected result.") continue } - log.WithField("elapsed", time.Since(start)).Info("Module stopped cleanly.") + log.WithField("elapsed", time.Since(start)).Debug("Module stopped cleanly.") case <-t.C: log.WithField("elapsed", time.Since(start)).Error("Module timed out.") diff --git a/pkg/visor/visorconfig/common.go b/pkg/visor/visorconfig/common.go index 78246cc030..b4e971accf 100644 --- a/pkg/visor/visorconfig/common.go +++ b/pkg/visor/visorconfig/common.go @@ -5,7 +5,7 @@ import ( "errors" "io/ioutil" - "github.com/skycoin/skycoin/src/util/logging" + "github.com/skycoin/skywire-utilities/pkg/logging" "github.com/skycoin/skywire-utilities/pkg/cipher" "github.com/skycoin/skywire/pkg/skyenv" diff --git a/pkg/visor/visorconfig/config.go b/pkg/visor/visorconfig/config.go index 77499173e8..555124ec38 100644 --- a/pkg/visor/visorconfig/config.go +++ b/pkg/visor/visorconfig/config.go @@ -8,9 +8,9 @@ import ( "github.com/skycoin/dmsg/pkg/disc" coinCipher "github.com/skycoin/skycoin/src/cipher" - "github.com/skycoin/skycoin/src/util/logging" "github.com/skycoin/skywire-utilities/pkg/cipher" + "github.com/skycoin/skywire-utilities/pkg/logging" utilenv "github.com/skycoin/skywire-utilities/pkg/skyenv" "github.com/skycoin/skywire/pkg/app/launcher" "github.com/skycoin/skywire/pkg/dmsgc" diff --git a/pkg/visor/visorconfig/parse.go b/pkg/visor/visorconfig/parse.go index 353e3378d0..e47abe4815 100644 --- a/pkg/visor/visorconfig/parse.go +++ b/pkg/visor/visorconfig/parse.go @@ -6,9 +6,9 @@ import ( "strings" "github.com/blang/semver/v4" - "github.com/skycoin/skycoin/src/util/logging" "github.com/skycoin/skywire-utilities/pkg/buildinfo" + "github.com/skycoin/skywire-utilities/pkg/logging" ) var ( @@ -25,9 +25,6 @@ func Parse(log *logging.Logger, r io.Reader, confPath string, visorBuildInfo *bu if err != nil { return nil, compat, err } - if conf.Version != "unknown" { - log.WithField("config version: ", conf.Version).Info() - } // we check if the version of the visor and config are the same if (conf.Version != "unknown") && (visorBuildInfo.Version != "unknown") { cVer, err := semver.Make(strings.TrimPrefix(conf.Version, "v")) diff --git a/pkg/visor/visorconfig/services.go b/pkg/visor/visorconfig/services.go index 69d7337a89..ad8e383552 100644 --- a/pkg/visor/visorconfig/services.go +++ b/pkg/visor/visorconfig/services.go @@ -7,7 +7,7 @@ import ( "strings" "time" - "github.com/skycoin/skycoin/src/util/logging" + "github.com/skycoin/skywire-utilities/pkg/logging" "github.com/skycoin/skywire-utilities/pkg/cipher" ) diff --git a/pkg/visor/visorinit/module.go b/pkg/visor/visorinit/module.go index 10844329e0..da84365d91 100644 --- a/pkg/visor/visorinit/module.go +++ b/pkg/visor/visorinit/module.go @@ -5,9 +5,8 @@ import ( "errors" "fmt" "sync" - "time" - "github.com/skycoin/skycoin/src/util/logging" + "github.com/skycoin/skywire-utilities/pkg/logging" ) // Hook is a function that can be run at some point as part @@ -110,8 +109,7 @@ func (m *Module) InitConcurrent(ctx context.Context) { return } defer m.stop() - m.log.Info("Starting") - start := time.Now() + m.log.Debug("Starting") // start init in every dependency for _, dep := range m.deps { go dep.InitConcurrent(ctx) @@ -134,12 +132,11 @@ func (m *Module) InitConcurrent(ctx context.Context) { m.err = fmt.Errorf("unable to initialize module %s error: %w", m.Name, ErrNoInit) return } - startSelf := time.Now() // init the module itself err := m.init(ctx, m.log) if err != nil { m.err = fmt.Errorf("initializing module %s returning error: %v", m.Name, err) return } - m.log.Infof("Initialized in %s (%s with dependencies)", time.Since(startSelf), time.Since(start)) + m.log.Debug("Initialized.") } diff --git a/scripts/mac_installer/desktop-deinstaller/deinstaller.go b/scripts/mac_installer/desktop-deinstaller/deinstaller.go index ccce67efac..64a02f94bb 100644 --- a/scripts/mac_installer/desktop-deinstaller/deinstaller.go +++ b/scripts/mac_installer/desktop-deinstaller/deinstaller.go @@ -9,7 +9,7 @@ import ( "path/filepath" "syscall" - "github.com/skycoin/skycoin/src/util/logging" + "github.com/skycoin/skywire-utilities/pkg/logging" "github.com/skycoin/skywire/pkg/util/osutil" ) diff --git a/vendor/github.com/skycoin/dmsg/pkg/direct/client.go b/vendor/github.com/skycoin/dmsg/pkg/direct/client.go index 63885e80f3..c6f801d93e 100644 --- a/vendor/github.com/skycoin/dmsg/pkg/direct/client.go +++ b/vendor/github.com/skycoin/dmsg/pkg/direct/client.go @@ -8,7 +8,7 @@ import ( "github.com/skycoin/skywire-utilities/pkg/cipher" - "github.com/skycoin/skycoin/src/util/logging" + "github.com/skycoin/skywire-utilities/pkg/logging" ) // directClient represents a client that doesnot communicates with a dmsg-discovery, diff --git a/vendor/github.com/skycoin/dmsg/pkg/direct/direct.go b/vendor/github.com/skycoin/dmsg/pkg/direct/direct.go index f71f06cbbb..cbcfc91046 100644 --- a/vendor/github.com/skycoin/dmsg/pkg/direct/direct.go +++ b/vendor/github.com/skycoin/dmsg/pkg/direct/direct.go @@ -9,7 +9,7 @@ import ( "github.com/skycoin/skywire-utilities/pkg/cipher" - "github.com/skycoin/skycoin/src/util/logging" + "github.com/skycoin/skywire-utilities/pkg/logging" ) // StartDmsg starts dmsg directly without the discovery @@ -28,11 +28,11 @@ func StartDmsg(ctx context.Context, log *logging.Logger, pk cipher.PubKey, sk ci stop = func() { err := dmsgDC.Close() - log.WithError(err).Info("Disconnected from dmsg network.") + log.WithError(err).Debug("Disconnected from dmsg network.") } log.WithField("public_key", pk.String()). - Info("Connecting to dmsg network...") + Debug("Connecting to dmsg network...") select { case <-ctx.Done(): @@ -40,7 +40,7 @@ func StartDmsg(ctx context.Context, log *logging.Logger, pk cipher.PubKey, sk ci return nil, nil, ctx.Err() case <-dmsgDC.Ready(): - log.Info("Dmsg network ready.") + log.Debug("Dmsg network ready.") return dmsgDC, stop, nil } } diff --git a/vendor/github.com/skycoin/dmsg/pkg/disc/client.go b/vendor/github.com/skycoin/dmsg/pkg/disc/client.go index 883da98f99..57de88cdea 100644 --- a/vendor/github.com/skycoin/dmsg/pkg/disc/client.go +++ b/vendor/github.com/skycoin/dmsg/pkg/disc/client.go @@ -11,7 +11,7 @@ import ( "time" jsoniter "github.com/json-iterator/go" - "github.com/skycoin/skycoin/src/util/logging" + "github.com/skycoin/skywire-utilities/pkg/logging" "github.com/skycoin/skywire-utilities/pkg/cipher" ) diff --git a/vendor/github.com/skycoin/dmsg/pkg/dmsg/client.go b/vendor/github.com/skycoin/dmsg/pkg/dmsg/client.go index ac73793b3c..2e4dc6fac6 100644 --- a/vendor/github.com/skycoin/dmsg/pkg/dmsg/client.go +++ b/vendor/github.com/skycoin/dmsg/pkg/dmsg/client.go @@ -8,7 +8,7 @@ import ( "sync" "time" - "github.com/skycoin/skycoin/src/util/logging" + "github.com/skycoin/skywire-utilities/pkg/logging" "github.com/skycoin/dmsg/pkg/disc" @@ -135,7 +135,7 @@ func (*Client) Type() string { // It blocks until the client is closed. func (ce *Client) Serve(ctx context.Context) { defer func() { - ce.log.Info("Stopped serving client!") + ce.log.Debug("Stopped serving client!") }() cancellabelCtx, cancel := context.WithCancel(ctx) @@ -154,7 +154,7 @@ func (ce *Client) Serve(ctx context.Context) { return } - ce.log.Info("Discovering dmsg servers...") + ce.log.Debug("Discovering dmsg servers...") entries, err := ce.discoverServers(cancellabelCtx) if err != nil { ce.log.WithError(err).Warn("Failed to discover dmsg servers.") @@ -180,7 +180,7 @@ func (ce *Client) Serve(ctx context.Context) { case <-ce.done: return case err := <-ce.errCh: - ce.log.WithError(err).Info("Session stopped.") + ce.log.WithError(err).Debug("Session stopped.") if isClosed(ce.done) { return } @@ -210,7 +210,7 @@ func (ce *Client) Serve(ctx context.Context) { case <-ce.done: return case err := <-ce.errCh: - ce.log.WithError(err).Info("Session stopped.") + ce.log.WithError(err).Debug("Session stopped.") if isClosed(ce.done) { return } @@ -250,10 +250,10 @@ func (ce *Client) Close() error { for _, dSes := range ce.sessions { ce.log. WithError(dSes.Close()). - Info("Session closed.") + Debug("Session closed.") } ce.sessions = make(map[cipher.PubKey]*SessionCommon) - ce.log.Info("All sessions closed.") + ce.log.Debug("All sessions closed.") ce.sessionsMx.Unlock() ce.porter.CloseAll(ce.log) err = ce.EntityCommon.delEntry(context.Background()) @@ -355,7 +355,7 @@ func (ce *Client) EnsureSession(ctx context.Context, entry *disc.Entry) error { // If session with server of pk already exists, skip. if _, ok := ce.clientSession(ce.porter, entry.Static); ok { - ce.log.WithField("remote_pk", entry.Static).Info("Session already exists...") + ce.log.WithField("remote_pk", entry.Static).Debug("Session already exists...") return nil } @@ -368,7 +368,7 @@ func (ce *Client) EnsureSession(ctx context.Context, entry *disc.Entry) error { // NOTE: This should not be called directly as it may lead to session duplicates. // Only `ensureSession` or `EnsureAndObtainSession` should call this function. func (ce *Client) dialSession(ctx context.Context, entry *disc.Entry) (cs ClientSession, err error) { - ce.log.WithField("remote_pk", entry.Static).Info("Dialing session...") + ce.log.WithField("remote_pk", entry.Static).Debug("Dialing session...") const network = "tcp" @@ -399,7 +399,7 @@ func (ce *Client) dialSession(ctx context.Context, entry *disc.Entry) (cs Client } go func() { - ce.log.WithField("remote_pk", dSes.RemotePK()).Info("Serving session.") + ce.log.WithField("remote_pk", dSes.RemotePK()).Debug("Serving session.") err := dSes.serve() if !isClosed(ce.done) { // We should only report an error when client is not closed. diff --git a/vendor/github.com/skycoin/dmsg/pkg/dmsg/client_session.go b/vendor/github.com/skycoin/dmsg/pkg/dmsg/client_session.go index deab5a3e98..328c2b7e74 100644 --- a/vendor/github.com/skycoin/dmsg/pkg/dmsg/client_session.go +++ b/vendor/github.com/skycoin/dmsg/pkg/dmsg/client_session.go @@ -82,12 +82,12 @@ func (cs *ClientSession) serve() error { if netErr, ok := err.(net.Error); ok && netErr.Temporary() { //nolint cs.log. WithError(err). - Info("Failed to accept stream.") + Debug("Failed to accept stream.") continue } if errors.Is(err, yamux.ErrSessionShutdown) { - cs.log.WithError(err).Info("Stopped accepting streams.") + cs.log.WithError(err).Debug("Stopped accepting streams.") return err } cs.log.WithError(err).Warn("Stopped accepting streams.") diff --git a/vendor/github.com/skycoin/dmsg/pkg/dmsg/entity_common.go b/vendor/github.com/skycoin/dmsg/pkg/dmsg/entity_common.go index c9e0bfa0bb..23fe29819c 100644 --- a/vendor/github.com/skycoin/dmsg/pkg/dmsg/entity_common.go +++ b/vendor/github.com/skycoin/dmsg/pkg/dmsg/entity_common.go @@ -14,7 +14,7 @@ import ( "github.com/skycoin/skywire-utilities/pkg/cipher" "github.com/skycoin/skywire-utilities/pkg/netutil" - "github.com/skycoin/skycoin/src/util/logging" + "github.com/skycoin/skywire-utilities/pkg/logging" ) // EntityCommon contains the common fields and methods for server and client entities. diff --git a/vendor/github.com/skycoin/dmsg/pkg/dmsg/server.go b/vendor/github.com/skycoin/dmsg/pkg/dmsg/server.go index 2df207d513..e16405be7a 100644 --- a/vendor/github.com/skycoin/dmsg/pkg/dmsg/server.go +++ b/vendor/github.com/skycoin/dmsg/pkg/dmsg/server.go @@ -7,7 +7,7 @@ import ( "time" "github.com/sirupsen/logrus" - "github.com/skycoin/skycoin/src/util/logging" + "github.com/skycoin/skywire-utilities/pkg/logging" "github.com/skycoin/dmsg/internal/servermetrics" "github.com/skycoin/dmsg/pkg/disc" diff --git a/vendor/github.com/skycoin/dmsg/pkg/dmsgget/dmsgget.go b/vendor/github.com/skycoin/dmsg/pkg/dmsgget/dmsgget.go index 7198c45603..4e29eff013 100644 --- a/vendor/github.com/skycoin/dmsg/pkg/dmsgget/dmsgget.go +++ b/vendor/github.com/skycoin/dmsg/pkg/dmsgget/dmsgget.go @@ -13,7 +13,7 @@ import ( jsoniter "github.com/json-iterator/go" "github.com/sirupsen/logrus" - "github.com/skycoin/skycoin/src/util/logging" + "github.com/skycoin/skywire-utilities/pkg/logging" "github.com/skycoin/dmsg/pkg/disc" dmsg "github.com/skycoin/dmsg/pkg/dmsg" diff --git a/vendor/github.com/skycoin/dmsg/pkg/dmsghttp/http.go b/vendor/github.com/skycoin/dmsg/pkg/dmsghttp/http.go index 4e3ab2bbc8..d4e4a2b980 100644 --- a/vendor/github.com/skycoin/dmsg/pkg/dmsghttp/http.go +++ b/vendor/github.com/skycoin/dmsg/pkg/dmsghttp/http.go @@ -10,7 +10,7 @@ import ( "github.com/skycoin/skywire-utilities/pkg/cipher" - "github.com/skycoin/skycoin/src/util/logging" + "github.com/skycoin/skywire-utilities/pkg/logging" ) // ListenAndServe serves http over dmsg @@ -29,7 +29,7 @@ func ListenAndServe(ctx context.Context, pk cipher.PubKey, sk cipher.SecKey, a h }() log.WithField("dmsg_addr", fmt.Sprintf("dmsg://%v", lis.Addr().String())). - Info("Serving...") + Debug("Serving...") return http.Serve(lis, a) } diff --git a/vendor/github.com/skycoin/dmsg/pkg/dmsghttp/util.go b/vendor/github.com/skycoin/dmsg/pkg/dmsghttp/util.go index d412cbab34..923ce0afbe 100644 --- a/vendor/github.com/skycoin/dmsg/pkg/dmsghttp/util.go +++ b/vendor/github.com/skycoin/dmsg/pkg/dmsghttp/util.go @@ -8,7 +8,7 @@ import ( "github.com/skycoin/dmsg/pkg/disc" "github.com/skycoin/dmsg/pkg/dmsg" - "github.com/skycoin/skycoin/src/util/logging" + "github.com/skycoin/skywire-utilities/pkg/logging" ) // GetServers is used to get all the available servers from the dmsg-discovery. @@ -49,7 +49,7 @@ func UpdateServers(ctx context.Context, dClient disc.APIClient, dmsgDisc string, log.WithError(err).Error("Error getting dmsg-servers.") break } - log.Infof("Servers found : %v.", len(servers)) + log.Debugf("Servers found : %v.", len(servers)) for _, server := range servers { dClient.PostEntry(ctx, server) //nolint err := dmsgC.EnsureSession(ctx, server) diff --git a/vendor/github.com/skycoin/dmsg/pkg/dmsgpty/cli.go b/vendor/github.com/skycoin/dmsg/pkg/dmsgpty/cli.go index 663298afbc..ecff6f2877 100644 --- a/vendor/github.com/skycoin/dmsg/pkg/dmsgpty/cli.go +++ b/vendor/github.com/skycoin/dmsg/pkg/dmsgpty/cli.go @@ -11,7 +11,7 @@ import ( "syscall" "github.com/sirupsen/logrus" - "github.com/skycoin/skycoin/src/util/logging" + "github.com/skycoin/skywire-utilities/pkg/logging" "github.com/skycoin/skywire-utilities/pkg/cipher" ) @@ -99,7 +99,7 @@ func (cli *CLI) prepareConn() (net.Conn, error) { cli.Log. WithField("address", fmt.Sprintf("%s://%s", cli.Net, cli.Addr)). - Infof("Requesting...") + Debugf("Requesting...") conn, err := net.Dial(cli.Net, cli.Addr) if err != nil { @@ -115,7 +115,7 @@ func (cli *CLI) servePty(ctx context.Context, ptyC *PtyClient, cmd string, args cli.Log. WithField("cmd", fmt.Sprint(append([]string{cmd}, args...))). - Infof("Executing...") + Debugf("Executing...") if err := ptyC.Start(cmd, args...); err != nil { return fmt.Errorf("failed to start command on pty: %v", err) diff --git a/vendor/github.com/skycoin/dmsg/pkg/dmsgpty/host.go b/vendor/github.com/skycoin/dmsg/pkg/dmsgpty/host.go index 583cbe555e..b532a2a018 100644 --- a/vendor/github.com/skycoin/dmsg/pkg/dmsgpty/host.go +++ b/vendor/github.com/skycoin/dmsg/pkg/dmsgpty/host.go @@ -12,7 +12,7 @@ import ( "sync/atomic" "github.com/sirupsen/logrus" - "github.com/skycoin/skycoin/src/util/logging" + "github.com/skycoin/skywire-utilities/pkg/logging" dmsg "github.com/skycoin/dmsg/pkg/dmsg" @@ -63,7 +63,7 @@ func (h *Host) ServeCLI(ctx context.Context, lis net.Listener) error { continue } if err == io.ErrClosedPipe || strings.Contains(err.Error(), "use of closed network connection") { - log.Info("Cleanly stopped serving.") + log.Debug("Cleanly stopped serving.") return nil } log.Error("Failed to accept CLI connection with permanent error.") @@ -71,7 +71,7 @@ func (h *Host) ServeCLI(ctx context.Context, lis net.Listener) error { } log := log.WithField("cli_id", atomic.AddInt32(&h.cliN, 1)) - log.Info("CLI connection accepted.") + log.Debug("CLI connection accepted.") go func() { h.serveConn(ctx, log, &mux, conn) atomic.AddInt32(&h.cliN, -1) @@ -101,7 +101,7 @@ func (h *Host) ListenAndServe(ctx context.Context, port uint16) error { <-ctx.Done() log. WithError(lis.Close()). - Info("Serve() ended.") + Debug("Serve() ended.") }() for { @@ -114,7 +114,7 @@ func (h *Host) ListenAndServe(ctx context.Context, port uint16) error { } if err == io.ErrClosedPipe || err == dmsg.ErrEntityClosed || strings.Contains(err.Error(), "use of closed network connection") { - log.Info("Cleanly stopped serving.") + log.Debug("Cleanly stopped serving.") return nil } log.Error("Failed to accept dmsg.Stream with permanent error.") @@ -123,7 +123,7 @@ func (h *Host) ListenAndServe(ctx context.Context, port uint16) error { rPK := stream.RawRemoteAddr().PK log := log.WithField("remote_pk", rPK.String()) - log.Info("Processing dmsg.Stream...") + log.Debug("Processing dmsg.Stream...") if !h.authorize(log, rPK) { err := writeResponse(stream, @@ -137,7 +137,7 @@ func (h *Host) ListenAndServe(ctx context.Context, port uint16) error { } log = log.WithField("conn_id", atomic.AddInt32(&h.connN, 1)) - log.Info("dmsg.Stream accepted.") + log.Debug("dmsg.Stream accepted.") log = stream.Logger().WithField("dmsgpty", "stream") go func() { h.serveConn(ctx, log, &mux, stream) @@ -161,7 +161,7 @@ func (h *Host) serveConn(ctx context.Context, log logrus.FieldLogger, mux *hostM log.WithError(mux.ServeConn(ctx, conn)). WithField("error_close", <-closeErr). WithField("remote_addr", conn.RemoteAddr()). - Info("Stopped serving connection.") + Debug("Stopped serving connection.") } // authorize returns true if the provided public key is whitelisted. diff --git a/vendor/github.com/skycoin/dmsg/pkg/dmsgpty/pty_client.go b/vendor/github.com/skycoin/dmsg/pkg/dmsgpty/pty_client.go index 8e10c9bd52..5345e07f1f 100644 --- a/vendor/github.com/skycoin/dmsg/pkg/dmsgpty/pty_client.go +++ b/vendor/github.com/skycoin/dmsg/pkg/dmsgpty/pty_client.go @@ -7,7 +7,7 @@ import ( "sync" "github.com/sirupsen/logrus" - "github.com/skycoin/skycoin/src/util/logging" + "github.com/skycoin/skywire-utilities/pkg/logging" "github.com/skycoin/skywire-utilities/pkg/cipher" ) diff --git a/vendor/github.com/skycoin/dmsg/pkg/dmsgpty/ui.go b/vendor/github.com/skycoin/dmsg/pkg/dmsgpty/ui.go index da295055b5..4b7ced39e7 100644 --- a/vendor/github.com/skycoin/dmsg/pkg/dmsgpty/ui.go +++ b/vendor/github.com/skycoin/dmsg/pkg/dmsgpty/ui.go @@ -11,7 +11,7 @@ import ( "time" "github.com/sirupsen/logrus" - "github.com/skycoin/skycoin/src/util/logging" + "github.com/skycoin/skywire-utilities/pkg/logging" "nhooyr.io/websocket" "github.com/skycoin/skywire-utilities/pkg/httputil" @@ -117,15 +117,15 @@ func (ui *UI) Handler() http.HandlerFunc { n, err := writeTermHTML(w) logrus.WithError(err). WithField("bytes", n). - Info("Served web page.") + Debug("Served web page.") return } // serve terminal sID := atomic.AddInt32(&sc, 1) log = log.WithField("ui_sid", sID) - log.Info("Serving terminal websocket...") - defer func() { log.Infof("Terminal closed: %d terminals left open.", atomic.AddInt32(&sc, -1)+1) }() + log.Debug("Serving terminal websocket...") + defer func() { log.Debugf("Terminal closed: %d terminals left open.", atomic.AddInt32(&sc, -1)+1) }() // open websocket ws, err := websocket.Accept(w, r, nil) diff --git a/vendor/github.com/skycoin/dmsg/pkg/ioutil/logging.go b/vendor/github.com/skycoin/dmsg/pkg/ioutil/logging.go index 71c97a40ee..8e375b4d7e 100644 --- a/vendor/github.com/skycoin/dmsg/pkg/ioutil/logging.go +++ b/vendor/github.com/skycoin/dmsg/pkg/ioutil/logging.go @@ -1,7 +1,7 @@ package ioutil import ( - "github.com/skycoin/skycoin/src/util/logging" + "github.com/skycoin/skywire-utilities/pkg/logging" ) var log = logging.MustGetLogger("ioutil") diff --git a/vendor/github.com/skycoin/dmsg/pkg/noise/noise.go b/vendor/github.com/skycoin/dmsg/pkg/noise/noise.go index e416231f66..189c49536d 100644 --- a/vendor/github.com/skycoin/dmsg/pkg/noise/noise.go +++ b/vendor/github.com/skycoin/dmsg/pkg/noise/noise.go @@ -7,7 +7,7 @@ import ( "fmt" "github.com/skycoin/noise" - "github.com/skycoin/skycoin/src/util/logging" + "github.com/skycoin/skywire-utilities/pkg/logging" "github.com/skycoin/skywire-utilities/pkg/cipher" ) diff --git a/vendor/github.com/skycoin/skywire-utilities/pkg/cmdutil/service_flags.go b/vendor/github.com/skycoin/skywire-utilities/pkg/cmdutil/service_flags.go index 6fbaa75e56..77b0a35e50 100644 --- a/vendor/github.com/skycoin/skywire-utilities/pkg/cmdutil/service_flags.go +++ b/vendor/github.com/skycoin/skywire-utilities/pkg/cmdutil/service_flags.go @@ -10,7 +10,7 @@ import ( "unicode" jsoniter "github.com/json-iterator/go" - "github.com/skycoin/skycoin/src/util/logging" + "github.com/skycoin/skywire-utilities/pkg/logging" "github.com/spf13/cobra" ) diff --git a/vendor/github.com/skycoin/skywire-utilities/pkg/cmdutil/sysloghook_unix.go b/vendor/github.com/skycoin/skywire-utilities/pkg/cmdutil/sysloghook_unix.go index 7575ec5272..eb2c421b36 100644 --- a/vendor/github.com/skycoin/skywire-utilities/pkg/cmdutil/sysloghook_unix.go +++ b/vendor/github.com/skycoin/skywire-utilities/pkg/cmdutil/sysloghook_unix.go @@ -9,7 +9,7 @@ import ( "github.com/sirupsen/logrus" logrussyslog "github.com/sirupsen/logrus/hooks/syslog" - "github.com/skycoin/skycoin/src/util/logging" + "github.com/skycoin/skywire-utilities/pkg/logging" ) func (sf *ServiceFlags) sysLogHook(log *logging.Logger, sysLvl int) { diff --git a/vendor/github.com/skycoin/skywire-utilities/pkg/cmdutil/sysloghook_windows.go b/vendor/github.com/skycoin/skywire-utilities/pkg/cmdutil/sysloghook_windows.go index b045610f13..60462931de 100644 --- a/vendor/github.com/skycoin/skywire-utilities/pkg/cmdutil/sysloghook_windows.go +++ b/vendor/github.com/skycoin/skywire-utilities/pkg/cmdutil/sysloghook_windows.go @@ -7,7 +7,7 @@ import ( "strings" "github.com/sirupsen/logrus" - "github.com/skycoin/skycoin/src/util/logging" + "github.com/skycoin/skywire-utilities/pkg/logging" ) func (sf *ServiceFlags) sysLogHook(_ *logging.Logger, _ int) { diff --git a/vendor/github.com/skycoin/skywire-utilities/pkg/geo/geo.go b/vendor/github.com/skycoin/skywire-utilities/pkg/geo/geo.go index 9c338ac317..eff2beeaba 100644 --- a/vendor/github.com/skycoin/skywire-utilities/pkg/geo/geo.go +++ b/vendor/github.com/skycoin/skywire-utilities/pkg/geo/geo.go @@ -9,7 +9,7 @@ import ( "net/http" "github.com/sirupsen/logrus" - "github.com/skycoin/skycoin/src/util/logging" + "github.com/skycoin/skywire-utilities/pkg/logging" "github.com/skycoin/skywire-utilities/pkg/netutil" ) diff --git a/vendor/github.com/skycoin/skywire-utilities/pkg/httputil/httputil.go b/vendor/github.com/skycoin/skywire-utilities/pkg/httputil/httputil.go index 49c482919b..3976d39099 100644 --- a/vendor/github.com/skycoin/skywire-utilities/pkg/httputil/httputil.go +++ b/vendor/github.com/skycoin/skywire-utilities/pkg/httputil/httputil.go @@ -10,7 +10,7 @@ import ( "github.com/go-chi/chi/v5/middleware" jsoniter "github.com/json-iterator/go" "github.com/sirupsen/logrus" - "github.com/skycoin/skycoin/src/util/logging" + "github.com/skycoin/skywire-utilities/pkg/logging" ) var json = jsoniter.ConfigFastest diff --git a/vendor/github.com/skycoin/skycoin/src/util/logging/formatter.go b/vendor/github.com/skycoin/skywire-utilities/pkg/logging/formatter.go similarity index 97% rename from vendor/github.com/skycoin/skycoin/src/util/logging/formatter.go rename to vendor/github.com/skycoin/skywire-utilities/pkg/logging/formatter.go index e9066f4ccc..93dd5512c1 100644 --- a/vendor/github.com/skycoin/skycoin/src/util/logging/formatter.go +++ b/vendor/github.com/skycoin/skywire-utilities/pkg/logging/formatter.go @@ -12,7 +12,7 @@ import ( "github.com/mgutz/ansi" "github.com/sirupsen/logrus" - "golang.org/x/crypto/ssh/terminal" + "golang.org/x/term" ) const defaultTimestampFormat = time.RFC3339 @@ -26,6 +26,7 @@ var ( FatalLevelStyle: "red", PanicLevelStyle: "red", DebugLevelStyle: "blue", + TraceLevelStyle: "black", PrefixStyle: "cyan", TimestampStyle: "black+h", CallContextStyle: "black+h", @@ -38,6 +39,7 @@ var ( FatalLevelColor: ansi.ColorFunc(""), PanicLevelColor: ansi.ColorFunc(""), DebugLevelColor: ansi.ColorFunc(""), + TraceLevelColor: ansi.ColorFunc(""), PrefixColor: ansi.ColorFunc(""), TimestampColor: ansi.ColorFunc(""), CallContextColor: ansi.ColorFunc(""), @@ -58,6 +60,7 @@ type ColorScheme struct { FatalLevelStyle string PanicLevelStyle string DebugLevelStyle string + TraceLevelStyle string PrefixStyle string TimestampStyle string CallContextStyle string @@ -71,6 +74,7 @@ type compiledColorScheme struct { FatalLevelColor func(string) string PanicLevelColor func(string) string DebugLevelColor func(string) string + TraceLevelColor func(string) string PrefixColor func(string) string TimestampColor func(string) string CallContextColor func(string) string @@ -149,6 +153,7 @@ func compileColorScheme(s *ColorScheme) *compiledColorScheme { FatalLevelColor: getCompiledColor(s.FatalLevelStyle, defaultColorScheme.FatalLevelStyle), PanicLevelColor: getCompiledColor(s.PanicLevelStyle, defaultColorScheme.PanicLevelStyle), DebugLevelColor: getCompiledColor(s.DebugLevelStyle, defaultColorScheme.DebugLevelStyle), + TraceLevelColor: getCompiledColor(s.TraceLevelStyle, defaultColorScheme.TraceLevelStyle), PrefixColor: getCompiledColor(s.PrefixStyle, defaultColorScheme.PrefixStyle), TimestampColor: getCompiledColor(s.TimestampStyle, defaultColorScheme.TimestampStyle), CallContextColor: getCompiledColor(s.CallContextStyle, defaultColorScheme.CallContextStyle), @@ -168,7 +173,7 @@ func (f *TextFormatter) init(entry *logrus.Entry) { func (f *TextFormatter) checkIfTerminal(w io.Writer) bool { switch v := w.(type) { case *os.File: - return terminal.IsTerminal(int(v.Fd())) + return term.IsTerminal(int(v.Fd())) default: return false } @@ -249,6 +254,8 @@ func (f *TextFormatter) printColored(b *bytes.Buffer, entry *logrus.Entry, keys levelColor = colorScheme.FatalLevelColor case logrus.PanicLevel: levelColor = colorScheme.PanicLevelColor + case logrus.TraceLevel: + levelColor = colorScheme.TraceLevelColor default: levelColor = colorScheme.DebugLevelColor } diff --git a/vendor/github.com/skycoin/skycoin/src/util/logging/hooks.go b/vendor/github.com/skycoin/skywire-utilities/pkg/logging/hooks.go similarity index 100% rename from vendor/github.com/skycoin/skycoin/src/util/logging/hooks.go rename to vendor/github.com/skycoin/skywire-utilities/pkg/logging/hooks.go diff --git a/vendor/github.com/skycoin/skycoin/src/util/logging/logger.go b/vendor/github.com/skycoin/skywire-utilities/pkg/logging/logger.go similarity index 85% rename from vendor/github.com/skycoin/skycoin/src/util/logging/logger.go rename to vendor/github.com/skycoin/skywire-utilities/pkg/logging/logger.go index 7b7e335973..cee9693aed 100644 --- a/vendor/github.com/skycoin/skycoin/src/util/logging/logger.go +++ b/vendor/github.com/skycoin/skywire-utilities/pkg/logging/logger.go @@ -56,16 +56,6 @@ func (logger *MasterLogger) PackageLogger(moduleName string) *Logger { } } -// AddHook adds a logrus.Hook to the logger and its module loggers -func (logger *MasterLogger) AddHook(hook logrus.Hook) { - logger.Hooks.Add(hook) -} - -// SetLevel sets the log level for the logger and its module loggers -func (logger *MasterLogger) SetLevel(level logrus.Level) { - logger.Level = level -} - // EnableColors enables colored logging func (logger *MasterLogger) EnableColors() { logger.Formatter.(*TextFormatter).DisableColors = false diff --git a/vendor/github.com/skycoin/skycoin/src/util/logging/logging.go b/vendor/github.com/skycoin/skywire-utilities/pkg/logging/logging.go similarity index 92% rename from vendor/github.com/skycoin/skycoin/src/util/logging/logging.go rename to vendor/github.com/skycoin/skywire-utilities/pkg/logging/logging.go index f7b86ffc6a..5b1a21278f 100644 --- a/vendor/github.com/skycoin/skycoin/src/util/logging/logging.go +++ b/vendor/github.com/skycoin/skywire-utilities/pkg/logging/logging.go @@ -38,6 +38,8 @@ func LevelFromString(s string) (logrus.Level, error) { return logrus.FatalLevel, nil case "panic": return logrus.PanicLevel, nil + case "trace": + return logrus.TraceLevel, nil default: return logrus.DebugLevel, errors.New("could not convert string to log level") } @@ -68,6 +70,11 @@ func SetLevel(level logrus.Level) { log.SetLevel(level) } +// GetLevel returns the logger level +func GetLevel() logrus.Level { + return log.GetLevel() +} + // SetOutputTo sets the logger's output to an io.Writer func SetOutputTo(w io.Writer) { log.Out = w diff --git a/vendor/github.com/skycoin/skywire-utilities/pkg/netutil/retrier.go b/vendor/github.com/skycoin/skywire-utilities/pkg/netutil/retrier.go index e49229150a..6a5418fc16 100644 --- a/vendor/github.com/skycoin/skywire-utilities/pkg/netutil/retrier.go +++ b/vendor/github.com/skycoin/skywire-utilities/pkg/netutil/retrier.go @@ -3,6 +3,7 @@ package netutil import ( "context" "errors" + "fmt" "time" "github.com/sirupsen/logrus" @@ -36,14 +37,16 @@ type Retrier struct { // NewRetrier returns a retrier that is ready to call Do() method func NewRetrier(log logrus.FieldLogger, initBO, maxBO time.Duration, tries int64, factor float64) *Retrier { - logger := log.WithField("func", "retrier") + if log != nil { + log = log.WithField("func", "retrier") + } return &Retrier{ initBO: initBO, maxBO: maxBO, tries: tries, factor: factor, errWl: make(map[error]struct{}), - log: logger, + log: log, } } @@ -82,6 +85,8 @@ func (r *Retrier) Do(ctx context.Context, f RetryFunc) error { case <-t.C: if r.log != nil { r.log.WithError(err).WithField("current_backoff", bo).Warn("Retrying...") + } else { + fmt.Printf("func = retrier, current_backoff = %v Retrying...\n", bo) } t.Reset(bo) continue diff --git a/vendor/golang.org/x/crypto/ssh/terminal/terminal.go b/vendor/golang.org/x/crypto/ssh/terminal/terminal.go deleted file mode 100644 index a4d1919a9e..0000000000 --- a/vendor/golang.org/x/crypto/ssh/terminal/terminal.go +++ /dev/null @@ -1,76 +0,0 @@ -// Copyright 2011 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// Package terminal provides support functions for dealing with terminals, as -// commonly found on UNIX systems. -// -// Deprecated: this package moved to golang.org/x/term. -package terminal - -import ( - "io" - - "golang.org/x/term" -) - -// EscapeCodes contains escape sequences that can be written to the terminal in -// order to achieve different styles of text. -type EscapeCodes = term.EscapeCodes - -// Terminal contains the state for running a VT100 terminal that is capable of -// reading lines of input. -type Terminal = term.Terminal - -// NewTerminal runs a VT100 terminal on the given ReadWriter. If the ReadWriter is -// a local terminal, that terminal must first have been put into raw mode. -// prompt is a string that is written at the start of each input line (i.e. -// "> "). -func NewTerminal(c io.ReadWriter, prompt string) *Terminal { - return term.NewTerminal(c, prompt) -} - -// ErrPasteIndicator may be returned from ReadLine as the error, in addition -// to valid line data. It indicates that bracketed paste mode is enabled and -// that the returned line consists only of pasted data. Programs may wish to -// interpret pasted data more literally than typed data. -var ErrPasteIndicator = term.ErrPasteIndicator - -// State contains the state of a terminal. -type State = term.State - -// IsTerminal returns whether the given file descriptor is a terminal. -func IsTerminal(fd int) bool { - return term.IsTerminal(fd) -} - -// ReadPassword reads a line of input from a terminal without local echo. This -// is commonly used for inputting passwords and other sensitive data. The slice -// returned does not include the \n. -func ReadPassword(fd int) ([]byte, error) { - return term.ReadPassword(fd) -} - -// MakeRaw puts the terminal connected to the given file descriptor into raw -// mode and returns the previous state of the terminal so that it can be -// restored. -func MakeRaw(fd int) (*State, error) { - return term.MakeRaw(fd) -} - -// Restore restores the terminal connected to the given file descriptor to a -// previous state. -func Restore(fd int, oldState *State) error { - return term.Restore(fd, oldState) -} - -// GetState returns the current state of a terminal which may be useful to -// restore the terminal after a signal. -func GetState(fd int) (*State, error) { - return term.GetState(fd) -} - -// GetSize returns the dimensions of the given terminal. -func GetSize(fd int) (width, height int, err error) { - return term.GetSize(fd) -} diff --git a/vendor/modules.txt b/vendor/modules.txt index fa8c63ac80..adadeb9f8d 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -141,7 +141,7 @@ github.com/shirou/gopsutil/v3/process ## explicit; go 1.13 github.com/sirupsen/logrus github.com/sirupsen/logrus/hooks/syslog -# github.com/skycoin/dmsg v0.0.0-20220607114207-d4a85dc351ce +# github.com/skycoin/dmsg v0.0.0-20220617100223-c17f98a92a47 ## explicit; go 1.16 github.com/skycoin/dmsg/internal/servermetrics github.com/skycoin/dmsg/pkg/direct @@ -164,14 +164,14 @@ github.com/skycoin/skycoin/src/cipher/base58 github.com/skycoin/skycoin/src/cipher/ripemd160 github.com/skycoin/skycoin/src/cipher/secp256k1-go github.com/skycoin/skycoin/src/cipher/secp256k1-go/secp256k1-go2 -github.com/skycoin/skycoin/src/util/logging -# github.com/skycoin/skywire-utilities v0.0.0-20220511053113-3d492e0048c4 +# github.com/skycoin/skywire-utilities v0.0.0-20220617085111-5c8c8d3ced14 ## explicit; go 1.17 github.com/skycoin/skywire-utilities/pkg/buildinfo github.com/skycoin/skywire-utilities/pkg/cipher github.com/skycoin/skywire-utilities/pkg/cmdutil github.com/skycoin/skywire-utilities/pkg/geo github.com/skycoin/skywire-utilities/pkg/httputil +github.com/skycoin/skywire-utilities/pkg/logging github.com/skycoin/skywire-utilities/pkg/metricsutil github.com/skycoin/skywire-utilities/pkg/netutil github.com/skycoin/skywire-utilities/pkg/skyenv @@ -250,7 +250,6 @@ golang.org/x/crypto/internal/subtle golang.org/x/crypto/pbkdf2 golang.org/x/crypto/salsa20 golang.org/x/crypto/salsa20/salsa -golang.org/x/crypto/ssh/terminal golang.org/x/crypto/tea golang.org/x/crypto/twofish golang.org/x/crypto/xtea