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

Merge develop into master #66

Merged
merged 140 commits into from
Apr 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
140 commits
Select commit Hold shift + click to select a range
df1e45d
add /dmsghttp config to config bootstrap
mrpalide Jun 20, 2023
7709699
fix images
mrpalide Jun 30, 2023
b2703ea
fix integration env configs
mrpalide Jun 30, 2023
bfaaae2
update docker-compose
mrpalide Jun 30, 2023
ddd00c2
add monitors to env_test values
mrpalide Jun 30, 2023
04ed26f
remove useless config
mrpalide Jun 30, 2023
daf59cb
update logic of reading config of vpn and public-visor monitors
mrpalide Jun 30, 2023
2e08766
fix docker-compose config
mrpalide Jun 30, 2023
0cb9232
export RootCmd(s)
0pcom Jul 10, 2023
ca68f28
update go.mod & vendor
0pcom Jul 10, 2023
10242db
fix build docker images for pods
mrpalide Jul 11, 2023
e144bd2
update Makefile
mrpalide Jul 11, 2023
67c413e
merge develop
0pcom Jul 11, 2023
cce4087
update go.mod go.sum vendor
0pcom Jul 11, 2023
beaa4e9
update go.mod with skywire & skywire-utilities v1.3.11
0pcom Jul 11, 2023
3fc4b94
Merge branch 'develop' into fix/build-docker-images-on-macos
mrpalide Jul 11, 2023
13a3e7a
fix images
mrpalide Jul 11, 2023
21d01b1
fix docker_build.sh script
mrpalide Jul 11, 2023
99f9460
fix Makefile
mrpalide Jul 11, 2023
f6e7912
fix Makefile
mrpalide Jul 11, 2023
5db03ef
fix merge conflicts
0pcom Jul 12, 2023
16664e3
Merge pull request #25 from 0pcom/export-RootCmds
jdknives Jul 20, 2023
ce97006
Fix CI test workflow
jdknives Aug 30, 2023
b50480b
Bump base image Go version for Go
jdknives Aug 30, 2023
fbd7706
Merge branch 'develop' of https://github.com/skycoin/skywire-services…
jdknives Aug 30, 2023
8d0d50d
Vendor
jdknives Aug 30, 2023
3dfbd3a
fix transport setup keys missing on dmsg-monitor and network-monitor …
mrpalide Oct 13, 2023
22fc18d
change reading config logic of vpn-monitor and public-visor-monitor
mrpalide Oct 13, 2023
84ce8cc
upgrade golangci-lint to 1.52.1
mrpalide Oct 13, 2023
11a37b5
upgrade golang:alpine to 3.19
mrpalide Oct 13, 2023
30d6c03
upgrade golang:alpine to 3.17
mrpalide Oct 13, 2023
eabcfb0
update dmsg for use dmsgcurl instead dmsgget
mrpalide Oct 18, 2023
f2b804f
Merge pull request #16 from mrpalide/feat/add-dmsghttp-to-config-service
jdknives Nov 18, 2023
115d627
Merge pull request #30 from mrpalide/fix/improve-monitor-logic
jdknives Nov 20, 2023
0a5d597
update dmsg and skywire at develop | go mod tidy | go mod vendor
mrpalide Nov 20, 2023
a1a4b7a
update go to 1.21.*
mrpalide Nov 20, 2023
22696f8
update go in docker build to 1.21
mrpalide Nov 20, 2023
6bd4ba9
update config-bootstrapper Dockerfile
mrpalide Nov 20, 2023
532ae91
tiny dummy update on config-bootstrapper for checking issue
mrpalide Nov 20, 2023
fa83303
tiny dummy update on config-bootstrapper for checking issue 2
mrpalide Nov 20, 2023
6729f56
fix .test workflow
mrpalide Nov 20, 2023
88db660
add changes for test
mrpalide Nov 20, 2023
a5ecfbd
do tiny changes on docker_build.sh script
mrpalide Nov 20, 2023
463e443
update skywire-utilities
mrpalide Nov 20, 2023
754d428
update skywier@develop
mrpalide Nov 20, 2023
651e13c
update skywire and dmsg @ develop
mrpalide Nov 20, 2023
f93d1f9
update skywire-utilities
mrpalide Nov 20, 2023
09600fb
upgrade golang to 1.21
mrpalide Nov 20, 2023
5313cd5
Merge branch 'develop' into fix/update-dmsg
mrpalide Nov 20, 2023
8152349
fix visor configs
mrpalide Nov 20, 2023
bb1ea9d
Merge pull request #31 from mrpalide/fix/update-dmsg
jdknives Nov 20, 2023
3398e83
improve `/health` endpoint informations (#33)
mrpalide Dec 10, 2023
64f8647
add dmsghttp access (#34)
mrpalide Dec 10, 2023
3212895
Update dependencies (#37)
mrpalide Dec 21, 2023
c989efd
fix wrong url on tpd deregister
mrpalide Jan 8, 2024
8363b52
fix typo
mrpalide Jan 8, 2024
7519e90
Merge pull request #39 from mrpalide/fix/improve-network-monitor
mrpalide Jan 8, 2024
3badf7f
improve error log on tpd monitor
mrpalide Jan 8, 2024
61e6d5c
Merge branch 'develop' into fix/improve-error-log-on-tpd-monitor
mrpalide Jan 8, 2024
d99c5e9
Merge pull request #40 from mrpalide/fix/improve-error-log-on-tpd-mon…
mrpalide Jan 8, 2024
addb4c2
move deregister endpoint out of nonce needed scope
mrpalide Jan 8, 2024
318dafd
Merge pull request #41 from mrpalide/fix/move-tpd-deregister-out-of-n…
mrpalide Jan 8, 2024
a816b7a
add whitelisted pks to tpd
mrpalide Jan 8, 2024
6b5dc72
Merge pull request #42 from mrpalide/fix/add-missing-part-of-monitor-…
mrpalide Jan 8, 2024
c06d2b1
fix linting issue
mrpalide Jan 8, 2024
3b74615
Merge pull request #43 from mrpalide/fix/fix-checking-error
mrpalide Jan 8, 2024
1a9e9ae
add shuffle on entries list of dmsg monitor
mrpalide Jan 9, 2024
81d54f1
Merge branch 'develop' into fix/add-shuffle-on-entries-list-of-dmsg-m…
mrpalide Jan 9, 2024
4a53cab
fix shuffle comment
mrpalide Jan 9, 2024
c66f356
Merge pull request #44 from mrpalide/fix/add-shuffle-on-entries-list-…
mrpalide Jan 9, 2024
b713db9
revert to old vpn-lite-client implementation
mrpalide Jan 9, 2024
2ce79fd
change oldApps logic on read config on vpn-monitor | remove unnecessa…
mrpalide Jan 9, 2024
21e3801
add shuffle on vpn list
mrpalide Jan 9, 2024
44d439d
Merge pull request #45 from mrpalide/fix/fix-vpn-monitor-issue
mrpalide Jan 9, 2024
132d8ee
fix route setup pks
mrpalide Jan 10, 2024
65a41ff
add tpsetuppks and surveywhitelistpks
mrpalide Jan 10, 2024
701233d
Merge branch 'develop' into fix/fix-wrong-keys-on-whitelistedPKs-dmsg…
mrpalide Jan 10, 2024
34cb3f3
Merge pull request #46 from mrpalide/fix/fix-wrong-keys-on-whiteliste…
mrpalide Jan 10, 2024
be7bf2c
Skysocks Monitor (#47)
mrpalide Jan 27, 2024
1b3cd00
Merge branch 'develop' into fix/monitors
mrpalide Jan 30, 2024
b2035f1
fix make check errors
mrpalide Jan 30, 2024
78c46f5
update docker-compose config
mrpalide Jan 30, 2024
869707f
udpate docker configs
mrpalide Jan 30, 2024
05b428b
Merge pull request #21 from mrpalide/fix/monitors
mrpalide Jan 30, 2024
3ad0f72
fix conflict
mrpalide Feb 1, 2024
7343026
fix some little issues
mrpalide Feb 1, 2024
afdfdf9
revert changes on dockerfiles
mrpalide Feb 1, 2024
27de6c8
fix little issues
mrpalide Feb 1, 2024
344d58e
fix vpn-test after recent changes on skywire vpn commands
mrpalide Feb 1, 2024
fbd8087
fix sd address for test
mrpalide Feb 1, 2024
b10c45c
fix sd address for test 2
mrpalide Feb 1, 2024
a84c785
fix ut address for test
mrpalide Feb 1, 2024
fda0ab7
disable skywire-cli vpn list command tests
mrpalide Feb 1, 2024
cb87a6e
Merge pull request #26 from mrpalide/fix/build-docker-images-on-macos
mrpalide Feb 1, 2024
68305a6
downgrade wireguard
mrpalide Feb 6, 2024
38eb4ba
fix VisorTpRm test command
mrpalide Feb 6, 2024
ebee734
Merge pull request #50 from mrpalide/fix/upgrade-wireguard-version
mrpalide Feb 7, 2024
e0f7b5c
upgrade skywire-utilities@develop
mrpalide Feb 8, 2024
0fb0916
add reward system pks to dmsg monitor whitelisted keys
mrpalide Feb 8, 2024
1f5d698
Merge pull request #51 from mrpalide/fix/add-reward-system-pk-to-dmsg…
mrpalide Feb 8, 2024
c8b53f2
disable node visualizer on docker build/push/clean steps, temporary
mrpalide Feb 26, 2024
a98e7a5
update dmsg@develop skywire@develop
mrpalide Feb 26, 2024
c3dfca9
- increase gap between two deregistation from 10 to 60 minutes
mrpalide Feb 26, 2024
7775a17
Merge branch 'develop' into fix/update-dmsg-monitor-logic-based-on-ne…
mrpalide Feb 26, 2024
0247e83
update skywire-utilities@develop"
mrpalide Feb 26, 2024
111c691
update configs of integraion and e2e tests
mrpalide Feb 26, 2024
be57550
update visor config file on e2e-test
mrpalide Feb 26, 2024
7288d44
fix visor configs on integration/e2e test
mrpalide Feb 26, 2024
f4e2916
fix visors configs
mrpalide Feb 26, 2024
a5fce66
add nocash to create e2e-image of visor"
mrpalide Feb 27, 2024
cca6a43
revert cash on dockerfile skywire visors
mrpalide Feb 27, 2024
e2b85b1
minor cli interface refactor (#53)
0pcom Feb 27, 2024
70aad53
fix skymessage ci issue
mrpalide Feb 29, 2024
b8740f9
update skywire@develop
mrpalide Feb 29, 2024
1ea5461
Merge branch 'develop' into fix/update-dmsg-monitor-logic-based-on-ne…
mrpalide Feb 29, 2024
5e5d9bc
add skysocks-monitor to e2e
mrpalide Feb 29, 2024
ccf4676
fix skysock monitor issue on e2e
mrpalide Feb 29, 2024
c9e98dd
Merge pull request #52 from mrpalide/fix/update-dmsg-monitor-logic-ba…
mrpalide Feb 29, 2024
177c854
Improve help menus (#54)
0pcom Mar 6, 2024
60e846f
delete syslog from whole of the repo
mrpalide Mar 16, 2024
662954c
fix ar issue on help menu
mrpalide Mar 16, 2024
0498a90
Merge pull request #57 from mrpalide/fix/remove-syslog-codes
mrpalide Mar 16, 2024
239cff8
add newTUNDevice to windows
mrpalide Mar 16, 2024
caaa6f3
Merge pull request #58 from mrpalide/fix/add-newTUNDevice-for-windows
mrpalide Mar 16, 2024
e87c29e
move back UT from own repo here
mrpalide Mar 25, 2024
ef7df7b
udpate db config for other services like UT
mrpalide Mar 25, 2024
e1c6bc4
fix tidy & vendor
mrpalide Mar 25, 2024
ba88986
update skywire dockerfile and configs
mrpalide Mar 25, 2024
7ed4c26
update skywire dockerfile and configs 2
mrpalide Mar 25, 2024
61e352d
remove wrong commands
mrpalide Mar 25, 2024
551d3da
fix ut docker file
mrpalide Mar 25, 2024
1961a1d
fix ENTRYPOINT of skywire
mrpalide Mar 25, 2024
bfc5e01
fix docker compose command
mrpalide Mar 25, 2024
a3a26ac
fix env_test commands
mrpalide Mar 25, 2024
e8e36b4
update visor configs
mrpalide Mar 25, 2024
c5b3252
update visor configs 2
mrpalide Mar 25, 2024
2fd1c10
update skywire@develop
mrpalide Mar 25, 2024
724b119
upgrade dsmg to v1.3.20
mrpalide Mar 25, 2024
58b8010
Merge pull request #62 from mrpalide/fix/move-ut-back-here
mrpalide Mar 26, 2024
50ccbbf
CLI for transport setup node (#65)
0pcom Apr 3, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
6 changes: 2 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,13 @@ jobs:
- name: Setup golang
uses: actions/setup-go@v3
with:
go-version: 1.19.x
go-version: 1.21.x
- name: Check out code
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Install Requirements
run: |
GO111MODULES=off; go mod vendor
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.50.1
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.55.2
- name: Setup SSH Key Build and run e2e
run : |
make e2e-build
Expand Down
1 change: 0 additions & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,6 @@ linters:
- megacheck
- misspell
- nakedret
- depguard
enable-all: false
disable:
disable-all: true
Expand Down
79 changes: 17 additions & 62 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ DATE := $(shell date -u $(RFC_3339))
COMMIT := $(shell git rev-list -1 HEAD)

OPTS?=GO111MODULE=on
DOCKER_OPTS?=GO111MODULE=on GOOS=linux # go options for compiling for docker container
DOCKER_OPTS?=GO111MODULE=on GOOS=linux
DOCKER_NETWORK?=SKYWIRE
DOCKER_COMPOSE_FILE:=./docker/docker-compose.yml
DOCKER_REGISTRY:=skycoin
Expand Down Expand Up @@ -45,78 +45,32 @@ export REGISTRY=${DOCKER_REGISTRY}
## : ## _ [Prepare code]

dep: ## Sorts dependencies
@command -v yarn >/dev/null 2>&1 && yarn --cwd ./pkg/node-visualizer/web install || true
# GO111MODULE=on GOPRIVATE=github.com/skycoin/* go get -v github.com/skycoin/skywire@master
GO111MODULE=on GOPRIVATE=github.com/skycoin/* go mod vendor -v
yarn --cwd ./pkg/node-visualizer/web install
# GO111MODULE=on GOPRIVATE=github.com/skycoin/* go mod vendor -v

format: dep ## Formats the code. Must have goimports and goimports-reviser installed (use make install-linters).
goimports -w -local github.com/skycoin/skywire-services ./pkg
goimports -w -local github.com/skycoin/skywire-services ./cmd
goimports -w -local github.com/skycoin/skywire-services ./internal
find . -type f -name '*.go' -not -path "./vendor/*" -exec goimports-reviser -project-name ${PROJECT_BASE} {} \;
goimports -w -local github.com/skycoin/skywire-services ./pkg ./cmd ./internal
find . -type f -name '*.go' -not -path "./.git/*" -not -path "./vendor/*" -exec goimports-reviser -project-name ${PROJECT_BASE} {} \;

## : ## _ [Build, install, clean]

build: dep ## Build binaries
${OPTS} go build ${BUILD_OPTS} -o ./bin/route-finder ./cmd/route-finder
${OPTS} go build ${BUILD_OPTS} -o ./bin/setup-node ./cmd/setup-node
${OPTS} go build ${BUILD_OPTS} -o ./bin/transport-discovery ./cmd/transport-discovery
${OPTS} go build ${BUILD_OPTS} -o ./bin/address-resolver ./cmd/address-resolver
${OPTS} go build ${BUILD_OPTS} -o ./bin/sw-env ./cmd/sw-env
${OPTS} go build ${BUILD_OPTS} -o ./bin/keys-gen ./cmd/keys-gen
${OPTS} go build ${BUILD_OPTS} -o ./bin/network-monitor ./cmd/network-monitor
${OPTS} go build ${BUILD_OPTS} -o ./apps/vpn-client ./cmd/vpn-lite-client
${OPTS} go build ${BUILD_OPTS} -o ./bin/transport-setup ./cmd/transport-setup
${OPTS} go build ${BUILD_OPTS} -o ./bin/config-bootstrapper ./cmd/config-bootstrapper
${OPTS} go build ${BUILD_OPTS} -o ./bin/liveness-checker ./cmd/liveness-checker
${OPTS} go build ${BUILD_OPTS} -o ./bin/dmsg-monitor ./cmd/dmsg-monitor
${OPTS} go build ${BUILD_OPTS} -o ./bin/tpd-monitor ./cmd/tpd-monitor
${OPTS} go build ${BUILD_OPTS} -o ./bin/vpn-monitor ./cmd/vpn-monitor
${OPTS} go build ${BUILD_OPTS} -o ./bin/public-visor-monitor ./cmd/public-visor-monitor
${OPTS} go build ${BUILD_OPTS} -o ./bin/skywire-services ./cmd/skywire-services

# yarn --cwd ./pkg/node-visualizer/web build
# rm -rf ./pkg/node-visualizer/api/build/static
# mv ./pkg/node-visualizer/web/build/* ./pkg/node-visualizer/api/build
# ${OPTS} go build ${BUILD_OPTS} -o ./bin/node-visualizer ./cmd/node-visualizer

build-deploy: ## Build for deployment Docker images
go build ${BUILD_OPTS_DEPLOY} -mod=vendor -o /release/address-resolver ./cmd/address-resolver
go build ${BUILD_OPTS_DEPLOY} -mod=vendor -o /release/route-finder ./cmd/route-finder
go build ${BUILD_OPTS_DEPLOY} -mod=vendor -o /release/setup-node ./cmd/setup-node
go build ${BUILD_OPTS_DEPLOY} -mod=vendor -o /release/transport-discovery ./cmd/transport-discovery
go build ${BUILD_OPTS_DEPLOY} -mod=vendor -o /release/network-monitor ./cmd/network-monitor
go build ${BUILD_OPTS_DEPLOY} -mod=vendor -o /release/vpn-client ./cmd/vpn-lite-client
go build ${BUILD_OPTS_DEPLOY} -mod=vendor -o /release/transport-setup ./cmd/transport-setup
go build ${BUILD_OPTS_DEPLOY} -mod=vendor -o /release/node-visualizer ./cmd/node-visualizer
go build ${BUILD_OPTS_DEPLOY} -mod=vendor -o /release/dmsg-monitor ./cmd/dmsg-monitor
go build ${BUILD_OPTS_DEPLOY} -mod=vendor -o /release/tpd-monitor ./cmd/tpd-monitor
go build ${BUILD_OPTS_DEPLOY} -mod=vendor -o /release/vpn-monitor ./cmd/vpn-monitor
go build ${BUILD_OPTS_DEPLOY} -mod=vendor -o /release/public-visor-monitor ./cmd/public-visor-monitor
${DOCKER_OPTS} go build ${BUILD_OPTS_DEPLOY} -mod=vendor -o ./release/skywire-services ./cmd/skywire-services

build-race: dep ## Build binaries
${OPTS} go build ${BUILD_OPTS} -race -o ./bin/route-finder ./cmd/route-finder
${OPTS} go build ${BUILD_OPTS} -race -o ./bin/setup-node ./cmd/setup-node
${OPTS} go build ${BUILD_OPTS} -race -o ./bin/transport-discovery ./cmd/transport-discovery
${OPTS} go build ${BUILD_OPTS} -race -o ./bin/address-resolver ./cmd/address-resolver
${OPTS} go build ${BUILD_OPTS} -race -o ./bin/sw-env ./cmd/sw-env
${OPTS} go build ${BUILD_OPTS} -race -o ./bin/keys-gen ./cmd/keys-gen
${OPTS} go build ${BUILD_OPTS} -race -o ./bin/network-monitor ./cmd/network-monitor
${OPTS} go build ${BUILD_OPTS} -race -o ./bin/vpn-client ./cmd/vpn-lite-client
${OPTS} go build ${BUILD_OPTS} -race -o ./bin/transport-setup ./cmd/transport-setup
${OPTS} go build ${BUILD_OPTS} -race -o ./bin/node-visualizer ./cmd/node-visualizer
${OPTS} go build ${BUILD_OPTS} -race -o ./bin/dmsg-monitor ./cmd/dmsg-monitor
${OPTS} go build ${BUILD_OPTS} -race -o ./bin/tpd-monitor ./cmd/tpd-monitor
${OPTS} go build ${BUILD_OPTS} -race -o ./bin/vpn-monitor ./cmd/vpn-monitor
${OPTS} go build ${BUILD_OPTS} -race -o ./bin/public-visor-monitor ./cmd/public-visor-monitor
${OPTS} go build ${BUILD_OPTS} -race -o ./bin/skywire-services ./cmd/skywire-services

install: ## Install route-finder, transport-discovery, address-resolver, sw-env, keys-gen, network-monitor, node-visualizer
${OPTS} go install ${BUILD_OPTS} \
./cmd/route-finder \
./cmd/transport-discovery \
./cmd/address-resolver \
./cmd/sw-env \
./cmd/keys-gen \
./cmd/network-monitor \
./cmd/node-visualizer
${OPTS} go install ${BUILD_OPTS} ./cmd/skywire-services

clean: ## Clean compiled binaries
rm -rf bin
Expand Down Expand Up @@ -188,9 +142,15 @@ e2e-help: ## E2E. Show env-vars and useful commands
@echo -e " docker-compose up/down/start/stop"
@echo -e "\nConsult with:\n\n docker-compose help\n"

docker-build-test:
bash ./docker/docker_build.sh test ${BUILD_OPTS_DEPLOY}

docker-build:
bash ./docker/docker_build.sh prod ${BUILD_OPTS_DEPLOY}

docker-push-test:
bash ./docker/docker_build.sh test ${BUILD_OPTS_DEPLOY}
# bash ./docker/docker_push.sh test
bash ./docker/docker_push.sh test

docker-push:
bash ./docker/docker_build.sh prod ${BUILD_OPTS_DEPLOY}
Expand Down Expand Up @@ -236,10 +196,5 @@ vendor-integration-check: ## Check compatibility of master@skywire-services with

## : ## _ [Other]

run-syslog: ## Run syslog-ng in docker. Logs are mounted under /tmp/syslog
-mkdir -p /tmp/syslog
-docker container rm syslog-ng -f
docker run -d -p 514:514/udp -v /tmp/syslog:/var/log --name syslog-ng balabit/syslog-ng:latest

help:
@grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$|^##.*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
- Setup Node (SN)
- Service Discovery (SD)
- Address Resolver (AR)
- Uptime Tracker (UT)

## Running the services locally

Expand Down Expand Up @@ -71,3 +72,4 @@ Check the [docs](docs/Deployments.md) for more documentation on the deployments.
- [Dmsg Discovery](https://github.com/skycoin/dmsg/blob/develop/cmd/dmsg-discovery/README.md)
- [Dmsg Server](https://github.com/skycoin/dmsg/blob/develop/cmd/dmsg-server/README.md)
- [Service Discovery](https://github.com/skycoin/skycoin-service-discovery/blob/master/README.md#http-api)
- [Uptime Tracker](cmd/uptime-tracker/README.md)
31 changes: 31 additions & 0 deletions cmd/address-resolver/address-resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,40 @@
package main

import (
cc "github.com/ivanpirog/coloredcobra"
"github.com/spf13/cobra"

"github.com/skycoin/skywire-services/cmd/address-resolver/commands"
)

func init() {
commands.RootCmd.SetUsageTemplate(help)
commands.RootCmd.SetHelpCommand(&cobra.Command{Hidden: true})
commands.RootCmd.PersistentFlags().MarkHidden("help") //nolint
}

func main() {
cc.Init(&cc.Config{
RootCmd: commands.RootCmd,
Headings: cc.HiBlue + cc.Bold,
Commands: cc.HiBlue + cc.Bold,
CmdShortDescr: cc.HiBlue,
Example: cc.HiBlue + cc.Italic,
ExecName: cc.HiBlue + cc.Bold,
Flags: cc.HiBlue + cc.Bold,
FlagsDescr: cc.HiBlue,
NoExtraNewlines: true,
NoBottomNewline: true,
})
commands.Execute()
}

const help = "Usage:\r\n" +
" {{.UseLine}}{{if .HasAvailableSubCommands}}{{end}} {{if gt (len .Aliases) 0}}\r\n\r\n" +
"{{.NameAndAliases}}{{end}}{{if .HasAvailableSubCommands}}\r\n\r\n" +
"Available Commands:{{range .Commands}}{{if (or .IsAvailableCommand)}}\r\n " +
"{{rpad .Name .NamePadding }} {{.Short}}{{end}}{{end}}{{end}}{{if .HasAvailableLocalFlags}}\r\n\r\n" +
"Flags:\r\n" +
"{{.LocalFlags.FlagUsages | trimTrailingWhitespaces}}{{end}}{{if .HasAvailableInheritedFlags}}\r\n\r\n" +
"Global Flags:\r\n" +
"{{.InheritedFlags.FlagUsages | trimTrailingWhitespaces}}{{end}}\r\n\r\n"
75 changes: 41 additions & 34 deletions cmd/address-resolver/commands/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ import (
"context"
"fmt"
"log"
"log/syslog"
"os"
"path/filepath"
"strings"
"time"

cc "github.com/ivanpirog/coloredcobra"
logrussyslog "github.com/sirupsen/logrus/hooks/syslog"
"github.com/skycoin/dmsg/pkg/direct"
"github.com/skycoin/dmsg/pkg/dmsg"
"github.com/skycoin/dmsg/pkg/dmsghttp"
Expand Down Expand Up @@ -41,7 +41,6 @@ var (
metricsAddr string
redisURL string
redisPoolSize int
syslogAddr string
tag string
logLvl string
testing bool
Expand All @@ -53,33 +52,42 @@ var (
)

func init() {
rootCmd.Flags().StringVarP(&addr, "addr", "a", ":9093", "address to bind to\033[0m")
rootCmd.Flags().StringVarP(&metricsAddr, "metrics", "m", "", "address to bind metrics API to\033[0m")
rootCmd.Flags().StringVar(&redisURL, "redis", "redis://localhost:6379", "connections string for a redis store\033[0m")
rootCmd.Flags().IntVar(&redisPoolSize, "redis-pool-size", 10, "redis connection pool size\033[0m")
rootCmd.Flags().StringVarP(&logLvl, "loglvl", "l", "info", "set log level one of: info, error, warn, debug, trace, panic")
rootCmd.Flags().StringVar(&syslogAddr, "syslog", "", "syslog server address. E.g. localhost:514\033[0m")
rootCmd.Flags().StringVar(&tag, "tag", "address_resolver", "logging tag\033[0m")
rootCmd.Flags().BoolVarP(&testing, "testing", "t", false, "enable testing to start without redis\033[0m")
rootCmd.Flags().StringVar(&dmsgDisc, "dmsg-disc", "http://dmsgd.skywire.skycoin.com", "url of dmsg-discovery\033[0m")
rootCmd.Flags().StringVar(&whitelistKeys, "whitelist-keys", "", "list of whitelisted keys of network monitor used for deregistration\033[0m")
rootCmd.Flags().BoolVar(&testEnvironment, "test-environment", false, "distinguished between prod and test environment\033[0m")
rootCmd.Flags().Var(&sk, "sk", "dmsg secret key\r")
rootCmd.Flags().Uint16Var(&dmsgPort, "dmsgPort", dmsg.DefaultDmsgHTTPPort, "dmsg port value\r")
RootCmd.Flags().StringVarP(&addr, "addr", "a", ":9093", "address to bind to\033[0m")
RootCmd.Flags().StringVarP(&metricsAddr, "metrics", "m", "", "address to bind metrics API to\033[0m")
RootCmd.Flags().StringVar(&redisURL, "redis", "redis://localhost:6379", "connections string for a redis store\033[0m")
RootCmd.Flags().IntVar(&redisPoolSize, "redis-pool-size", 10, "redis connection pool size\033[0m")
RootCmd.Flags().StringVarP(&logLvl, "loglvl", "l", "info", "set log level one of: info, error, warn, debug, trace, panic")
RootCmd.Flags().StringVar(&tag, "tag", "address_resolver", "logging tag\033[0m")
RootCmd.Flags().BoolVarP(&testing, "testing", "t", false, "enable testing to start without redis\033[0m")
RootCmd.Flags().StringVar(&dmsgDisc, "dmsg-disc", "http://dmsgd.skywire.skycoin.com", "url of dmsg-discovery\033[0m")
RootCmd.Flags().StringVar(&whitelistKeys, "whitelist-keys", "", "list of whitelisted keys of network monitor used for deregistration\033[0m")
RootCmd.Flags().BoolVar(&testEnvironment, "test-environment", false, "distinguished between prod and test environment\033[0m")
RootCmd.Flags().Var(&sk, "sk", "dmsg secret key\r")
RootCmd.Flags().Uint16Var(&dmsgPort, "dmsgPort", dmsg.DefaultDmsgHTTPPort, "dmsg port value\r")
var helpflag bool
rootCmd.SetUsageTemplate(help)
rootCmd.PersistentFlags().BoolVarP(&helpflag, "help", "h", false, "help for "+rootCmd.Use)
rootCmd.SetHelpCommand(&cobra.Command{Hidden: true})
rootCmd.PersistentFlags().MarkHidden("help") //nolint
RootCmd.SetUsageTemplate(help)
RootCmd.PersistentFlags().BoolVarP(&helpflag, "help", "h", false, "help for address-resolver")
RootCmd.SetHelpCommand(&cobra.Command{Hidden: true})
RootCmd.PersistentFlags().MarkHidden("help") //nolint
}

var rootCmd = &cobra.Command{
Use: "address-resolver",
// RootCmd contains the root command
var RootCmd = &cobra.Command{
Use: func() string {
return strings.Split(filepath.Base(strings.ReplaceAll(strings.ReplaceAll(fmt.Sprintf("%v", os.Args), "[", ""), "]", "")), " ")[0]
}(),
Short: "Address Resolver Server for skywire",
Long: `
┌─┐┌┬┐┌┬┐┬─┐┌─┐┌─┐┌─┐ ┬─┐┌─┐┌─┐┌─┐┬ ┬ ┬┌─┐┬─┐
├─┤ ││ ││├┬┘├┤ └─┐└─┐───├┬┘├┤ └─┐│ ││ └┐┌┘├┤ ├┬┘
┴ ┴─┴┘─┴┘┴└─└─┘└─┘└─┘ ┴└─└─┘└─┘└─┘┴─┘└┘ └─┘┴└─`,
┴ ┴─┴┘─┴┘┴└─└─┘└─┘└─┘ ┴└─└─┘└─┘└─┘┴─┘└┘ └─┘┴└─

depends: redis

Note: the specified port must be accessible from the internet ip address or port forwarded for udp
skywire cli config gen-keys > ar-config.json
skywire svc ar --addr ":9093" --redis "redis://localhost:6379" --sk $(tail -n1 ar-config.json)
`,
SilenceErrors: true,
SilenceUsage: true,
DisableSuggestions: true,
Expand Down Expand Up @@ -145,14 +153,6 @@ var rootCmd = &cobra.Command{
logger.WithError(err).Warn("No SecKey found. Skipping serving on dmsghttp.")
}

if syslogAddr != "" {
hook, err := logrussyslog.NewSyslogHook("udp", syslogAddr, syslog.LOG_INFO, tag)
if err != nil && logger != nil {
logger.Fatalf("Unable to connect to syslog daemon on %v", syslogAddr)
}
logging.AddHook(hook)
}

metricsutil.ServeHTTPMetrics(logger, metricsAddr)

var m armetrics.Metrics
Expand Down Expand Up @@ -206,10 +206,17 @@ var rootCmd = &cobra.Command{

defer closeDmsgDC()

go func() {
for {
arAPI.DmsgServers = dmsgDC.ConnectedServersPK()
time.Sleep(time.Second)
}
}()

go dmsghttp.UpdateServers(ctx, dClient, dmsgDisc, dmsgDC, logger)

go func() {
if err := dmsghttp.ListenAndServe(ctx, pk, sk, arAPI, dClient, dmsg.DefaultDmsgHTTPPort, config, dmsgDC, logger); err != nil {
if err := dmsghttp.ListenAndServe(ctx, sk, arAPI, dClient, dmsg.DefaultDmsgHTTPPort, dmsgDC, logger); err != nil {
logger.Errorf("dmsghttp.ListenAndServe: %v", err)
cancel()
}
Expand All @@ -225,7 +232,7 @@ var rootCmd = &cobra.Command{
// Execute executes root CLI command.
func Execute() {
cc.Init(&cc.Config{
RootCmd: rootCmd,
RootCmd: RootCmd,
Headings: cc.HiBlue + cc.Bold, //+ cc.Underline,
Commands: cc.HiBlue + cc.Bold,
CmdShortDescr: cc.HiBlue,
Expand All @@ -237,7 +244,7 @@ func Execute() {
NoExtraNewlines: true,
NoBottomNewline: true,
})
if err := rootCmd.Execute(); err != nil {
if err := RootCmd.Execute(); err != nil {
log.Fatal("Failed to execute command: ", err)

}
Expand Down
Loading
Loading