Skip to content

Commit

Permalink
Merge pull request #1038 from mrpalide/fixbug/delBindSTCPR
Browse files Browse the repository at this point in the history
Check IP before call delBindSTCPR
  • Loading branch information
jdknives authored Dec 30, 2021
2 parents 48ae271 + f8c71b7 commit 9e9f849
Show file tree
Hide file tree
Showing 98 changed files with 11,825 additions and 4 deletions.
3 changes: 3 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,13 @@ require (
github.com/google/go-querystring v1.0.0 // indirect
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 // indirect
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/jaypipes/pcidb v0.6.0 // indirect
github.com/klauspost/compress v1.11.0 // indirect
github.com/klauspost/cpuid v1.2.4 // indirect
github.com/klauspost/pgzip v1.2.1 // indirect
github.com/mattn/go-isatty v0.0.14 // indirect
github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/nwaples/rardecode v1.0.0 // indirect
Expand All @@ -102,6 +104,7 @@ require (
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
howett.net/plist v0.0.0-20181124034731-591f970eefbb // indirect
)

// Uncomment for tests with alternate branches of 'dmsg'
Expand Down
3 changes: 3 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@ github.com/james-barrow/golang-ipc v0.0.0-20210227130457-95e7cc81f5e2 h1:lnIIG50
github.com/james-barrow/golang-ipc v0.0.0-20210227130457-95e7cc81f5e2/go.mod h1:M3eGiVVY7bdtqyWT+gtbIqji7CqHi3PKJHSPl2pP40c=
github.com/jaypipes/ghw v0.8.0 h1:02q1pTm9CD83vuhBsEZZhOCS128pq87uyaQeJZkp3sQ=
github.com/jaypipes/ghw v0.8.0/go.mod h1:+gR9bjm3W/HnFi90liF+Fj9GpCe/Dsibl9Im8KmC7c4=
github.com/jaypipes/pcidb v0.6.0 h1:VIM7GKVaW4qba30cvB67xSCgJPTzkG8Kzw/cbs5PHWU=
github.com/jaypipes/pcidb v0.6.0/go.mod h1:L2RGk04sfRhp5wvHO0gfRAMoLY/F3PKv/nwJeVoho0o=
github.com/jellevandenhooff/dkim v0.0.0-20150330215556-f50fe3d243e1/go.mod h1:E0B/fFc00Y+Rasa88328GlI/XbtyysCtTHZS8h7IrBU=
github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI=
Expand Down Expand Up @@ -341,6 +342,7 @@ github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceT
github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db h1:62I3jR2EmQ4l5rM/4FEfDWcRD+abF5XlKShorW5LRoQ=
github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db/go.mod h1:l0dey0ia/Uv7NcFFVbCLtqEBQbrT4OCwCSKTEv6enCw=
github.com/mitchellh/go-homedir v1.0.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y=
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
github.com/mitchellh/go-testing-interface v1.0.0/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI=
github.com/mitchellh/gox v0.4.0/go.mod h1:Sd9lOJ0+aimLBi73mGofS1ycjY8lL3uZM3JPS42BGNg=
Expand Down Expand Up @@ -945,6 +947,7 @@ honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWh
honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
howett.net/plist v0.0.0-20181124034731-591f970eefbb h1:jhnBjNi9UFpfpl8YZhA9CrOqpnJdvzuiHsl/dnxl11M=
howett.net/plist v0.0.0-20181124034731-591f970eefbb/go.mod h1:vMygbs4qMhSZSc4lCUl2OEE+rDiIIJAIdR4m7MiMcm0=
nhooyr.io/websocket v1.8.2 h1:LwdzfyyOZKtVFoXay6A39Acu03KmidSZ3YUUvPa13PA=
nhooyr.io/websocket v1.8.2/go.mod h1:LiqdCg1Cu7TPWxEvPjPa0TGYxCsy4pHNTN9gGluwBpQ=
Expand Down
12 changes: 9 additions & 3 deletions pkg/transport/network/addrresolver/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"github.com/skycoin/skywire/internal/httpauth"
"github.com/skycoin/skywire/internal/netutil"
"github.com/skycoin/skywire/internal/packetfilter"
pkgnetutil "github.com/skycoin/skywire/pkg/util/netutil"
)

const (
Expand Down Expand Up @@ -196,7 +197,6 @@ func (c *httpClient) Delete(ctx context.Context, path string) (*http.Response, e
if err != nil {
return nil, err
}

return c.httpClient.Do(req.WithContext(ctx))
}

Expand Down Expand Up @@ -511,8 +511,14 @@ func (c *httpClient) Close() error {
}
}

if err := c.delBindSTCPR(context.Background()); err != nil {
c.log.WithError(err).Errorf("Failed to delete STCPR binding")
hasPublic, err := pkgnetutil.HasPublicIP()
if err != nil {
c.log.Errorf("Failed to check for public IP: %v", err)
}
if hasPublic {
if err := c.delBindSTCPR(context.Background()); err != nil {
c.log.WithError(err).Errorf("Failed to delete STCPR binding")
}
}

return nil
Expand Down
15 changes: 14 additions & 1 deletion pkg/visor/visor.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ import (
"sync"
"time"

"github.com/jaypipes/ghw"
"github.com/jaypipes/ghw/pkg/baseboard"
"github.com/jaypipes/ghw/pkg/product"
"github.com/skycoin/dmsg"
"github.com/skycoin/dmsg/cipher"
dmsgdisc "github.com/skycoin/dmsg/disc"
Expand Down Expand Up @@ -258,19 +260,30 @@ func (v *Visor) HostKeeper(skybianBuildVersion string) {
}
serialNumber = string(serialNumberByte)
} else {
baseboardInfo, err := baseboard.New()
baseboardInfo, err := baseboard.New(ghw.WithDisableWarnings())
if err != nil {
logger.Errorf("Error during get information of host due to %v", err)
return
}
model = baseboardInfo.Vendor
serialNumber = baseboardInfo.SerialNumber
if model == "unknown" || serialNumber == "unknown" {
productInfo, err := product.New(ghw.WithDisableWarnings())
if err != nil {
logger.Errorf("Error during get information of host due to %v", err)
return
}
model = productInfo.Vendor
serialNumber = productInfo.UUID
}
}

var keeperInfo HostKeeperData
keeperInfo.Model = model
keeperInfo.SerialNumber = serialNumber

logger.WithField("Info", keeperInfo).Info("Host information achieved.")

client, err := httpauth.NewClient(context.Background(), v.conf.HostKeeper, v.conf.PK, v.conf.SK, &http.Client{}, v.MasterLogger())
if err != nil {
logger.Errorf("Host Keeper httpauth: %v", err)
Expand Down
3 changes: 3 additions & 0 deletions vendor/github.com/jaypipes/ghw/.get-go-packages.sh

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions vendor/github.com/jaypipes/ghw/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 25 additions & 0 deletions vendor/github.com/jaypipes/ghw/.travis.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 26 additions & 0 deletions vendor/github.com/jaypipes/ghw/Dockerfile

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

39 changes: 39 additions & 0 deletions vendor/github.com/jaypipes/ghw/Makefile

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 9e9f849

Please sign in to comment.