diff --git a/cmd/apps/skychat/chat.go b/cmd/apps/skychat/chat.go index f2ae7df808..56b14cd3cc 100644 --- a/cmd/apps/skychat/chat.go +++ b/cmd/apps/skychat/chat.go @@ -24,6 +24,7 @@ import ( ) const ( + appName = "skychat" netType = appnet.TypeDMSG port = routing.Port(1024) ) @@ -40,7 +41,6 @@ var ( ) func main() { - appName := "skychat" log = app2.NewLogger(appName) flag.Parse() diff --git a/cmd/apps/therealproxy-client/therealproxy-client.go b/cmd/apps/therealproxy-client/therealproxy-client.go index e06a292d2c..cd93d8d983 100644 --- a/cmd/apps/therealproxy-client/therealproxy-client.go +++ b/cmd/apps/therealproxy-client/therealproxy-client.go @@ -20,6 +20,7 @@ import ( ) const ( + appName = "socksproxy-client" netType = appnet.TypeDMSG socksPort = routing.Port(3) ) @@ -27,8 +28,6 @@ const ( var r = netutil.NewRetrier(time.Second, 0, 1) func main() { - appName := "socksproxy-client" - log := app2.NewLogger(appName) therealproxy.Log = log.PackageLogger("therealproxy") diff --git a/cmd/apps/therealproxy/therealproxy.go b/cmd/apps/therealproxy/therealproxy.go index e15e430bfc..e7e75ed880 100644 --- a/cmd/apps/therealproxy/therealproxy.go +++ b/cmd/apps/therealproxy/therealproxy.go @@ -16,13 +16,12 @@ import ( ) const ( + appName = "socksproxy" netType = appnet.TypeDMSG port = routing.Port(1024) ) func main() { - appName := "socksproxy" - log := app2.NewLogger(appName) therealproxy.Log = log.PackageLogger("therealproxy") diff --git a/cmd/apps/therealssh-client/therealssh-client.go b/cmd/apps/therealssh-client/therealssh-client.go index aac5642730..8f327db85b 100644 --- a/cmd/apps/therealssh-client/therealssh-client.go +++ b/cmd/apps/therealssh-client/therealssh-client.go @@ -5,34 +5,41 @@ package main import ( "flag" + "fmt" "net/http" "github.com/sirupsen/logrus" "github.com/skycoin/skycoin/src/util/logging" - "github.com/skycoin/skywire/pkg/app" + "github.com/skycoin/skywire/pkg/app2" ssh "github.com/skycoin/skywire/pkg/therealssh" ) +const ( + appName = "SSH-client" +) + var log *logging.MasterLogger func main() { - log = app.NewLogger("SSH-client") + log = app2.NewLogger(appName) ssh.Log = log.PackageLogger("therealssh") var rpcAddr = flag.String("rpc", ":2222", "Client RPC address to listen on") var debug = flag.Bool("debug", false, "enable debug messages") flag.Parse() - config := &app.Config{AppName: "SSH-client", AppVersion: "1.0", ProtocolVersion: "0.0.1"} - sshApp, err := app.Setup(config) + config, err := app2.ClientConfigFromEnv() + if err != nil { + log.Fatalf("Error getting client config: %v\n", err) + } + + sshApp, err := app2.NewClient(logging.MustGetLogger(fmt.Sprintf("app_%s", appName)), config) if err != nil { log.Fatal("Setup failure: ", err) } defer func() { - if err := sshApp.Close(); err != nil { - log.Println("Failed to close app:", err) - } + sshApp.Close() }() ssh.Debug = *debug diff --git a/cmd/apps/therealssh/therealssh.go b/cmd/apps/therealssh/therealssh.go index ca71a7c567..32e7c95591 100644 --- a/cmd/apps/therealssh/therealssh.go +++ b/cmd/apps/therealssh/therealssh.go @@ -20,13 +20,12 @@ import ( var log *logging.MasterLogger const ( + appName = "SSH" netType = appnet.TypeDMSG port = routing.Port(1000) ) func main() { - appName := "SSH" - log = app2.NewLogger(appName) ssh.Log = log.PackageLogger("therealssh") diff --git a/pkg/therealssh/client_test.go b/pkg/therealssh/client_test.go index 9402246f7c..4b8507209e 100644 --- a/pkg/therealssh/client_test.go +++ b/pkg/therealssh/client_test.go @@ -9,6 +9,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "github.com/skycoin/skywire/pkg/app2/appnet" "github.com/skycoin/skywire/pkg/routing" ) @@ -91,7 +92,7 @@ func newPipeDialer() (net.Conn, *pipeDialer) { return out, &pipeDialer{in} } -func (d *pipeDialer) Dial(raddr routing.Addr) (net.Conn, error) { +func (d *pipeDialer) Dial(raddr appnet.Addr) (net.Conn, error) { return d.conn, nil } diff --git a/pkg/therealssh/dialer.go b/pkg/therealssh/dialer.go index 7e5da3a9b3..5ecce39f2c 100644 --- a/pkg/therealssh/dialer.go +++ b/pkg/therealssh/dialer.go @@ -3,10 +3,10 @@ package therealssh import ( "net" - "github.com/skycoin/skywire/pkg/routing" + "github.com/skycoin/skywire/pkg/app2/appnet" ) // dialer dials to a remote node. type dialer interface { - Dial(raddr routing.Addr) (net.Conn, error) + Dial(raddr appnet.Addr) (net.Conn, error) } diff --git a/pkg/therealssh/pty_test.go b/pkg/therealssh/pty_test.go index d5483e7bad..d15fab1f83 100644 --- a/pkg/therealssh/pty_test.go +++ b/pkg/therealssh/pty_test.go @@ -14,6 +14,7 @@ import ( "github.com/skycoin/skycoin/src/util/logging" "github.com/stretchr/testify/require" + "github.com/skycoin/skywire/pkg/app2/appnet" "github.com/skycoin/skywire/pkg/routing" ) @@ -83,7 +84,7 @@ type PipeDialer struct { dialConn, acceptConn net.Conn } -func (p PipeDialer) Dial(raddr routing.Addr) (c net.Conn, err error) { +func (p PipeDialer) Dial(raddr appnet.Addr) (c net.Conn, err error) { return p.dialConn, nil }