Skip to content

Commit

Permalink
Refactor apps
Browse files Browse the repository at this point in the history
  • Loading branch information
Darkren committed Oct 25, 2019
1 parent 00194be commit 3a51ddd
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 18 deletions.
2 changes: 1 addition & 1 deletion cmd/apps/skychat/chat.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
)

const (
appName = "skychat"
netType = appnet.TypeDMSG
port = routing.Port(1024)
)
Expand All @@ -40,7 +41,6 @@ var (
)

func main() {
appName := "skychat"
log = app2.NewLogger(appName)
flag.Parse()

Expand Down
3 changes: 1 addition & 2 deletions cmd/apps/therealproxy-client/therealproxy-client.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,14 @@ import (
)

const (
appName = "socksproxy-client"
netType = appnet.TypeDMSG
socksPort = routing.Port(3)
)

var r = netutil.NewRetrier(time.Second, 0, 1)

func main() {
appName := "socksproxy-client"

log := app2.NewLogger(appName)
therealproxy.Log = log.PackageLogger("therealproxy")

Expand Down
3 changes: 1 addition & 2 deletions cmd/apps/therealproxy/therealproxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down
21 changes: 14 additions & 7 deletions cmd/apps/therealssh-client/therealssh-client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions cmd/apps/therealssh/therealssh.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down
3 changes: 2 additions & 1 deletion pkg/therealssh/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -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
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/therealssh/dialer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
3 changes: 2 additions & 1 deletion pkg/therealssh/pty_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -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
}

Expand Down

0 comments on commit 3a51ddd

Please sign in to comment.