Skip to content

Commit

Permalink
Merge branch 'mainnet' of https://github.com/skycoin/skywire into fix…
Browse files Browse the repository at this point in the history
…/data_race_therealssh
  • Loading branch information
Darkren committed Jul 8, 2019
2 parents 2b6e98d + eccff5d commit ced40ef
Show file tree
Hide file tree
Showing 156 changed files with 1,273 additions and 8,198 deletions.
6 changes: 6 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.git
bin
skywire
ci_scripts
apps
integration
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,7 @@ pkg/node/foo/
/*-server
/*.json
/*.sh
/*.log
/*.log

# Ignore backup go.mod after running '/ci_scripts/go_mod_replace.sh'.
go.mod-e
23 changes: 7 additions & 16 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -62,21 +62,7 @@ vendorcheck: ## Run vendorcheck
test: ## Run tests
-go clean -testcache &>/dev/null
${OPTS} go test ${TEST_OPTS} ./internal/...
#${OPTS} go test -race -tags no_ci -cover -timeout=5m ./pkg/...
${OPTS} go test ${TEST_OPTS} ./pkg/app/...
${OPTS} go test ${TEST_OPTS} ./pkg/cipher/...
${OPTS} go test ${TEST_OPTS} ./pkg/dmsg/...
${OPTS} go test ${TEST_OPTS} ./pkg/manager/...
${OPTS} go test ${TEST_OPTS} ./pkg/messaging-discovery/...
${OPTS} go test ${TEST_OPTS} ./pkg/node/...
${OPTS} go test ${TEST_OPTS} ./pkg/route-finder/...
${OPTS} go test ${TEST_OPTS} ./pkg/router/...
${OPTS} go test ${TEST_OPTS} ./pkg/routing/...
${OPTS} go test ${TEST_OPTS} ./pkg/setup/...
${OPTS} go test ${TEST_OPTS} ./pkg/transport/...
${OPTS} go test ${TEST_OPTS} ./pkg/transport-discovery/...
${OPTS} go test -tags no_ci -cover -timeout=5m ./pkg/messaging/...

${OPTS} go test ${TEST_OPTS} ./pkg/...

install-linters: ## Install linters
- VERSION=1.17.1 ./ci_scripts/install-golangci-lint.sh
Expand Down Expand Up @@ -198,6 +184,11 @@ integration-run-proxy: ## Runs the proxy interactive testing environment
integration-run-ssh: ## Runs the ssh interactive testing environment
./integration/run-ssh-env.sh

mod-comm: ## Comments the 'replace' rule in go.mod
./ci_scripts/go_mod_replace.sh comment go.mod

mod-uncomm: ## Uncomments the 'replace' rule in go.mod
./ci_scripts/go_mod_replace.sh uncomment go.mod

help:
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'

34 changes: 34 additions & 0 deletions ci_scripts/go_mod_replace.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/usr/bin/env bash

if [[ $# -ne 2 ]]; then
exit 0
fi

# Inputs.
action=$1
filename=$2

# Line to comment/uncomment in go.mod
line="replace github.com\/skycoin\/dmsg => ..\/dmsg"

function print_usage() {
echo $"Usage: $0 (comment|uncomment) <filename>"
}

case "$action" in
comment)
echo "commenting ${filename}..."
sed -i -e "/$line/s/^\/*/\/\//" ${filename}
;;
uncomment)
echo "uncommenting ${filename}..."
sed -i -e "/$line/s/^\/\/*//" ${filename}
;;
help)
print_usage
;;
*)
print_usage
exit 1
;;
esac
32 changes: 0 additions & 32 deletions ci_scripts/run-pkg-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,38 +22,6 @@ go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m

go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/skycoin/skywire/pkg/manager -run TestNewNode >> ./logs/pkg/TestNewNode.log

go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/skycoin/skywire/pkg/messaging -run TestChannelRead >> ./logs/pkg/TestChannelRead.log
go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/skycoin/skywire/pkg/messaging -run TestChannelWrite >> ./logs/pkg/TestChannelWrite.log
go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/skycoin/skywire/pkg/messaging -run TestChannelClose >> ./logs/pkg/TestChannelClose.log
go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/skycoin/skywire/pkg/messaging -run TestClientConnectInitialServers >> ./logs/pkg/TestClientConnectInitialServers.log
go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/skycoin/skywire/pkg/messaging -run TestClientDial >> ./logs/pkg/TestClientDial.log
go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/skycoin/skywire/pkg/messaging -run TestHandshakeFrame >> ./logs/pkg/TestHandshakeFrame.log
go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/skycoin/skywire/pkg/messaging -run TestHandshake >> ./logs/pkg/TestHandshake.log
go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/skycoin/skywire/pkg/messaging -run TestHandshakeInvalidResponder >> ./logs/pkg/TestHandshakeInvalidResponder.log
go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/skycoin/skywire/pkg/messaging -run TestHandshakeInvalidInitiator >> ./logs/pkg/TestHandshakeInvalidInitiator.log
go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/skycoin/skywire/pkg/messaging -run TestNewConn >> ./logs/pkg/TestNewConn.log
go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/skycoin/skywire/pkg/messaging -run TestNewPool >> ./logs/pkg/TestNewPool.log
go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/skycoin/skywire/pkg/messaging -run TestPool_Range >> ./logs/pkg/TestPool_Range.log
go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/skycoin/skywire/pkg/messaging -run TestPool_All >> ./logs/pkg/TestPool_All.log

go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/skycoin/skywire/pkg/messaging-discovery/client -run TestNewMockGetAvailableServers>> ./logs/pkg/TestNewMockGetAvailableServers.log
go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/skycoin/skywire/pkg/messaging-discovery/client -run TestNewMockEntriesEndpoint>> ./logs/pkg/TestNewMockEntriesEndpoint.log
go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/skycoin/skywire/pkg/messaging-discovery/client -run TestNewMockSetEntriesEndpoint>> ./logs/pkg/TestNewMockSetEntriesEndpoint.log
go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/skycoin/skywire/pkg/messaging-discovery/client -run TestNewMockUpdateEntriesEndpoint>> ./logs/pkg/TestNewMockUpdateEntriesEndpoint.log
go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/skycoin/skywire/pkg/messaging-discovery/client -run TestNewMockUpdateEntrySequence>> ./logs/pkg/TestNewMockUpdateEntrySequence.log
go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/skycoin/skywire/pkg/messaging-discovery/client -run TestNewClientEntryIsValid>> ./logs/pkg/TestNewClientEntryIsValid.log
go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/skycoin/skywire/pkg/messaging-discovery/client -run TestVerifySignature>> ./logs/pkg/TestVerifySignature.log
go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/skycoin/skywire/pkg/messaging-discovery/client -run TestValidateRightEntry>> ./logs/pkg/TestValidateRightEntry.log
go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/skycoin/skywire/pkg/messaging-discovery/client -run TestValidateNonKeysEntry>> ./logs/pkg/TestValidateNonKeysEntry.log
go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/skycoin/skywire/pkg/messaging-discovery/client -run TestValidateNonClientNonServerEntry>> ./logs/pkg/TestValidateNonClientNonServerEntry.log
go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/skycoin/skywire/pkg/messaging-discovery/client -run TestValidateNonSignedEntry>> ./logs/pkg/TestValidateNonSignedEntry.log
go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/skycoin/skywire/pkg/messaging-discovery/client -run TestValidateIteration>> ./logs/pkg/TestValidateIteration.log
go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/skycoin/skywire/pkg/messaging-discovery/client -run TestValidateIterationEmptyClient>> ./logs/pkg/TestValidateIterationEmptyClient.log
go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/skycoin/skywire/pkg/messaging-discovery/client -run TestValidateIterationWrongSequence>> ./logs/pkg/TestValidateIterationWrongSequence.log
go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/skycoin/skywire/pkg/messaging-discovery/client -run TestValidateIterationWrongTime>> ./logs/pkg/TestValidateIterationWrongTime.log
go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/skycoin/skywire/pkg/messaging-discovery/client -run TestCopy>> ./logs/pkg/TestCopy.log


go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/skycoin/skywire/pkg/node -run TestMessagingDiscovery >> ./logs/pkg/TestMessagingDiscovery.log
go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/skycoin/skywire/pkg/node -run TestTransportDiscovery >> ./logs/pkg/TestTransportDiscovery.log
go clean -testcache &> /dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/skycoin/skywire/pkg/node -run TestTransportLogStore >> ./logs/pkg/TestTransportLogStore.log
Expand Down
3 changes: 2 additions & 1 deletion cmd/apps/helloworld/helloworld.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ import (
"log"
"os"

"github.com/skycoin/dmsg/cipher"

"github.com/skycoin/skywire/pkg/app"
"github.com/skycoin/skywire/pkg/cipher"
)

func main() {
Expand Down
7 changes: 4 additions & 3 deletions cmd/apps/skychat/chat.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@ import (
"sync"
"time"

"github.com/skycoin/dmsg/cipher"

"github.com/skycoin/skywire/internal/netutil"
"github.com/skycoin/skywire/pkg/app"
"github.com/skycoin/skywire/pkg/cipher"
)

var addr = flag.String("addr", ":8000", "address to bind")
Expand Down Expand Up @@ -107,10 +108,10 @@ func messageHandler(w http.ResponseWriter, req *http.Request) {

addr := &app.Addr{PubKey: pk, Port: 1}
connsMu.Lock()
conn := chatConns[pk]
conn, ok := chatConns[pk]
connsMu.Unlock()

if conn == nil {
if !ok {
var err error
err = r.Do(func() error {
conn, err = chatApp.Dial(addr)
Expand Down
4 changes: 2 additions & 2 deletions cmd/apps/therealproxy-client/therealproxy-client.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ import (
"net"
"time"

"github.com/skycoin/skywire/internal/netutil"
"github.com/skycoin/dmsg/cipher"

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

const socksPort = 3
Expand Down
9 changes: 4 additions & 5 deletions cmd/messaging-server/commands/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,11 @@ import (

"github.com/prometheus/client_golang/prometheus/promhttp"
logrus_syslog "github.com/sirupsen/logrus/hooks/syslog"
"github.com/skycoin/dmsg"
"github.com/skycoin/dmsg/cipher"
"github.com/skycoin/dmsg/disc"
"github.com/skycoin/skycoin/src/util/logging"
"github.com/spf13/cobra"

"github.com/skycoin/skywire/pkg/cipher"
"github.com/skycoin/skywire/pkg/dmsg"
"github.com/skycoin/skywire/pkg/messaging-discovery/client"
)

var (
Expand Down Expand Up @@ -78,7 +77,7 @@ var rootCmd = &cobra.Command{
}

// Start
srv, err := dmsg.NewServer(conf.PubKey, conf.SecKey, conf.PublicAddress, l, client.NewHTTP(conf.Discovery))
srv, err := dmsg.NewServer(conf.PubKey, conf.SecKey, conf.PublicAddress, l, disc.NewHTTP(conf.Discovery))
if err != nil {
logger.Fatalf("Error creating DMSG server instance: %v", err)
}
Expand Down
8 changes: 4 additions & 4 deletions cmd/skywire-cli/commands/mdisc/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import (
"text/tabwriter"
"time"

"github.com/skycoin/dmsg/disc"
"github.com/spf13/cobra"

"github.com/skycoin/skywire/cmd/skywire-cli/internal"
"github.com/skycoin/skywire/pkg/messaging-discovery/client"
)

var mdAddr string
Expand Down Expand Up @@ -40,7 +40,7 @@ var entryCmd = &cobra.Command{
ctx, cancel := context.WithTimeout(context.Background(), time.Second*10)
defer cancel()
pk := internal.ParsePK("node-public-key", args[0])
entry, err := client.NewHTTP(mdAddr).Entry(ctx, pk)
entry, err := disc.NewHTTP(mdAddr).Entry(ctx, pk)
internal.Catch(err)
fmt.Println(entry)
},
Expand All @@ -52,13 +52,13 @@ var availableServersCmd = &cobra.Command{
Run: func(_ *cobra.Command, _ []string) {
ctx, cancel := context.WithTimeout(context.Background(), time.Second*10)
defer cancel()
entries, err := client.NewHTTP(mdAddr).AvailableServers(ctx)
entries, err := disc.NewHTTP(mdAddr).AvailableServers(ctx)
internal.Catch(err)
printAvailableServers(entries)
},
}

func printAvailableServers(entries []*client.Entry) {
func printAvailableServers(entries []*disc.Entry) {
w := tabwriter.NewWriter(os.Stdout, 0, 0, 5, ' ', tabwriter.TabIndent)
_, err := fmt.Fprintln(w, "version\tregistered\tpublic-key\taddress\tport\tconns")
internal.Catch(err)
Expand Down
2 changes: 1 addition & 1 deletion cmd/skywire-cli/commands/node/gen-config.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import (
"path/filepath"
"time"

"github.com/skycoin/dmsg/cipher"
"github.com/spf13/cobra"

"github.com/skycoin/skywire/pkg/cipher"
"github.com/skycoin/skywire/pkg/node"
"github.com/skycoin/skywire/pkg/util/pathutil"
)
Expand Down
5 changes: 2 additions & 3 deletions cmd/skywire-cli/commands/node/transports.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,11 @@ import (
"text/tabwriter"
"time"

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

"github.com/skycoin/dmsg"
"github.com/skycoin/dmsg/cipher"
"github.com/spf13/cobra"

"github.com/skycoin/skywire/cmd/skywire-cli/internal"
"github.com/skycoin/skywire/pkg/cipher"
"github.com/skycoin/skywire/pkg/node"
)

Expand Down
2 changes: 1 addition & 1 deletion cmd/skywire-cli/commands/rtfind/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import (
"fmt"
"time"

"github.com/skycoin/dmsg/cipher"
"github.com/spf13/cobra"

"github.com/skycoin/skywire/cmd/skywire-cli/internal"
"github.com/skycoin/skywire/pkg/cipher"
"github.com/skycoin/skywire/pkg/route-finder/client"
)

Expand Down
2 changes: 1 addition & 1 deletion cmd/skywire-cli/commands/tpdisc/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ import (
"time"

"github.com/google/uuid"
"github.com/skycoin/dmsg/cipher"
"github.com/spf13/cobra"

"github.com/skycoin/skywire/cmd/skywire-cli/internal"
"github.com/skycoin/skywire/pkg/cipher"
"github.com/skycoin/skywire/pkg/transport"
"github.com/skycoin/skywire/pkg/transport-discovery/client"
)
Expand Down
3 changes: 1 addition & 2 deletions cmd/skywire-cli/internal/internal.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@ import (
"fmt"

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

"github.com/skycoin/skywire/pkg/cipher"
)

var log = logging.MustGetLogger("skywire-cli")
Expand Down
3 changes: 1 addition & 2 deletions cmd/therealssh-cli/commands/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,10 @@ import (
"time"

"github.com/kr/pty"
"github.com/skycoin/dmsg/cipher"
"github.com/spf13/cobra"
"golang.org/x/crypto/ssh/terminal"

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

ssh "github.com/skycoin/skywire/internal/therealssh"
)

Expand Down
38 changes: 38 additions & 0 deletions docker/images/node/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Builder
# ARG builder_base=golang:alpine
ARG base=alpine
FROM golang:alpine as builder

ARG CGO_ENABLED=0
ENV CGO_ENABLED=${CGO_ENABLED} \
GOOS=linux \
GOARCH=amd64 \
GO111MODULE=on

COPY . skywire

WORKDIR skywire

RUN go build -mod=vendor -tags netgo -ldflags="-w -s" \
-o skywire-node cmd/skywire-node/skywire-node.go &&\
go build -mod=vendor -ldflags="-w -s" -o ./apps/skychat.v1.0 ./cmd/apps/skychat &&\
go build -mod=vendor -ldflags="-w -s" -o ./apps/helloworld.v1.0 ./cmd/apps/helloworld &&\
go build -mod=vendor -ldflags="-w -s" -o ./apps/socksproxy.v1.0 ./cmd/apps/therealproxy &&\
go build -mod=vendor -ldflags="-w -s" -o ./apps/socksproxy-client.v1.0 ./cmd/apps/therealproxy-client &&\
go build -mod=vendor -ldflags="-w -s" -o ./apps/SSH.v1.0 ./cmd/apps/therealssh &&\
go build -mod=vendor -ldflags="-w -s" -o ./apps/SSH-client.v1.0 ./cmd/apps/therealssh-client


## Resulting image
FROM ${base} as node-runner

COPY --from=builder /go/skywire/skywire-node skywire-node
COPY --from=builder /go/skywire/apps bin/apps
COPY --from=builder /go/skywire/docker/images/node/update.sh update.sh

RUN ./update.sh

ENTRYPOINT [ "./skywire-node" ]

# default target
FROM node-runner
16 changes: 16 additions & 0 deletions docker/images/node/update.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/sh

if type apt > /dev/null; then
apt-get update && apt-get install -y --no-install-recommends \
ca-certificates \
&& rm -rf /var/lib/apt/lists/*
fi

if type apk > /dev/null; then

apk update
apk upgrade
apk add --no-cache ca-certificates openssl iproute2
update-ca-certificates --fresh
apk add iproute2
fi
Loading

0 comments on commit ced40ef

Please sign in to comment.