Skip to content

Commit

Permalink
Merge pull request #77 from jdknives/feature/default_stcp_listen
Browse files Browse the repository at this point in the history
Feature/default stcp listen
  • Loading branch information
jdknives authored Nov 29, 2019
2 parents ed12183 + 841a479 commit 5228294
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 206 deletions.
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 {
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

0 comments on commit 5228294

Please sign in to comment.