Skip to content

Commit

Permalink
Merge branch 'milestone2' into feature/restart-visor
Browse files Browse the repository at this point in the history
# Conflicts:
#	pkg/router/routerclient/client.go
#	pkg/visor/rpc_client.go
#	pkg/visor/visor.go
  • Loading branch information
nkryuchkov committed Dec 23, 2019
2 parents 01ae1ba + 164c995 commit 3c218ed
Show file tree
Hide file tree
Showing 154 changed files with 6,316 additions and 3,867 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ bin: ## Build `skywire-visor`, `skywire-cli`, `hypervisor`, `SSH-cli`
${OPTS} go build ${BUILD_OPTS} -o ./skywire-visor ./cmd/skywire-visor
${OPTS} go build ${BUILD_OPTS} -o ./skywire-cli ./cmd/skywire-cli
${OPTS} go build ${BUILD_OPTS} -o ./setup-node ./cmd/setup-node
${OPTS} go build ${BUILD_OPTS} -o ./messaging-server ./cmd/messaging-server
${OPTS} go build ${BUILD_OPTS} -o ./dmsg-server ./cmd/dmsg-server
${OPTS} go build ${BUILD_OPTS} -o ./hypervisor ./cmd/hypervisor
${OPTS} go build ${BUILD_OPTS} -o ./SSH-cli ./cmd/therealssh-cli
${OPTS} go build ${BUILD_OPTS} -o ./dmsgpty ./cmd/dmsgpty
Expand Down
8 changes: 4 additions & 4 deletions cmd/apps/helloworld/helloworld.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import (
"github.com/SkycoinProject/dmsg/cipher"
"github.com/SkycoinProject/skycoin/src/util/logging"

"github.com/SkycoinProject/skywire-mainnet/pkg/app2"
"github.com/SkycoinProject/skywire-mainnet/pkg/app2/appnet"
"github.com/SkycoinProject/skywire-mainnet/pkg/app"
"github.com/SkycoinProject/skywire-mainnet/pkg/app/appnet"
"github.com/SkycoinProject/skywire-mainnet/pkg/routing"
)

Expand All @@ -20,12 +20,12 @@ const (
)

func main() {
clientConfig, err := app2.ClientConfigFromEnv()
clientConfig, err := app.ClientConfigFromEnv()
if err != nil {
log.Fatalf("Error getting client config: %v\n", err)
}

app, err := app2.NewClient(logging.MustGetLogger("helloworld"), clientConfig)
app, err := app.NewClient(logging.MustGetLogger("helloworld"), clientConfig)
if err != nil {
log.Fatalf("Error creating app client: %v\n", err)
}
Expand Down
18 changes: 11 additions & 7 deletions cmd/apps/skychat/chat.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ import (
"github.com/SkycoinProject/skycoin/src/util/logging"

"github.com/SkycoinProject/skywire-mainnet/internal/netutil"
"github.com/SkycoinProject/skywire-mainnet/pkg/app2"
"github.com/SkycoinProject/skywire-mainnet/pkg/app2/appnet"
"github.com/SkycoinProject/skywire-mainnet/pkg/app"
"github.com/SkycoinProject/skywire-mainnet/pkg/app/appnet"
"github.com/SkycoinProject/skywire-mainnet/pkg/routing"
)

Expand All @@ -33,28 +33,29 @@ var addr = flag.String("addr", ":8000", "address to bind")
var r = netutil.NewRetrier(50*time.Millisecond, 5, 2)

var (
chatApp *app2.Client
chatApp *app.Client
clientCh chan string
chatConns map[cipher.PubKey]net.Conn
connsMu sync.Mutex
log *logging.MasterLogger
)

func main() {
log = app2.NewLogger(appName)
log = app.NewLogger(appName)
flag.Parse()

clientConfig, err := app2.ClientConfigFromEnv()
clientConfig, err := app.ClientConfigFromEnv()
if err != nil {
log.Fatalf("Error getting client config: %v\n", err)
}

// TODO: pass `log`?
a, err := app2.NewClient(logging.MustGetLogger(fmt.Sprintf("app_%s", appName)), clientConfig)
a, err := app.NewClient(logging.MustGetLogger(fmt.Sprintf("app_%s", appName)), clientConfig)
if err != nil {
log.Fatal("Setup failure: ", err)
}
defer a.Close()
log.Println("Successfully created skychat app")

chatApp = a

Expand All @@ -75,21 +76,24 @@ func main() {
func listenLoop() {
l, err := chatApp.Listen(netType, port)
if err != nil {
log.Printf("Error listening network %v on port %d: %v\n", netType, port)
log.Printf("Error listening network %v on port %d: %v\n", netType, port, err)
return
}

for {
log.Println("Accepting skychat conn...")
conn, err := l.Accept()
if err != nil {
log.Println("Failed to accept conn:", err)
return
}
log.Println("Accepted skychat conn")

raddr := conn.RemoteAddr().(appnet.Addr)
connsMu.Lock()
chatConns[raddr.PubKey] = conn
connsMu.Unlock()
log.Printf("Accepted skychat conn on %s from %s\n", conn.LocalAddr(), raddr.PubKey)

go handleConn(conn)
}
Expand Down
16 changes: 9 additions & 7 deletions cmd/apps/therealproxy-client/therealproxy-client.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ import (
"github.com/SkycoinProject/skywire-mainnet/internal/netutil"
"github.com/SkycoinProject/skywire-mainnet/internal/skyenv"
"github.com/SkycoinProject/skywire-mainnet/internal/therealproxy"
"github.com/SkycoinProject/skywire-mainnet/pkg/app2"
"github.com/SkycoinProject/skywire-mainnet/pkg/app2/appnet"
"github.com/SkycoinProject/skywire-mainnet/pkg/app"
"github.com/SkycoinProject/skywire-mainnet/pkg/app/appnet"
"github.com/SkycoinProject/skywire-mainnet/pkg/routing"
)

Expand All @@ -29,19 +29,19 @@ const (
var r = netutil.NewRetrier(time.Second, 0, 1)

func main() {
log := app2.NewLogger(appName)
log := app.NewLogger(appName)
therealproxy.Log = log.PackageLogger("therealproxy")

var addr = flag.String("addr", skyenv.SkyproxyClientAddr, "Client address to listen on")
var serverPK = flag.String("srv", "", "PubKey of the server to connect to")
flag.Parse()

config, err := app2.ClientConfigFromEnv()
config, err := app.ClientConfigFromEnv()
if err != nil {
log.Fatalf("Error getting client config: %v\n", err)
}

socksApp, err := app2.NewClient(logging.MustGetLogger(fmt.Sprintf("app_%s", appName)), config)
socksApp, err := app.NewClient(logging.MustGetLogger(fmt.Sprintf("app_%s", appName)), config)

if err != nil {
log.Fatal("Setup failure: ", err)
Expand Down Expand Up @@ -79,7 +79,9 @@ func main() {
log.Fatal("Failed to create a new client: ", err)
}

log.Printf("Serving %v\n", addr)
log.Printf("Serving proxy client %v\n", *addr)

log.Fatal(client.ListenAndServe(*addr))
if err := client.ListenAndServe(*addr); err != nil {
log.Fatalf("Error serving proxy client: %v\n", err)
}
}
12 changes: 7 additions & 5 deletions cmd/apps/therealproxy/therealproxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import (
"github.com/SkycoinProject/skycoin/src/util/logging"

"github.com/SkycoinProject/skywire-mainnet/internal/therealproxy"
"github.com/SkycoinProject/skywire-mainnet/pkg/app2"
"github.com/SkycoinProject/skywire-mainnet/pkg/app2/appnet"
"github.com/SkycoinProject/skywire-mainnet/pkg/app"
"github.com/SkycoinProject/skywire-mainnet/pkg/app/appnet"
"github.com/SkycoinProject/skywire-mainnet/pkg/routing"
)

Expand All @@ -22,18 +22,18 @@ const (
)

func main() {
log := app2.NewLogger(appName)
log := app.NewLogger(appName)
therealproxy.Log = log.PackageLogger("therealproxy")

var passcode = flag.String("passcode", "", "Authorize user against this passcode")
flag.Parse()

config, err := app2.ClientConfigFromEnv()
config, err := app.ClientConfigFromEnv()
if err != nil {
log.Fatalf("Error getting client config: %v\n", err)
}

socksApp, err := app2.NewClient(logging.MustGetLogger(fmt.Sprintf("app_%s", appName)), config)
socksApp, err := app.NewClient(logging.MustGetLogger(fmt.Sprintf("app_%s", appName)), config)
if err != nil {
log.Fatal("Setup failure: ", err)
}
Expand All @@ -51,5 +51,7 @@ func main() {
log.Fatalf("Error listening network %v on port %d: %v\n", netType, port, err)
}

log.Infoln("Starting serving proxy server")

log.Fatal(srv.Serve(l))
}
8 changes: 4 additions & 4 deletions cmd/apps/therealssh-client/therealssh-client.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"github.com/SkycoinProject/skycoin/src/util/logging"
"github.com/sirupsen/logrus"

"github.com/SkycoinProject/skywire-mainnet/pkg/app2"
"github.com/SkycoinProject/skywire-mainnet/pkg/app"
ssh "github.com/SkycoinProject/skywire-mainnet/pkg/therealssh"
)

Expand All @@ -24,20 +24,20 @@ const (
var log *logging.MasterLogger

func main() {
log = app2.NewLogger(appName)
log = app.NewLogger(appName)
ssh.Log = log.PackageLogger("therealssh")

// TODO(evanlinjin): Change "rpc" to "addr".
var rpcAddr = flag.String("rpc", skyenv.SkysshClientAddr, "Client RPC address to listen on")
var debug = flag.Bool("debug", false, "enable debug messages")
flag.Parse()

config, err := app2.ClientConfigFromEnv()
config, err := app.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)
sshApp, err := app.NewClient(logging.MustGetLogger(fmt.Sprintf("app_%s", appName)), config)
if err != nil {
log.Fatal("Setup failure: ", err)
}
Expand Down
14 changes: 8 additions & 6 deletions cmd/apps/therealssh/therealssh.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ import (
"flag"
"fmt"

"github.com/SkycoinProject/skywire-mainnet/pkg/app2/appnet"
"github.com/SkycoinProject/skywire-mainnet/pkg/app/appnet"
"github.com/SkycoinProject/skywire-mainnet/pkg/routing"

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

"github.com/SkycoinProject/skywire-mainnet/pkg/app2"
"github.com/SkycoinProject/skywire-mainnet/pkg/app"
ssh "github.com/SkycoinProject/skywire-mainnet/pkg/therealssh"
)

Expand All @@ -27,20 +27,21 @@ const (
)

func main() {
log = app2.NewLogger(appName)
log = app.NewLogger(appName)
ssh.Log = log.PackageLogger("therealssh")

var authFile = flag.String("auth", "~/.therealssh/authorized_keys", "Auth file location. Should contain one PubKey per line.")
// TODO: change back to the tilda-like home path
var authFile = flag.String("auth", "/Users/darkrengarius/.therealssh/authorized_keys", "Auth file location. Should contain one PubKey per line.")
var debug = flag.Bool("debug", false, "enable debug messages")

flag.Parse()

config, err := app2.ClientConfigFromEnv()
config, err := app.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)
sshApp, err := app.NewClient(logging.MustGetLogger(fmt.Sprintf("app_%s", appName)), config)

if err != nil {
log.Fatal("Setup failure: ", err)
Expand All @@ -51,6 +52,7 @@ func main() {

path, err := homedir.Expand(*authFile)
if err != nil {
log.Errorf("Error expanding auth file path %s: %v\n", *authFile, err)
log.Fatal("Failed to resolve auth file path: ", err)
}

Expand Down
File renamed without changes.
7 changes: 7 additions & 0 deletions cmd/dmsg-server/dmsg-server.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package main

import "github.com/SkycoinProject/skywire-mainnet/cmd/dmsg-server/commands"

func main() {
commands.Execute()
}
7 changes: 0 additions & 7 deletions cmd/messaging-server/messaging-server.go

This file was deleted.

11 changes: 6 additions & 5 deletions cmd/skywire-cli/commands/node/routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func init() {
}

var addRuleCmd = &cobra.Command{
Use: "add-rule (app <route-id> <remote-pk> <remote-port> <local-port> | fwd <next-route-id> <next-transport-id>)",
Use: "add-rule (app <route-id> <local-pk> <local-port> <remote-pk> <remote-port> | fwd <next-route-id> <next-transport-id>)",
Short: "Adds a new routing rule",
Args: func(_ *cobra.Command, args []string) error {
if len(args) > 0 {
Expand All @@ -95,11 +95,12 @@ var addRuleCmd = &cobra.Command{
case "app":
var (
routeID = routing.RouteID(parseUint("route-id", args[1], 32))
remotePK = internal.ParsePK("remote-pk", args[2])
remotePort = routing.Port(parseUint("remote-port", args[3], 16))
localPort = routing.Port(parseUint("local-port", args[4], 16))
localPK = internal.ParsePK("local-pk", args[2])
localPort = routing.Port(parseUint("local-port", args[3], 16))
remotePK = internal.ParsePK("remote-pk", args[4])
remotePort = routing.Port(parseUint("remote-port", args[5], 16))
)
rule = routing.ConsumeRule(keepAlive, routeID, remotePK, localPort, remotePort)
rule = routing.ConsumeRule(keepAlive, routeID, localPK, remotePK, localPort, remotePort)
case "fwd":
var (
nextRouteID = routing.RouteID(parseUint("next-route-id", args[1], 32))
Expand Down
7 changes: 4 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,14 @@ go 1.13
require (
github.com/SkycoinProject/dmsg v0.0.0-20191106075825-cabc26522b11
github.com/SkycoinProject/skycoin v0.26.0
github.com/SkycoinProject/yamux v0.0.0-20191213015001-a36efeefbf6a
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5
github.com/creack/pty v1.1.9
github.com/go-chi/chi v4.0.2+incompatible
github.com/google/uuid v1.1.1
github.com/gorilla/handlers v1.4.2
github.com/gorilla/securecookie v1.1.1
github.com/hashicorp/yamux v0.0.0-20190923154419-df201c70410d
github.com/mitchellh/go-homedir v1.1.0
github.com/pkg/errors v0.8.1
github.com/pkg/profile v1.3.0
github.com/prometheus/client_golang v1.2.1
github.com/prometheus/common v0.7.0
Expand All @@ -22,5 +21,7 @@ require (
github.com/stretchr/testify v1.4.0
go.etcd.io/bbolt v1.3.3
golang.org/x/crypto v0.0.0-20191106202628-ed6320f186d4
golang.org/x/net v0.0.0-20191105084925-a882066a44e0
golang.org/x/net v0.0.0-20191204025024-5ee1b9f4859a
)

// replace github.com/SkycoinProject/dmsg => ../dmsg
Loading

0 comments on commit 3c218ed

Please sign in to comment.