Skip to content

Commit

Permalink
Merge branch 'mainnet-milestone2' of https://github.com/skycoin/skywire
Browse files Browse the repository at this point in the history
… into feature/app2
  • Loading branch information
Darkren committed Sep 18, 2019
2 parents 7ef6861 + 6439c70 commit 946a3dc
Show file tree
Hide file tree
Showing 186 changed files with 19,907 additions and 3,024 deletions.
7 changes: 6 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,10 @@ install:
- go get -u github.com/FiloSottile/vendorcheck
- curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $GOPATH/bin v1.17.1

before_script:
- ci_scripts/create-ip-aliases.sh

script:
- make check
- make lint
- make test
- make test-no-ci
7 changes: 6 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ DOCKER_NETWORK?=SKYNET
DOCKER_NODE?=SKY01
DOCKER_OPTS?=GO111MODULE=on GOOS=linux # go options for compiling for docker container
TEST_OPTS?=-race -tags no_ci -cover -timeout=5m
TEST_OPTS_NOCI?=-race -cover -timeout=5m -v
BUILD_OPTS?=-race

check: lint test ## Run linters and tests
Expand Down Expand Up @@ -45,7 +46,7 @@ rerun: stop
lint: ## Run linters. Use make install-linters first
${OPTS} golangci-lint run -c .golangci.yml ./...
# The govet version in golangci-lint is out of date and has spurious warnings, run it separately
${OPTS} go vet -mod=vendor -all ./...
${OPTS} go vet -all ./...

vendorcheck: ## Run vendorcheck
GO111MODULE=off vendorcheck ./internal/...
Expand All @@ -64,6 +65,10 @@ test: ## Run tests
${OPTS} go test ${TEST_OPTS} ./internal/...
${OPTS} go test ${TEST_OPTS} ./pkg/...

test-no-ci: ## Run no_ci tests
-go clean -testcache
${OPTS} go test ${TEST_OPTS_NOCI} ./pkg/transport/... -run "TCP|PubKeyTable"

install-linters: ## Install linters
- VERSION=1.17.1 ./ci_scripts/install-golangci-lint.sh
# GO111MODULE=off go get -u github.com/FiloSottile/vendorcheck
Expand Down
13 changes: 13 additions & 0 deletions ci_scripts/create-ip-aliases.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env bash

if [[ "$OSTYPE" == "linux-gnu" ]]; then
for ((i=1; i<=255; i++))
do
sudo ip addr add 12.12.12.$i/32 dev lo
done
elif [[ "$OSTYPE" == "darwin" ]]; then
for ((i=1; i<=255; i++))
do
sudo ip addr add 12.12.12.$i/32 dev lo0
done
fi
7 changes: 5 additions & 2 deletions cmd/apps/skychat/chat.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ import (
"encoding/json"
"flag"
"fmt"
"log"
"net"
"net/http"
"sync"
"time"

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

"github.com/skycoin/skywire/internal/netutil"
"github.com/skycoin/skywire/pkg/app"
Expand All @@ -30,12 +30,15 @@ var (
clientCh chan string
chatConns map[cipher.PubKey]net.Conn
connsMu sync.Mutex
log *logging.MasterLogger
)

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

a, err := app.Setup(&app.Config{AppName: "skychat", AppVersion: "1.0", ProtocolVersion: "0.0.1"})
a, err := app.Setup(&app.Config{AppName: appName, AppVersion: "1.0", ProtocolVersion: "0.0.1"})
if err != nil {
log.Fatal("Setup failure: ", err)
}
Expand Down
4 changes: 3 additions & 1 deletion cmd/apps/therealproxy-client/therealproxy-client.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ package main

import (
"flag"
"log"
"net"
"time"

Expand All @@ -22,6 +21,9 @@ const socksPort = 3
var r = netutil.NewRetrier(time.Second, 0, 1)

func main() {
log := app.NewLogger("socksproxy-client")
therealproxy.Log = log.PackageLogger("therealproxy")

var addr = flag.String("addr", ":1080", "Client address to listen on")
var serverPK = flag.String("srv", "", "PubKey of the server to connect to")
flag.Parse()
Expand Down
6 changes: 4 additions & 2 deletions cmd/apps/therealproxy/therealproxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@ package main

import (
"flag"
"log"

"github.com/skycoin/skywire/internal/therealproxy"
"github.com/skycoin/skywire/pkg/app"
)

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

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

Expand All @@ -26,7 +28,7 @@ func main() {
}
}()

srv, err := therealproxy.NewServer(*passcode)
srv, err := therealproxy.NewServer(*passcode, log)
if err != nil {
log.Fatal("Failed to create a new server: ", err)
}
Expand Down
6 changes: 5 additions & 1 deletion cmd/apps/therealssh-client/therealssh-client.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ package main

import (
"flag"
"log"
"net/http"

"github.com/sirupsen/logrus"
Expand All @@ -15,7 +14,12 @@ import (
ssh "github.com/skycoin/skywire/pkg/therealssh"
)

var log *logging.MasterLogger

func main() {
log = app.NewLogger("SSH-client")
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()
Expand Down
8 changes: 6 additions & 2 deletions cmd/apps/therealssh/therealssh.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ package main

import (
"flag"
"log"

"github.com/mitchellh/go-homedir"
"github.com/sirupsen/logrus"
Expand All @@ -15,7 +14,12 @@ import (
ssh "github.com/skycoin/skywire/pkg/therealssh"
)

var log *logging.MasterLogger

func main() {
log = app.NewLogger("SSH")
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")

Expand Down Expand Up @@ -47,7 +51,7 @@ func main() {
log.Fatal("Failed to setup Authorizer: ", err)
}

server := ssh.NewServer(auth)
server := ssh.NewServer(auth, log)
defer func() {
if err := server.Close(); err != nil {
log.Println("Failed to close server:", err)
Expand Down
29 changes: 28 additions & 1 deletion cmd/skywire-cli/commands/node/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"strconv"
"strings"
"text/tabwriter"
"time"

"github.com/spf13/cobra"

Expand All @@ -19,6 +20,7 @@ func init() {
startAppCmd,
stopAppCmd,
setAppAutostartCmd,
appLogsSinceCmd,
execCmd,
)
}
Expand Down Expand Up @@ -85,13 +87,38 @@ var setAppAutostartCmd = &cobra.Command{
},
}

var appLogsSinceCmd = &cobra.Command{
Use: "app-logs-since <name> <timestamp>",
Short: "Gets logs from given app since RFC3339Nano-formated timestamp. \"beginning\" is a special timestamp to fetch all the logs",
Args: cobra.MinimumNArgs(2),
Run: func(_ *cobra.Command, args []string) {
var t time.Time

if args[1] == "beginning" {
t = time.Unix(0, 0)
} else {
var err error
strTime := args[1]
t, err = time.Parse(time.RFC3339Nano, strTime)
internal.Catch(err)
}
logs, err := rpcClient().LogsSince(t, args[0])
internal.Catch(err)
if len(logs) > 0 {
fmt.Println(logs)
} else {
fmt.Println("no logs")
}
},
}

var execCmd = &cobra.Command{
Use: "exec <command>",
Short: "Executes the given command",
Args: cobra.MinimumNArgs(1),
Run: func(_ *cobra.Command, args []string) {
out, err := rpcClient().Exec(strings.Join(args, " "))
internal.Catch(err)
fmt.Println(string(out))
fmt.Print(string(out))
},
}
12 changes: 6 additions & 6 deletions cmd/skywire-cli/commands/node/routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,10 @@ var rmRuleCmd = &cobra.Command{
},
}

var expire time.Duration
var keepAlive time.Duration

func init() {
addRuleCmd.PersistentFlags().DurationVar(&expire, "expire", router.RouteTTL, "duration after which routing rule will expire")
addRuleCmd.PersistentFlags().DurationVar(&keepAlive, "keep-alive", router.DefaultRouteKeepAlive, "duration after which routing rule will expire if no activity is present")
}

var addRuleCmd = &cobra.Command{
Expand Down Expand Up @@ -100,13 +100,13 @@ var addRuleCmd = &cobra.Command{
remotePort = routing.Port(parseUint("remote-port", args[3], 16))
localPort = routing.Port(parseUint("local-port", args[4], 16))
)
rule = routing.AppRule(time.Now().Add(expire), routeID, remotePK, remotePort, localPort, 0)
rule = routing.AppRule(keepAlive, 0, routeID, remotePK, localPort, remotePort)
case "fwd":
var (
nextRouteID = routing.RouteID(parseUint("next-route-id", args[1], 32))
nextTpID = internal.ParseUUID("next-transport-id", args[2])
)
rule = routing.ForwardRule(time.Now().Add(expire), nextRouteID, nextTpID, 0)
rule = routing.ForwardRule(keepAlive, nextRouteID, nextTpID, 0)
}
rIDKey, err := rpcClient().AddRoutingRule(rule)
internal.Catch(err)
Expand All @@ -117,12 +117,12 @@ var addRuleCmd = &cobra.Command{
func printRoutingRules(rules ...*visor.RoutingEntry) {
printAppRule := func(w io.Writer, id routing.RouteID, s *routing.RuleSummary) {
_, err := fmt.Fprintf(w, "%d\t%s\t%d\t%d\t%s\t%d\t%s\t%s\t%s\n", id, s.Type, s.AppFields.LocalPort,
s.AppFields.RemotePort, s.AppFields.RemotePK, s.AppFields.RespRID, "-", "-", s.ExpireAt)
s.AppFields.RemotePort, s.AppFields.RemotePK, s.AppFields.RespRID, "-", "-", s.KeepAlive)
internal.Catch(err)
}
printFwdRule := func(w io.Writer, id routing.RouteID, s *routing.RuleSummary) {
_, err := fmt.Fprintf(w, "%d\t%s\t%s\t%s\t%s\t%s\t%d\t%s\t%s\n", id, s.Type, "-",
"-", "-", "-", s.ForwardFields.NextRID, s.ForwardFields.NextTID, s.ExpireAt)
"-", "-", "-", s.ForwardFields.NextRID, s.ForwardFields.NextTID, s.KeepAlive)
internal.Catch(err)
}
w := tabwriter.NewWriter(os.Stdout, 0, 0, 5, ' ', tabwriter.TabIndent)
Expand Down
1 change: 1 addition & 0 deletions cmd/skywire-visor/commands/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ func (cfg *runCfg) readConfig() *runCfg {
if err := json.NewDecoder(rdr).Decode(&cfg.conf); err != nil {
cfg.logger.Fatalf("Failed to decode %s: %s", rdr, err)
}
fmt.Println("TCP Factory conf:", cfg.conf.TCPTransport)
return cfg
}

Expand Down
24 changes: 10 additions & 14 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,22 @@ require (
github.com/creack/pty v1.1.7
github.com/go-chi/chi v4.0.2+incompatible
github.com/google/uuid v1.1.1
github.com/gorilla/handlers v1.4.0
github.com/gorilla/handlers v1.4.2
github.com/gorilla/securecookie v1.1.1
github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d
github.com/kr/pty v1.1.5 // indirect
github.com/mitchellh/go-homedir v1.1.0
github.com/pkg/errors v0.8.0
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.1 // indirect
github.com/pkg/errors v0.8.1
github.com/pkg/profile v1.3.0
github.com/prometheus/client_golang v1.0.0
github.com/prometheus/common v0.4.1
github.com/prometheus/client_golang v1.1.0
github.com/prometheus/common v0.7.0
github.com/sirupsen/logrus v1.4.2
github.com/skycoin/dmsg v0.0.0-20190816104216-d18ee6aa05cb
github.com/skycoin/dmsg v0.0.0-20190805065636-70f4c32a994f
github.com/skycoin/skycoin v0.26.0
github.com/spf13/cobra v0.0.5
github.com/stretchr/testify v1.3.0
github.com/stretchr/testify v1.4.0
go.etcd.io/bbolt v1.3.3
golang.org/x/crypto v0.0.0-20190820162420-60c769a6c586
golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7
golang.org/x/sys v0.0.0-20190825160603-fb81701db80f // indirect
golang.org/x/tools v0.0.0-20190826060629-95c3470cfb70 // indirect
golang.org/x/crypto v0.0.0-20190911031432-227b76d455e7
golang.org/x/net v0.0.0-20190916140828-c8589233b77d
)

// Uncomment for tests with alternate branches of 'dmsg'
replace github.com/skycoin/dmsg => ../dmsg
Loading

0 comments on commit 946a3dc

Please sign in to comment.