Skip to content

Commit

Permalink
Merge pull request #123
Browse files Browse the repository at this point in the history
Release v0.6.0
  • Loading branch information
bsrinivas8687 committed Mar 3, 2023
2 parents 296d292 + 78f0834 commit d437d10
Show file tree
Hide file tree
Showing 21 changed files with 592 additions and 353 deletions.
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
/.idea/
/.github/
/CODE_OF_CONDUCT.md
/bin/
/build/
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.DS_Store*
/.idea/
/bin/
/vendor/
/build/
/vendor/
5 changes: 2 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.19-alpine3.17 AS build
FROM golang:1.20-alpine3.17 AS build

COPY . /go/src/github.com/sentinel-official/dvpn-node/

Expand All @@ -17,7 +17,6 @@ FROM alpine:3.17
COPY --from=build /go/bin/sentinelnode /usr/local/bin/process
COPY --from=build /root/hnsd/hnsd /usr/local/bin/hnsd

RUN apk add --no-cache ip6tables unbound-dev v2ray wireguard-tools && \
rm -rf /tmp/* /var/tmp/*
RUN apk add --no-cache ip6tables unbound-libs v2ray wireguard-tools

CMD ["process"]
8 changes: 6 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
PACKAGES := $(shell go list ./...)
VERSION := $(shell echo $(shell git describe --tags) | sed 's/^v//')
VERSION := $(shell git describe --tags | sed 's/^v//' | rev | cut -d - -f 2- | rev)
COMMIT := $(shell git log -1 --format='%H')

BUILD_TAGS := $(strip netgo)
Expand All @@ -16,13 +16,17 @@ benchmark:

.PHONY: clean
clean:
rm -rf ./build
rm -rf ./bin ./build ./vendor

.PHONY: install
install:
go build -mod=readonly -tags="${BUILD_TAGS}" -ldflags="${LD_FLAGS}" \
-o ${GOPATH}/bin/sentinelnode main.go

.PHONY: build-image
build-image:
@docker build --compress --file Dockerfile --force-rm --no-cache --tag sentinel-dvpn-node .

.PHONY: go-lint
go-lint:
@golangci-lint run --fix
Expand Down
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# Sentinel dVPN Node

[![Go](https://img.shields.io/github/go-mod/go-version/sentinel-official/dvpn-node)]()
[![GoReport](https://goreportcard.com/badge/github.com/sentinel-official/dvpn-node)](https://goreportcard.com/report/github.com/sentinel-official/dvpn-node)
[![Licence](https://img.shields.io/github/license/sentinel-official/dvpn-node.svg)](https://github.com/sentinel-official/dvpn-node/blob/master/LICENSE)
[![Tag](https://img.shields.io/github/tag/sentinel-official/dvpn-node.svg)](https://github.com/sentinel-official/dvpn-node/releases/latest)
[![GoReportCard](https://goreportcard.com/badge/github.com/sentinel-official/dvpn-node)](https://goreportcard.com/report/github.com/sentinel-official/dvpn-node)
[![Licence](https://img.shields.io/github/license/sentinel-official/dvpn-node.svg)](https://github.com/sentinel-official/dvpn-node/blob/development/LICENSE)
[![LoC](https://tokei.rs/b1/github/sentinel-official/dvpn-node)](https://github.com/sentinel-official/dvpn-node)
[![TotalLines](https://img.shields.io/tokei/lines/github/sentinel-official/dvpn-node)]()

For documentation click [here](https://docs.sentinel.co/dVPN-node/setup "here")
29 changes: 9 additions & 20 deletions cmd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,11 @@ import (

"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/crypto/keyring"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
"github.com/gin-contrib/cors"
"github.com/gin-gonic/gin"
"github.com/go-kit/kit/transport/http/jsonrpc"
"github.com/spf13/cobra"
"github.com/spf13/viper"
rpchttp "github.com/tendermint/tendermint/rpc/client/http"
"gorm.io/driver/sqlite"
"gorm.io/gorm"
"gorm.io/gorm/logger"
Expand Down Expand Up @@ -100,18 +98,12 @@ func StartCmd() *cobra.Command {
}

var (
encoding = types.MakeEncodingConfig()
reader = bufio.NewReader(cmd.InOrStdin())
input = bufio.NewReader(cmd.InOrStdin())
remotes = strings.Split(config.Chain.RPCAddresses, ",")
)

log.Info("Initializing the RPC client", "address", config.Chain.RPCAddress, "endpoint", "/websocket")
rpcClient, err := rpchttp.New(config.Chain.RPCAddress, "/websocket")
if err != nil {
return err
}

log.Info("Initializing the keyring", "name", types.KeyringName, "backend", config.Keyring.Backend)
kr, err := keyring.New(types.KeyringName, config.Keyring.Backend, home, reader)
kr, err := keyring.New(types.KeyringName, config.Keyring.Backend, home, input)
if err != nil {
return err
}
Expand All @@ -122,24 +114,21 @@ func StartCmd() *cobra.Command {
}

client := lite.NewDefaultClient().
WithAccountRetriever(authtypes.AccountRetriever{}).
WithChainID(config.Chain.ID).
WithClient(rpcClient).
WithFrom(config.Keyring.From).
WithFromAddress(info.GetAddress()).
WithFromName(config.Keyring.From).
WithGas(config.Chain.Gas).
WithGasAdjustment(config.Chain.GasAdjustment).
WithGasPrices(config.Chain.GasPrices).
WithInterfaceRegistry(encoding.InterfaceRegistry).
WithKeyring(kr).
WithLegacyAmino(encoding.Amino).
WithLogger(log).
WithNodeURI(config.Chain.RPCAddress).
WithQueryTimeout(config.Chain.RPCQueryTimeout).
WithRemotes(remotes).
WithSignModeStr("").
WithSimulateAndExecute(config.Chain.SimulateAndExecute).
WithTxConfig(encoding.TxConfig)
WithTxTimeout(config.Chain.RPCTxTimeout)

account, err := client.QueryAccount(info.GetAddress())
account, err := client.QueryAccount(client.FromAddress())
if err != nil {
return err
}
Expand All @@ -166,7 +155,7 @@ func StartCmd() *cobra.Command {
for {
log.Info("Starting the Handshake process...")
if err := runHandshake(config.Handshake.Peers); err != nil {
log.Error("Handshake process exited unexpectedly", "error", err)
log.Error("handshake process exited unexpectedly", "error", err)
}
}
}()
Expand Down
10 changes: 5 additions & 5 deletions context/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ import (
)

type Context struct {
logger tmlog.Logger
service types.Service
handler http.Handler
bandwidth *hubtypes.Bandwidth
client *lite.Client
config *types.Config
database *gorm.DB
handler http.Handler
location *types.GeoIPLocation
logger tmlog.Logger
service types.Service
}

func NewContext() *Context {
Expand All @@ -32,16 +32,17 @@ func NewContext() *Context {
func (c *Context) WithBandwidth(v *hubtypes.Bandwidth) *Context { c.bandwidth = v; return c }
func (c *Context) WithClient(v *lite.Client) *Context { c.client = v; return c }
func (c *Context) WithConfig(v *types.Config) *Context { c.config = v; return c }
func (c *Context) WithDatabase(v *gorm.DB) *Context { c.database = v; return c }
func (c *Context) WithHandler(v http.Handler) *Context { c.handler = v; return c }
func (c *Context) WithLocation(v *types.GeoIPLocation) *Context { c.location = v; return c }
func (c *Context) WithLogger(v tmlog.Logger) *Context { c.logger = v; return c }
func (c *Context) WithService(v types.Service) *Context { c.service = v; return c }
func (c *Context) WithDatabase(v *gorm.DB) *Context { c.database = v; return c }

func (c *Context) Address() hubtypes.NodeAddress { return c.Operator().Bytes() }
func (c *Context) Bandwidth() *hubtypes.Bandwidth { return c.bandwidth }
func (c *Context) Client() *lite.Client { return c.client }
func (c *Context) Config() *types.Config { return c.config }
func (c *Context) Database() *gorm.DB { return c.database }
func (c *Context) Handler() http.Handler { return c.handler }
func (c *Context) IntervalSetSessions() time.Duration { return c.Config().Node.IntervalSetSessions }
func (c *Context) IntervalUpdateStatus() time.Duration { return c.Config().Node.IntervalUpdateStatus }
Expand All @@ -52,7 +53,6 @@ func (c *Context) Moniker() string { return c.Config().Node.
func (c *Context) Operator() sdk.AccAddress { return c.client.FromAddress() }
func (c *Context) RemoteURL() string { return c.Config().Node.RemoteURL }
func (c *Context) Service() types.Service { return c.service }
func (c *Context) Database() *gorm.DB { return c.database }

func (c *Context) IntervalUpdateSessions() time.Duration {
return c.Config().Node.IntervalUpdateSessions
Expand Down
8 changes: 4 additions & 4 deletions context/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ func (c *Context) RemovePeer(key string) error {

data, err := base64.StdEncoding.DecodeString(key)
if err != nil {
c.Log().Error("Failed to decode the key", "error", err, "key", key)
c.Log().Error("failed to decode the key", "error", err, "key", key)
return err
}

if err = c.Service().RemovePeer(data); err != nil {
c.Log().Error("Failed to remove the peer from service", "error", err, "data", data)
c.Log().Error("failed to remove the peer from service", "error", err, "data", data)
return err
}

Expand All @@ -24,7 +24,7 @@ func (c *Context) RemovePeer(key string) error {
func (c *Context) HasPeer(key string) (bool, error) {
data, err := base64.StdEncoding.DecodeString(key)
if err != nil {
c.Log().Error("Failed to decode the key", "error", err, "key", key)
c.Log().Error("failed to decode the key", "error", err, "key", key)
return false, err
}

Expand All @@ -37,7 +37,7 @@ func (c *Context) RemovePeerIfExists(key string) error {
return err
}
if !ok {
c.Log().Info("Peer does not exist", "key", key)
c.Log().Debug("Peer does not exist", "key", key)
return nil
}

Expand Down
8 changes: 4 additions & 4 deletions context/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func (c *Context) RegisterNode() error {
),
)
if err != nil {
c.Log().Error("Failed to register the node", "error", err)
c.Log().Error("failed to register the node", "error", err)
return err
}

Expand All @@ -40,7 +40,7 @@ func (c *Context) UpdateNodeInfo() error {
),
)
if err != nil {
c.Log().Error("Failed to update the node info", "error", err)
c.Log().Error("failed to update the node info", "error", err)
return err
}

Expand All @@ -57,7 +57,7 @@ func (c *Context) UpdateNodeStatus() error {
),
)
if err != nil {
c.Log().Error("Failed to update the node status", "error", err)
c.Log().Error("failed to update the node status", "error", err)
return err
}

Expand Down Expand Up @@ -86,7 +86,7 @@ func (c *Context) UpdateSessions(items ...types.Session) error {
messages...,
)
if err != nil {
c.Log().Error("Failed to update the sessions", "error", err)
c.Log().Error("failed to update the sessions", "error", err)
return err
}

Expand Down
44 changes: 24 additions & 20 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,27 @@ module github.com/sentinel-official/dvpn-node
go 1.20

require (
github.com/avast/retry-go v3.0.0+incompatible
github.com/avast/retry-go/v4 v4.3.3
github.com/cosmos/cosmos-sdk v0.45.11
github.com/cosmos/go-bip39 v1.0.0
github.com/cosmos/ibc-go/v3 v3.4.0
github.com/gin-contrib/cors v1.4.0
github.com/gin-gonic/gin v1.8.1
github.com/gin-gonic/gin v1.9.0
github.com/go-kit/kit v0.12.0
github.com/pkg/errors v0.9.1
github.com/rs/zerolog v1.28.0
github.com/rs/zerolog v1.29.0
github.com/sentinel-official/hub v0.10.1
github.com/showwin/speedtest-go v1.3.0
github.com/showwin/speedtest-go v1.5.0
github.com/soheilhy/cmux v0.1.5
github.com/spf13/cobra v1.6.1
github.com/spf13/viper v1.14.0
github.com/tendermint/tendermint v0.34.23
github.com/v2fly/v2ray-core/v5 v5.1.0
golang.org/x/crypto v0.1.0
golang.org/x/crypto v0.5.0
google.golang.org/grpc v1.50.1
google.golang.org/protobuf v1.28.2-0.20220831092852-f930b1dc76e8
gorm.io/driver/sqlite v1.4.3
gorm.io/gorm v1.24.2
gorm.io/driver/sqlite v1.4.4
gorm.io/gorm v1.24.5
)

require (
Expand All @@ -37,8 +37,10 @@ require (
github.com/beorn7/perks v1.0.1 // indirect
github.com/bgentry/speakeasy v0.1.0 // indirect
github.com/btcsuite/btcd v0.22.1 // indirect
github.com/bytedance/sonic v1.8.0 // indirect
github.com/cespare/xxhash v1.1.0 // indirect
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 // indirect
github.com/coinbase/rosetta-sdk-go v0.7.0 // indirect
github.com/confio/ics23/go v0.7.0 // indirect
github.com/cosmos/btcutil v1.0.4 // indirect
Expand All @@ -61,10 +63,10 @@ require (
github.com/gin-contrib/sse v0.1.0 // indirect
github.com/go-kit/log v0.2.1 // indirect
github.com/go-logfmt/logfmt v0.5.1 // indirect
github.com/go-playground/locales v0.14.0 // indirect
github.com/go-playground/universal-translator v0.18.0 // indirect
github.com/go-playground/validator/v10 v10.11.0 // indirect
github.com/goccy/go-json v0.9.7 // indirect
github.com/go-playground/locales v0.14.1 // indirect
github.com/go-playground/universal-translator v0.18.1 // indirect
github.com/go-playground/validator/v10 v10.11.2 // indirect
github.com/goccy/go-json v0.10.0 // indirect
github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 // indirect
github.com/gogo/gateway v1.1.0 // indirect
github.com/gogo/protobuf v1.3.3 // indirect
Expand Down Expand Up @@ -92,12 +94,13 @@ require (
github.com/jmhodges/levigo v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/compress v1.15.11 // indirect
github.com/klauspost/cpuid/v2 v2.0.9 // indirect
github.com/leodido/go-urn v1.2.1 // indirect
github.com/lib/pq v1.10.6 // indirect
github.com/libp2p/go-buffer-pool v0.1.0 // indirect
github.com/magiconair/properties v1.8.6 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.16 // indirect
github.com/mattn/go-isatty v0.0.17 // indirect
github.com/mattn/go-sqlite3 v1.14.15 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 // indirect
github.com/mimoo/StrobeGo v0.0.0-20210601165009-122bf33a46e0 // indirect
Expand All @@ -106,9 +109,9 @@ require (
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/mtibben/percent v0.2.1 // indirect
github.com/onsi/gomega v1.13.0 // indirect
github.com/onsi/gomega v1.27.0 // indirect
github.com/pelletier/go-toml v1.9.5 // indirect
github.com/pelletier/go-toml/v2 v2.0.5 // indirect
github.com/pelletier/go-toml/v2 v2.0.6 // indirect
github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5 // indirect
github.com/pires/go-proxyproto v0.6.2 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
Expand All @@ -134,16 +137,17 @@ require (
github.com/tendermint/crypto v0.0.0-20191022145703-50d29ede1e15 // indirect
github.com/tendermint/go-amino v0.16.0 // indirect
github.com/tendermint/tm-db v0.6.7 // indirect
github.com/ugorji/go/codec v1.2.7 // indirect
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
github.com/ugorji/go/codec v1.2.9 // indirect
github.com/v2fly/ss-bloomring v0.0.0-20210312155135-28617310f63e // indirect
github.com/zondax/hid v0.9.0 // indirect
go.etcd.io/bbolt v1.3.6 // indirect
golang.org/x/arch v0.0.0-20210923205945-b76863e36670 // indirect
golang.org/x/exp v0.0.0-20220722155223-a9213eeb770e // indirect
golang.org/x/net v0.1.0 // indirect
golang.org/x/sync v0.1.0 // indirect
golang.org/x/sys v0.1.0 // indirect
golang.org/x/term v0.1.0 // indirect
golang.org/x/text v0.4.0 // indirect
golang.org/x/net v0.7.0 // indirect
golang.org/x/sys v0.5.0 // indirect
golang.org/x/term v0.5.0 // indirect
golang.org/x/text v0.7.0 // indirect
google.golang.org/genproto v0.0.0-20221024183307-1bc688fe9f3e // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
Expand Down

0 comments on commit d437d10

Please sign in to comment.