Skip to content

Commit

Permalink
Rename /pkg/node to /pkg/visor
Browse files Browse the repository at this point in the history
  • Loading branch information
nkryuchkov committed Jul 10, 2019
1 parent d51b7bf commit 1de6722
Show file tree
Hide file tree
Showing 15 changed files with 51 additions and 51 deletions.
6 changes: 3 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
/skywire/
/local*

pkg/node/apps/
pkg/node/bar/
pkg/node/foo/
pkg/visor/apps/
pkg/visor/bar/
pkg/visor/foo/

/node
/users.db
Expand Down
4 changes: 2 additions & 2 deletions cmd/skywire-cli/commands/node/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"github.com/spf13/cobra"

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

func init() {
Expand All @@ -34,7 +34,7 @@ var lsAppsCmd = &cobra.Command{

for _, state := range states {
status := "stopped"
if state.Status == node.AppStatusRunning {
if state.Status == visor.AppStatusRunning {
status = "running"
}
_, err = fmt.Fprintf(w, "%s\t%s\t%t\t%s\n", state.Name, strconv.Itoa(int(state.Port)), state.AutoStart, status)
Expand Down
20 changes: 10 additions & 10 deletions cmd/skywire-cli/commands/node/gen-config.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import (
"github.com/skycoin/dmsg/cipher"
"github.com/spf13/cobra"

"github.com/skycoin/skywire/pkg/node"
"github.com/skycoin/skywire/pkg/util/pathutil"
"github.com/skycoin/skywire/pkg/visor"
)

func init() {
Expand Down Expand Up @@ -43,7 +43,7 @@ var genConfigCmd = &cobra.Command{
}
},
Run: func(_ *cobra.Command, _ []string) {
var conf *node.Config
var conf *visor.Config
switch configLocType {
case pathutil.WorkingDirLoc:
conf = defaultConfig()
Expand All @@ -58,24 +58,24 @@ var genConfigCmd = &cobra.Command{
},
}

func homeConfig() *node.Config {
func homeConfig() *visor.Config {
c := defaultConfig()
c.AppsPath = filepath.Join(pathutil.HomeDir(), ".skycoin/skywire/apps")
c.Transport.LogStore.Location = filepath.Join(pathutil.HomeDir(), ".skycoin/skywire/transport_logs")
c.Routing.Table.Location = filepath.Join(pathutil.HomeDir(), ".skycoin/skywire/routing.db")
return c
}

func localConfig() *node.Config {
func localConfig() *visor.Config {
c := defaultConfig()
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
}

func defaultConfig() *node.Config {
conf := &node.Config{}
func defaultConfig() *visor.Config {
conf := &visor.Config{}
conf.Version = "1.0"

pk, sk := cipher.GenerateKeyPair()
Expand All @@ -86,7 +86,7 @@ func defaultConfig() *node.Config {
conf.Messaging.ServerCount = 1

passcode := base64.StdEncoding.EncodeToString(cipher.RandByte(8))
conf.Apps = []node.AppConfig{
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}},
Expand All @@ -103,16 +103,16 @@ func defaultConfig() *node.Config {
conf.Routing.SetupNodes = []cipher.PubKey{sPK}
conf.Routing.Table.Type = "boltdb"
conf.Routing.Table.Location = "./skywire/routing.db"
conf.Routing.RouteFinderTimeout = node.Duration(10 * time.Second)
conf.Routing.RouteFinderTimeout = visor.Duration(10 * time.Second)

conf.Hypervisors = []node.HypervisorConfig{}
conf.Hypervisors = []visor.HypervisorConfig{}

conf.AppsPath = "./apps"
conf.LocalPath = "./local"

conf.LogLevel = "info"

conf.ShutdownTimeout = node.Duration(10 * time.Second)
conf.ShutdownTimeout = visor.Duration(10 * time.Second)

conf.Interfaces.RPCAddress = "localhost:3435"

Expand Down
6 changes: 3 additions & 3 deletions cmd/skywire-cli/commands/node/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"github.com/skycoin/skycoin/src/util/logging"
"github.com/spf13/cobra"

"github.com/skycoin/skywire/pkg/node"
"github.com/skycoin/skywire/pkg/visor"
)

var log = logging.MustGetLogger("skywire-cli")
Expand All @@ -23,10 +23,10 @@ var RootCmd = &cobra.Command{
Short: "Contains sub-commands that interact with the local Skywire Networking Node",
}

func rpcClient() node.RPCClient {
func rpcClient() visor.RPCClient {
client, err := rpc.Dial("tcp", rpcAddr)
if err != nil {
log.Fatal("RPC connection failed:", err)
}
return node.NewRPCClient(client, node.RPCPrefix)
return visor.NewRPCClient(client, visor.RPCPrefix)
}
6 changes: 3 additions & 3 deletions cmd/skywire-cli/commands/node/routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ import (
"github.com/spf13/cobra"

"github.com/skycoin/skywire/cmd/skywire-cli/internal"
"github.com/skycoin/skywire/pkg/node"
"github.com/skycoin/skywire/pkg/router"
"github.com/skycoin/skywire/pkg/routing"
"github.com/skycoin/skywire/pkg/visor"
)

func init() {
Expand Down Expand Up @@ -48,7 +48,7 @@ var ruleCmd = &cobra.Command{
rule, err := rpcClient().RoutingRule(routing.RouteID(id))
internal.Catch(err)

printRoutingRules(&node.RoutingEntry{Key: rule.RouteID(), Value: rule})
printRoutingRules(&visor.RoutingEntry{Key: rule.RouteID(), Value: rule})
},
}

Expand Down Expand Up @@ -114,7 +114,7 @@ var addRuleCmd = &cobra.Command{
},
}

func printRoutingRules(rules ...*node.RoutingEntry) {
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)
Expand Down
6 changes: 3 additions & 3 deletions cmd/skywire-cli/commands/node/transports.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"github.com/spf13/cobra"

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

func init() {
Expand Down Expand Up @@ -106,7 +106,7 @@ var rmTpCmd = &cobra.Command{
},
}

func printTransports(tps ...*node.TransportSummary) {
func printTransports(tps ...*visor.TransportSummary) {
sortTransports(tps...)
w := tabwriter.NewWriter(os.Stdout, 0, 0, 5, ' ', tabwriter.TabIndent)
_, err := fmt.Fprintln(w, "type\tid\tremote\tmode")
Expand All @@ -123,7 +123,7 @@ func printTransports(tps ...*node.TransportSummary) {
internal.Catch(w.Flush())
}

func sortTransports(tps ...*node.TransportSummary) {
func sortTransports(tps ...*visor.TransportSummary) {
sort.Slice(tps, func(i, j int) bool {
return tps[i].ID.String() < tps[j].ID.String()
})
Expand Down
14 changes: 7 additions & 7 deletions cmd/skywire-networking-node/commands/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ import (
"github.com/skycoin/skycoin/src/util/logging"
"github.com/spf13/cobra"

"github.com/skycoin/skywire/pkg/node"
"github.com/skycoin/skywire/pkg/util/pathutil"
"github.com/skycoin/skywire/pkg/visor"
)

const configEnv = "SW_CONFIG"
const defaultShutdownTimeout = node.Duration(10 * time.Second)
const defaultShutdownTimeout = visor.Duration(10 * time.Second)

type runCfg struct {
syslogAddr string
Expand All @@ -39,8 +39,8 @@ type runCfg struct {
profileStop func()
logger *logging.Logger
masterLogger *logging.MasterLogger
conf node.Config
node *node.Node
conf visor.Config
node *visor.Node
}

var cfg *runCfg
Expand All @@ -58,7 +58,7 @@ var rootCmd = &cobra.Command{
waitOsSignals().
stopNode()
},
Version: node.Version,
Version: visor.Version,
}

func init() {
Expand Down Expand Up @@ -134,15 +134,15 @@ func (cfg *runCfg) readConfig() *runCfg {
rdr = bufio.NewReader(os.Stdin)
}

cfg.conf = node.Config{}
cfg.conf = visor.Config{}
if err := json.NewDecoder(rdr).Decode(&cfg.conf); err != nil {
cfg.logger.Fatalf("Failed to decode %s: %s", rdr, err)
}
return cfg
}

func (cfg *runCfg) runNode() *runCfg {
node, err := node.NewNode(&cfg.conf, cfg.masterLogger)
node, err := visor.NewNode(&cfg.conf, cfg.masterLogger)
if err != nil {
cfg.logger.Fatal("Failed to initialize node: ", err)
}
Expand Down
24 changes: 12 additions & 12 deletions pkg/hypervisor/hypervisor.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ import (
"github.com/skycoin/skycoin/src/util/logging"

"github.com/skycoin/skywire/pkg/httputil"
"github.com/skycoin/skywire/pkg/node"
"github.com/skycoin/skywire/pkg/routing"
"github.com/skycoin/skywire/pkg/visor"
)

var (
Expand All @@ -31,7 +31,7 @@ var (

type appNodeConn struct {
Addr *noise.Addr
Client node.RPCClient
Client visor.RPCClient
}

// Node manages AppNodes.
Expand Down Expand Up @@ -69,7 +69,7 @@ func (m *Node) ServeRPC(lis net.Listener) error {
m.mu.RLock()
m.nodes[addr.PK] = appNodeConn{
Addr: addr,
Client: node.NewRPCClient(rpc.NewClient(conn), node.RPCPrefix),
Client: visor.NewRPCClient(rpc.NewClient(conn), visor.RPCPrefix),
}
m.mu.RUnlock()
}
Expand All @@ -92,7 +92,7 @@ type MockConfig struct {
func (m *Node) AddMockData(config MockConfig) error {
r := rand.New(rand.NewSource(time.Now().UnixNano()))
for i := 0; i < config.Nodes; i++ {
pk, client := node.NewMockRPCClient(r, config.MaxTpsPerNode, config.MaxRoutesPerNode)
pk, client := visor.NewMockRPCClient(r, config.MaxTpsPerNode, config.MaxRoutesPerNode)
m.mu.Lock()
m.nodes[pk] = appNodeConn{
Addr: &noise.Addr{
Expand Down Expand Up @@ -149,7 +149,7 @@ func (m *Node) ServeHTTP(w http.ResponseWriter, req *http.Request) {

type summaryResp struct {
TCPAddr string `json:"tcp_addr"`
*node.Summary
*visor.Summary
}

// provides summary of all nodes.
Expand All @@ -161,7 +161,7 @@ func (m *Node) getNodes() http.HandlerFunc {
summary, err := c.Client.Summary()
if err != nil {
log.Printf("failed to obtain summary from AppNode with pk %s. Error: %v", pk, err)
summary = &node.Summary{PubKey: pk}
summary = &visor.Summary{PubKey: pk}
}
summaries = append(summaries, summaryResp{
TCPAddr: c.Addr.Addr.String(),
Expand Down Expand Up @@ -428,7 +428,7 @@ type loopResp struct {
FwdRule routing.RuleForwardFields `json:"resp"`
}

func makeLoopResp(info node.LoopInfo) loopResp {
func makeLoopResp(info visor.LoopInfo) loopResp {
if len(info.FwdRule) == 0 || len(info.AppRule) == 0 {
return loopResp{}
}
Expand Down Expand Up @@ -457,7 +457,7 @@ func (m *Node) getLoops() http.HandlerFunc {
<<< Helper functions >>>
*/

func (m *Node) client(pk cipher.PubKey) (*noise.Addr, node.RPCClient, bool) {
func (m *Node) client(pk cipher.PubKey) (*noise.Addr, visor.RPCClient, bool) {
m.mu.RLock()
conn, ok := m.nodes[pk]
m.mu.RUnlock()
Expand All @@ -468,13 +468,13 @@ type httpCtx struct {
// Node
PK cipher.PubKey
Addr *noise.Addr
RPC node.RPCClient
RPC visor.RPCClient

// App
App *node.AppState
App *visor.AppState

// Transport
Tp *node.TransportSummary
Tp *visor.TransportSummary

// Route
RtKey routing.RouteID
Expand Down Expand Up @@ -545,7 +545,7 @@ func (m *Node) tpCtx(w http.ResponseWriter, r *http.Request) (*httpCtx, bool) {
}
tp, err := ctx.RPC.Transport(tid)
if err != nil {
if err.Error() == node.ErrNotFound.Error() {
if err.Error() == visor.ErrNotFound.Error() {
httputil.WriteJSON(w, r, http.StatusNotFound,
fmt.Errorf("transport of ID %s is not found", tid))
return nil, false
Expand Down
2 changes: 1 addition & 1 deletion pkg/node/config.go → pkg/visor/config.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package node
package visor

import (
"encoding/json"
Expand Down
2 changes: 1 addition & 1 deletion pkg/node/config_test.go → pkg/visor/config_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package node
package visor

import (
"encoding/json"
Expand Down
2 changes: 1 addition & 1 deletion pkg/node/rpc.go → pkg/visor/rpc.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package node
package visor

import (
"context"
Expand Down
2 changes: 1 addition & 1 deletion pkg/node/rpc_client.go → pkg/visor/rpc_client.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package node
package visor

import (
"encoding/binary"
Expand Down
2 changes: 1 addition & 1 deletion pkg/node/rpc_test.go → pkg/visor/rpc_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package node
package visor

import (
"context"
Expand Down
4 changes: 2 additions & 2 deletions pkg/node/node.go → pkg/visor/visor.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Package node implements skywire networking node.
package node
// Package visor implements skywire networking node.
package visor

import (
"bufio"
Expand Down
2 changes: 1 addition & 1 deletion pkg/node/node_test.go → pkg/visor/visor_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package node
package visor

import (
"context"
Expand Down

0 comments on commit 1de6722

Please sign in to comment.