From 6d7da7b48cb1841d2e9f47e412374ff806439585 Mon Sep 17 00:00:00 2001 From: Tim Foerster Date: Wed, 20 Feb 2019 22:10:59 +0100 Subject: [PATCH] repo: Update structure, add ci/cd pipeline --- .gitignore | 1 + .goreleaser.yml | 35 +++++++++++++++++++++++++++++++++++ .travis.yml | 25 +++++++++++++++++++++++++ README.md | 13 +++---------- cli/cli.go | 2 +- {hop => pkg/hop}/hop.go | 2 +- {icmp => pkg/icmp}/icmp.go | 0 {mtr => pkg/mtr}/mtr.go | 4 ++-- 8 files changed, 68 insertions(+), 14 deletions(-) create mode 100644 .goreleaser.yml create mode 100644 .travis.yml rename {hop => pkg/hop}/hop.go (98%) rename {icmp => pkg/icmp}/icmp.go (100%) rename {mtr => pkg/mtr}/mtr.go (97%) diff --git a/.gitignore b/.gitignore index d104f1d..b9c755c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ *.swp mtr-bin +/dist diff --git a/.goreleaser.yml b/.goreleaser.yml new file mode 100644 index 0000000..baf2425 --- /dev/null +++ b/.goreleaser.yml @@ -0,0 +1,35 @@ +build: + binary: mtr + main: main.go + ldflags: + - > + -s -w + -X github.com/tonobo/mtr/cli.version={{.Version}} + -X github.com/tonobo/mtr/cli.date={{.Date}} + goos: + - linux + env: + - CGO_ENABLED=0 + +archive: + name_template: "{{.Binary}}_{{.Os}}_{{.Arch}}" + +snapshot: + name_template: "{{.Tag}}" + +checksum: + name_template: "mtr_checksums.txt" + +nfpm: + vendor: Task + homepage: https://github.com/tonobo/mtr + maintainer: Tim Foerster + description: Golang native MTR + license: MIT + conflicts: + - mtr + formats: + - deb + - rpm + name_template: "{{.ProjectName}}_{{.Os}}_{{.Arch}}" + diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..63651ca --- /dev/null +++ b/.travis.yml @@ -0,0 +1,25 @@ +language: go + +go: + - 1.11.x + +addons: + apt: + packages: + - rpm + +env: + - GO111MODULE=on + +script: + - go build -o mtr # currently there are no tests avaiable ... + - git reset --hard + +deploy: + - provider: script + skip_cleanup: true + script: curl -sL http://git.io/goreleaser | bash + on: + tags: true + condition: $TRAVIS_OS_NAME = linux + diff --git a/README.md b/README.md index 0c63bca..c754897 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,14 @@ # MTR -A MTR implementation written in golang, completly without shell-execs. +A MTR implementation written in golang, completely without shell-execs. Just install with the following command: ``` go get -u github.com/tonobo/mtr +sudo setcap cap_net_raw+ep PATH-TO-GOMTR ``` -**Note: This tool mayby called with sudo or as root, because it requires raw sockets.** +**Note: This tool maybe called with sudo or as root, because it requires raw sockets.** ## Output @@ -86,11 +87,3 @@ Flags: --max-hops int Maximal TTL count (default 64) -t, --timeout duration ICMP reply timeout (default 800ms) ``` - -## Roadmap - -* [ ] IPv6 Support -* [ ] HTTP API (Launch MTR and just receive Updates - Grpc, Websocket, HTTP-Polling?) -* [ ] PTR Lookup -* [ ] AS-Number Lookup -* [ ] Multi-Target Support at Hop-Level diff --git a/cli/cli.go b/cli/cli.go index f04b7a7..4e61ec3 100644 --- a/cli/cli.go +++ b/cli/cli.go @@ -9,7 +9,7 @@ import ( tm "github.com/buger/goterm" pj "github.com/hokaccha/go-prettyjson" "github.com/spf13/cobra" - "github.com/tonobo/mtr/mtr" + "github.com/tonobo/mtr/pkg/mtr" ) var ( diff --git a/hop/hop.go b/pkg/hop/hop.go similarity index 98% rename from hop/hop.go rename to pkg/hop/hop.go index f4c6407..2729fdc 100644 --- a/hop/hop.go +++ b/pkg/hop/hop.go @@ -8,7 +8,7 @@ import ( "time" gm "github.com/buger/goterm" - "github.com/tonobo/mtr/icmp" + "github.com/tonobo/mtr/pkg/icmp" ) type HopStatistic struct { diff --git a/icmp/icmp.go b/pkg/icmp/icmp.go similarity index 100% rename from icmp/icmp.go rename to pkg/icmp/icmp.go diff --git a/mtr/mtr.go b/pkg/mtr/mtr.go similarity index 97% rename from mtr/mtr.go rename to pkg/mtr/mtr.go index ab59fd5..bf1f29e 100644 --- a/mtr/mtr.go +++ b/pkg/mtr/mtr.go @@ -9,8 +9,8 @@ import ( "time" gm "github.com/buger/goterm" - "github.com/tonobo/mtr/hop" - "github.com/tonobo/mtr/icmp" + "github.com/tonobo/mtr/pkg/hop" + "github.com/tonobo/mtr/pkg/icmp" ) type MTR struct {