Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix production env. #7

Merged
merged 9 commits into from
Oct 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file modified ci_scripts/run-internal-tests.sh
100644 → 100755
Empty file.
Empty file modified ci_scripts/run-pkg-tests.sh
100644 → 100755
Empty file.
9 changes: 5 additions & 4 deletions cmd/apps/skychat/chat.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import (
"sync"
"time"

"github.com/SkycoinProject/skywire-mainnet/internal/skyenv"

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

Expand All @@ -22,7 +24,7 @@ import (
"github.com/SkycoinProject/skywire-mainnet/pkg/routing"
)

var addr = flag.String("addr", ":8000", "address to bind")
var addr = flag.String("addr", skyenv.SkychatAddr, "address to bind")
var r = netutil.NewRetrier(50*time.Millisecond, 5, 2)

var (
Expand All @@ -34,11 +36,10 @@ var (
)

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

a, err := app.Setup(&app.Config{AppName: appName, AppVersion: "1.0", ProtocolVersion: "0.0.1"})
a, err := app.Setup(&app.Config{AppName: skyenv.SkychatName, AppVersion: skyenv.SkychatVersion, ProtocolVersion: skyenv.AppProtocolVersion})
if err != nil {
log.Fatal("Setup failure: ", err)
}
Expand Down
14 changes: 7 additions & 7 deletions cmd/apps/therealproxy-client/therealproxy-client.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import (
"net"
"time"

"github.com/SkycoinProject/skywire-mainnet/internal/skyenv"

"github.com/SkycoinProject/dmsg/cipher"

"github.com/SkycoinProject/skywire-mainnet/internal/netutil"
Expand All @@ -16,19 +18,17 @@ import (
"github.com/SkycoinProject/skywire-mainnet/pkg/routing"
)

const socksPort = 3

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

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

var addr = flag.String("addr", ":1080", "Client address to listen on")
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 := &app.Config{AppName: "socksproxy-client", AppVersion: "1.0", ProtocolVersion: "0.0.1"}
config := &app.Config{AppName: skyenv.SkyproxyClientName, AppVersion: skyenv.SkyproxyClientVersion, ProtocolVersion: skyenv.AppProtocolVersion}
socksApp, err := app.Setup(config)
if err != nil {
log.Fatal("Setup failure: ", err)
Expand All @@ -50,7 +50,7 @@ func main() {

var conn net.Conn
err = r.Do(func() error {
conn, err = socksApp.Dial(routing.Addr{PubKey: pk, Port: routing.Port(socksPort)})
conn, err = socksApp.Dial(routing.Addr{PubKey: pk, Port: routing.Port(skyenv.SkyproxyPort)})
return err
})
if err != nil {
Expand Down
8 changes: 5 additions & 3 deletions cmd/apps/therealproxy/therealproxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,20 @@ package main
import (
"flag"

"github.com/SkycoinProject/skywire-mainnet/internal/skyenv"

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

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

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

config := &app.Config{AppName: "socksproxy", AppVersion: "1.0", ProtocolVersion: "0.0.1"}
config := &app.Config{AppName: skyenv.SkyproxyName, AppVersion: skyenv.SkyproxyVersion, ProtocolVersion: skyenv.AppProtocolVersion}
socksApp, err := app.Setup(config)
if err != nil {
log.Fatal("Setup failure: ", err)
Expand Down
11 changes: 7 additions & 4 deletions cmd/apps/therealssh-client/therealssh-client.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import (
"flag"
"net/http"

"github.com/SkycoinProject/skywire-mainnet/internal/skyenv"

"github.com/SkycoinProject/skycoin/src/util/logging"
"github.com/sirupsen/logrus"

Expand All @@ -17,14 +19,15 @@ import (
var log *logging.MasterLogger

func main() {
log = app.NewLogger("SSH-client")
ssh.Log = log.PackageLogger("therealssh")
log = app.NewLogger(skyenv.SkysshClientName)
ssh.Log = log.PackageLogger(skyenv.SkysshClientName)

var rpcAddr = flag.String("rpc", ":2222", "Client RPC address to listen on")
// 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 := &app.Config{AppName: "SSH-client", AppVersion: "1.0", ProtocolVersion: "0.0.1"}
config := &app.Config{AppName: skyenv.SkysshClientName, AppVersion: skyenv.SkysshClientVersion, ProtocolVersion: skyenv.AppProtocolVersion}
sshApp, err := app.Setup(config)
if err != nil {
log.Fatal("Setup failure: ", err)
Expand Down
8 changes: 5 additions & 3 deletions cmd/apps/therealssh/therealssh.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ package main
import (
"flag"

"github.com/SkycoinProject/skywire-mainnet/internal/skyenv"

"github.com/SkycoinProject/skycoin/src/util/logging"
"github.com/mitchellh/go-homedir"
"github.com/sirupsen/logrus"
Expand All @@ -17,15 +19,15 @@ import (
var log *logging.MasterLogger

func main() {
log = app.NewLogger("SSH")
ssh.Log = log.PackageLogger("therealssh")
log = app.NewLogger(skyenv.SkysshName)
ssh.Log = log.PackageLogger(skyenv.SkysshName)

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"}
config := &app.Config{AppName: skyenv.SkysshName, AppVersion: skyenv.SkysshVersion, ProtocolVersion: skyenv.AppProtocolVersion}
sshApp, err := app.Setup(config)
if err != nil {
log.Fatal("Setup failure: ", err)
Expand Down
4 changes: 3 additions & 1 deletion cmd/skywire-cli/commands/mdisc/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import (
"text/tabwriter"
"time"

"github.com/SkycoinProject/skywire-mainnet/internal/skyenv"

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

Expand All @@ -16,7 +18,7 @@ import (
var mdAddr string

func init() {
RootCmd.PersistentFlags().StringVar(&mdAddr, "addr", "https://messaging.discovery.skywire.skycoin.net", "address of messaging discovery server")
RootCmd.PersistentFlags().StringVar(&mdAddr, "addr", skyenv.DefaultDmsgDiscAddr, "address of messaging discovery server")
}

// RootCmd is the command that contains sub-commands which interacts with messaging services.
Expand Down
85 changes: 70 additions & 15 deletions cmd/skywire-cli/commands/node/gen-config.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package node

import (
"encoding/base64"
"fmt"
"path/filepath"
"time"

"github.com/SkycoinProject/skywire-mainnet/internal/skyenv"
"github.com/SkycoinProject/skywire-mainnet/pkg/routing"

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

Expand Down Expand Up @@ -68,9 +70,9 @@ func homeConfig() *visor.Config {

func localConfig() *visor.Config {
c := defaultConfig()
c.AppsPath = "/usr/local/SkycoinProject/skywire-mainnet/apps"
c.Transport.LogStore.Location = "/usr/local/SkycoinProject/skywire-mainnet/transport_logs"
c.Routing.Table.Location = "/usr/local/SkycoinProject/skywire-mainnet/routing.db"
c.AppsPath = "/usr/local/skycoin/skywire/apps"
c.Transport.LogStore.Location = "/usr/local/skycoin/skywire/transport_logs"
c.Routing.Table.Location = "/usr/local/skycoin/skywire/routing.db"
return c
}

Expand All @@ -82,27 +84,29 @@ func defaultConfig() *visor.Config {
conf.Node.StaticPubKey = pk
conf.Node.StaticSecKey = sk

conf.Messaging.Discovery = "https://messaging.discovery.skywire.skycoin.com"
conf.Messaging.Discovery = skyenv.DefaultDmsgDiscAddr
conf.Messaging.ServerCount = 1

passcode := base64.StdEncoding.EncodeToString(cipher.RandByte(8))
// TODO(evanlinjin): We have disabled skyproxy passcode by default for now - We should make a cli arg for this.
//passcode := base64.StdEncoding.Strict().EncodeToString(cipher.RandByte(8))
conf.Apps = []visor.AppConfig{
{App: "skychat", Version: "1.0", Port: 1, AutoStart: true, Args: []string{}},
{App: "SSH", Version: "1.0", Port: 2, AutoStart: true, Args: []string{}},
{App: "socksproxy", Version: "1.0", Port: 3, AutoStart: true, Args: []string{"-passcode", passcode}},
defaultSkychatConfig(),
defaultSkysshConfig(),
defaultSkyproxyConfig(""),
defaultSkysshClientConfig(),
defaultSkyproxyClientConfig(),
}
conf.TrustedNodes = []cipher.PubKey{}

conf.Transport.Discovery = "https://transport.discovery.skywire.skycoin.com"
conf.Transport.Discovery = skyenv.DefaultTpDiscAddr
conf.Transport.LogStore.Type = "file"
conf.Transport.LogStore.Location = "./skywire/transport_logs"

conf.Routing.RouteFinder = "https://routefinder.skywire.skycoin.com/"
conf.Routing.RouteFinder = skyenv.DefaultRouteFinderAddr

const defaultSetupNodePK = "0324579f003e6b4048bae2def4365e634d8e0e3054a20fc7af49daf2a179658557"
sPK := cipher.PubKey{}
if err := sPK.UnmarshalText([]byte(defaultSetupNodePK)); err != nil {
log.WithError(err).Warnf("Failed to unmarshal default setup node public key %s", defaultSetupNodePK)
var sPK cipher.PubKey
if err := sPK.UnmarshalText([]byte(skyenv.DefaultSetupPK)); err != nil {
log.WithError(err).Warnf("Failed to unmarshal default setup node public key %s", skyenv.DefaultSetupPK)
}
conf.Routing.SetupNodes = []cipher.PubKey{sPK}
conf.Routing.Table.Type = "boltdb"
Expand All @@ -124,3 +128,54 @@ func defaultConfig() *visor.Config {

return conf
}

func defaultSkychatConfig() visor.AppConfig {
return visor.AppConfig{
App: skyenv.SkychatName,
Version: skyenv.SkychatVersion,
AutoStart: true,
Port: routing.Port(skyenv.SkychatPort),
Args: []string{"-addr", skyenv.SkychatAddr},
}
}

func defaultSkysshConfig() visor.AppConfig {
return visor.AppConfig{
App: skyenv.SkysshName,
Version: skyenv.SkysshVersion,
AutoStart: true,
Port: routing.Port(skyenv.SkysshPort),
}
}

func defaultSkyproxyConfig(passcode string) visor.AppConfig {
var args []string
if passcode != "" {
args = []string{"-passcode", passcode}
}
return visor.AppConfig{
App: skyenv.SkyproxyName,
Version: skyenv.SkyproxyVersion,
AutoStart: true,
Port: routing.Port(skyenv.SkyproxyPort),
Args: args,
}
}

func defaultSkysshClientConfig() visor.AppConfig {
return visor.AppConfig{
App: skyenv.SkysshClientName,
Version: skyenv.SkysshVersion,
AutoStart: true,
Port: routing.Port(skyenv.SkysshClientPort),
}
}

func defaultSkyproxyClientConfig() visor.AppConfig {
return visor.AppConfig{
App: skyenv.SkyproxyClientName,
Version: skyenv.SkyproxyClientVersion,
AutoStart: false,
Port: routing.Port(skyenv.SkyproxyClientPort),
}
}
14 changes: 12 additions & 2 deletions cmd/skywire-cli/commands/node/root.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package node

import (
"net"
"net/rpc"
"time"

"github.com/SkycoinProject/skycoin/src/util/logging"
"github.com/spf13/cobra"
Expand All @@ -24,9 +26,17 @@ var RootCmd = &cobra.Command{
}

func rpcClient() visor.RPCClient {
client, err := rpc.Dial("tcp", rpcAddr)
conn, err := net.DialTimeout("tcp", rpcAddr, rpcDialTimeout)
if err != nil {
log.Fatal("RPC connection failed:", err)
}
return visor.NewRPCClient(client, visor.RPCPrefix)
if err := conn.SetDeadline(time.Now().Add(rpcConnDuration)); err != nil {
log.Fatal("RPC connection failed:", err)
}
return visor.NewRPCClient(rpc.NewClient(conn), visor.RPCPrefix)
}

const (
rpcDialTimeout = time.Second * 5
rpcConnDuration = time.Second * 60
)
Original file line number Diff line number Diff line change
@@ -1,37 +1,35 @@
package tpdisc
package node

import (
"context"
"errors"
"fmt"
"os"
"text/tabwriter"
"time"

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

"github.com/SkycoinProject/skywire-mainnet/cmd/skywire-cli/internal"
"github.com/SkycoinProject/skywire-mainnet/pkg/transport"
"github.com/SkycoinProject/skywire-mainnet/pkg/transport-discovery/client"
)

func init() {
RootCmd.AddCommand(discTpCmd)
}

var (
addr string
tpID transportID
tpPK cipher.PubKey
)

func init() {
RootCmd.Flags().StringVar(&addr, "addr", "https://transport.discovery.skywire.skycoin.net", "address of transport discovery")
RootCmd.Flags().Var(&tpID, "id", "if specified, obtains a single transport of given ID")
RootCmd.Flags().Var(&tpPK, "pk", "if specified, obtains transports associated with given public key")
discTpCmd.Flags().Var(&tpID, "id", "if specified, obtains a single transport of given ID")
discTpCmd.Flags().Var(&tpPK, "pk", "if specified, obtains transports associated with given public key")
}

// RootCmd is the command that queries the transport-discovery.
var RootCmd = &cobra.Command{
Use: "tpdisc (--id=<transport-id> | --pk=<edge-public-key>)",
var discTpCmd = &cobra.Command{
Use: "disc-tp (--id=<transport-id> | --pk=<edge-public-key>)",
Short: "Queries the Transport Discovery to find transport(s) of given transport ID or edge public key",
Args: func(_ *cobra.Command, _ []string) error {
var (
Expand All @@ -47,17 +45,13 @@ var RootCmd = &cobra.Command{
return nil
},
Run: func(_ *cobra.Command, _ []string) {
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
pk, sk := cipher.GenerateKeyPair()
c, err := client.NewHTTP(addr, pk, sk)
internal.Catch(err)
if tpPK.Null() {
entry, err := c.GetTransportByID(ctx, uuid.UUID(tpID))

if rc := rpcClient(); tpPK.Null() {
entry, err := rc.DiscoverTransportByID(uuid.UUID(tpID))
internal.Catch(err)
printTransportEntries(entry)
} else {
entries, err := c.GetTransportsByEdge(ctx, pk)
entries, err := rc.DiscoverTransportsByPK(tpPK)
internal.Catch(err)
printTransportEntries(entries...)
}
Expand Down
Loading