Skip to content

Commit

Permalink
Refactor therealssh
Browse files Browse the repository at this point in the history
  • Loading branch information
Darkren committed Oct 25, 2019
1 parent 626220f commit 00194be
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 15 deletions.
9 changes: 3 additions & 6 deletions cmd/apps/therealproxy-client/therealproxy-client.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,13 @@ import (
"net"
"time"

"github.com/skycoin/skywire/pkg/app2/appnet"

"github.com/skycoin/skycoin/src/util/logging"

"github.com/skycoin/skywire/pkg/app2"

"github.com/skycoin/dmsg/cipher"
"github.com/skycoin/skycoin/src/util/logging"

"github.com/skycoin/skywire/internal/netutil"
"github.com/skycoin/skywire/internal/therealproxy"
"github.com/skycoin/skywire/pkg/app2"
"github.com/skycoin/skywire/pkg/app2/appnet"
"github.com/skycoin/skywire/pkg/routing"
)

Expand Down
35 changes: 26 additions & 9 deletions cmd/apps/therealssh/therealssh.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,35 +5,47 @@ package main

import (
"flag"
"fmt"

"github.com/mitchellh/go-homedir"
"github.com/sirupsen/logrus"
"github.com/skycoin/skycoin/src/util/logging"

"github.com/skycoin/skywire/pkg/app"
ssh "github.com/skycoin/skywire/pkg/therealssh"

"github.com/skycoin/skywire/pkg/app2"
"github.com/skycoin/skywire/pkg/app2/appnet"
"github.com/skycoin/skywire/pkg/routing"
)

var log *logging.MasterLogger

const (
netType = appnet.TypeDMSG
port = routing.Port(1000)
)

func main() {
log = app.NewLogger("SSH")
appName := "SSH"

log = app2.NewLogger(appName)
ssh.Log = log.PackageLogger("therealssh")

var authFile = flag.String("auth", "~/.therealssh/authorized_keys", "Auth file location. Should contain one PubKey per line.")
var debug = flag.Bool("debug", false, "enable debug messages")

flag.Parse()

config := &app.Config{AppName: "SSH", 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()
}()

path, err := homedir.Expand(*authFile)
Expand All @@ -58,8 +70,13 @@ func main() {
}
}()

l, err := sshApp.Listen(netType, port)
if err != nil {
log.Fatalf("Error listening network %v on port %d: %v\n", netType, port, err)
}

for {
conn, err := sshApp.Accept()
conn, err := l.Accept()
if err != nil {
log.Fatal("failed to receive packet: ", err)
}
Expand Down

0 comments on commit 00194be

Please sign in to comment.