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 authored 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
Loading

0 comments on commit d437d10

Please sign in to comment.