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

Feature/default stcp listen #77

Merged
merged 4 commits into from
Nov 29, 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
25 changes: 25 additions & 0 deletions cmd/skywire-cli/commands/node/gen-config.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package node

import (
"errors"
"fmt"
"net"
"path/filepath"
"time"

Expand Down Expand Up @@ -86,6 +88,13 @@ func defaultConfig() *visor.Config {
conf.Node.StaticPubKey = pk
conf.Node.StaticSecKey = sk

lIPaddr, err := getLocalIPAddress()
if err != nil {
log.Warn(err)
}

conf.STCP.LocalAddr = lIPaddr

if testenv {
conf.Messaging.Discovery = skyenv.TestDmsgDiscAddr
} else {
Expand Down Expand Up @@ -186,3 +195,19 @@ func defaultSkyproxyClientConfig() visor.AppConfig {
Port: routing.Port(skyenv.SkyproxyClientPort),
}
}

func getLocalIPAddress() (string, error) {
addrs, err := net.InterfaceAddrs()
if err != nil {
return "", err
}

for _, a := range addrs {
if ipnet, ok := a.(*net.IPNet); ok && !ipnet.IP.IsLoopback() {
if ipnet.IP.To4() != nil {
nkryuchkov marked this conversation as resolved.
Show resolved Hide resolved
return ipnet.IP.String() + ":7777", nil
}
}
}
return "", errors.New("could not find local IP address")
}
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ require (
github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d
github.com/kr/pty v1.1.8 // indirect
github.com/mattn/go-isatty v0.0.9 // indirect
github.com/mitchellh/go-homedir v1.1.0
github.com/pkg/profile v1.3.0
github.com/prometheus/client_golang v1.1.0
github.com/prometheus/common v0.6.0
Expand Down
21 changes: 0 additions & 21 deletions vendor/github.com/mitchellh/go-homedir/LICENSE

This file was deleted.

14 changes: 0 additions & 14 deletions vendor/github.com/mitchellh/go-homedir/README.md

This file was deleted.

1 change: 0 additions & 1 deletion vendor/github.com/mitchellh/go-homedir/go.mod

This file was deleted.

167 changes: 0 additions & 167 deletions vendor/github.com/mitchellh/go-homedir/homedir.go

This file was deleted.

2 changes: 0 additions & 2 deletions vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ github.com/mattn/go-isatty
github.com/matttproud/golang_protobuf_extensions/pbutil
# github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b
github.com/mgutz/ansi
# github.com/mitchellh/go-homedir v1.1.0
github.com/mitchellh/go-homedir
# github.com/pkg/profile v1.3.0
github.com/pkg/profile
# github.com/pmezard/go-difflib v1.0.0
Expand Down