Skip to content

Commit

Permalink
v0.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
spiritLHLS committed Jun 27, 2024
1 parent d93eed9 commit 1e437aa
Show file tree
Hide file tree
Showing 10 changed files with 843 additions and 1 deletion.
31 changes: 31 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: CI

on:
workflow_dispatch:

jobs:
test:
strategy:
matrix:
go: [ '1.22.x' ]
os: [ ubuntu-latest ]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup Go
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go }}
- name: Test
run: go test ./... -coverprofile=coverage.txt
- name: Create Tag
if: success() # 仅在测试成功时运行
run: |
git config --global user.name 'github-actions'
git config --global user.email '[email protected]'
TAG="v0.0.1-$(date +'%Y%m%d%H%M%S')"
git tag $TAG
git push origin $TAG
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
126 changes: 126 additions & 0 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
name: Build and Release

on:
# push:
# branches: [ main ]
# pull_request:
# branches: [ main ]
# release:
# types: [published]
workflow_dispatch:

jobs:
build:
name: Build and Test
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 'stable'

- name: Test on Default Platform
run: |
go test -v ./...
- name: Delete Existing Release Assets
run: |
release_id=$(curl -s -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" "https://api.github.com/repos/oneclickvirt/nt3/releases/tags/output" | jq -r '.id')
echo "Deleting existing release assets..."
assets=$(curl -s -H "Accept: application/vnd.github.v3+json" "https://api.github.com/repos/oneclickvirt/nt3/releases/$release_id/assets" | jq -r '.[] | .id')
for asset in $assets; do
echo "Deleting asset with ID: $asset"
curl -X DELETE -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" "https://api.github.com/repos/oneclickvirt/nt3/releases/assets/$asset"
done
sleep 60
release-binary:
name: Release Go Binary
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 'stable'

- name: Build and Release
run: |
mkdir -p bin
cd cmd
CGO_ENABLED=0 GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} go build -o ../bin/nt3-${{ matrix.goos }}-${{ matrix.goarch }} -v -ldflags="-extldflags=-static" .
- name: Upload New Assets
run: |
release_id=$(curl -s -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" "https://api.github.com/repos/oneclickvirt/nt3/releases/tags/output" | jq -r '.id')
echo "Uploading new assets to release..."
for file in ./bin/*; do
echo "Uploading $file to release..."
curl -s -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
-H "Content-Type: application/octet-stream" \
--data-binary @"$file" \
"https://uploads.github.com/repos/oneclickvirt/nt3/releases/$release_id/assets?name=$(basename "$file")"
rm -rf $file
done
strategy:
matrix:
goos: [windows, freebsd, linux, darwin]
goarch: [amd64, 386]
exclude:
- goarch: 386
goos: darwin
include:
- goos: windows
goarch: 386
- goos: windows
goarch: amd64
- goos: windows
goarch: arm64
- goos: darwin
goarch: arm64
- goos: linux
goarch: arm
goarm: 7
- goos: linux
goarch: arm64
- goos: linux
goarch: riscv64
- goos: linux
goarch: mips64
- goos: linux
goarch: mips64le
- goos: linux
goarch: mipsle
- goos: linux
goarch: mips
- goos: freebsd
goarch: arm64
- goos: freebsd
goarch: arm
goarm: 7
# - goos: linux
# goarch: mipsle
# gomips: softfloat
# - goos: linux
# goarch: mips
# gomips: softfloat
# - goos: linux
# goarch: arm
# goarm: 6
# - goos: linux
# goarch: arm
# goarm: 5
# - goos: linux
# goarch: ppc64
# - goos: linux
# goarch: ppc64le
# - goos: windows
# goarch: arm
# goarm: 7
56 changes: 55 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,55 @@
# nt3
# nt3

[![Hits](https://hits.seeyoufarm.com/api/count/incr/badge.svg?url=https%3A%2F%2Fgithub.com%2Foneclickvirt%2Fnt3&count_bg=%232EFFF8&title_bg=%23555555&icon=&icon_color=%23E7E7E7&title=hits&edge_flat=false)](https://hits.seeyoufarm.com) [![Build and Release](https://github.com/oneclickvirt/nt3/actions/workflows/main.yaml/badge.svg)](https://github.com/oneclickvirt/nt3/actions/workflows/main.yaml)

三网路由查询模块

## 说明

- [x] 使用[nexttrace](https://github.com/nxtrace/NTrace-core)进行ICMP测试,预先加载定义好的广州、上海、北京、成都的三网地址
- [x] 支持双语输出,以```-l```指定```zh``````en```可指定输出的语言,未指定时默认使用中文输出
- [x] 全平台编译支持(除了WIN)

## 使用

下载及安装

```
curl https://raw.githubusercontent.com/oneclickvirt/nt3/main/nt3_install.sh -sSf | bash
```


```
curl https://cdn.spiritlhl.net/https://raw.githubusercontent.com/oneclickvirt/nt3/main/nt3_install.sh -sSf | bash
```

使用

```
nt3
```


```
./nt3
```

进行测试

无环境依赖,理论上适配所有系统和主流架构,更多架构请查看 https://github.com/oneclickvirt/nt3/releases/tag/output

```
```

## 在Golang中使用

```
go get github.com/oneclickvirt/nt3@latest
```

## Thanks

https://github.com/nxtrace/NTrace-core
43 changes: 43 additions & 0 deletions cmd/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package main

import (
"flag"
"fmt"
"net/http"
"strings"

"github.com/oneclickvirt/nt3/model"
"github.com/oneclickvirt/nt3/nt"
)

func main() {
go func() {
http.Get("https://hits.seeyoufarm.com/api/count/incr/badge.svg?url=https%3A%2F%2Fgithub.com%2Foneclickvirt%2Fnt3&count_bg=%2379C83D&title_bg=%23555555&icon=&icon_color=%23E7E7E7&title=hits&edge_flat=false")
}()
fmt.Println("项目地址:", "https://github.com/oneclickvirt/nt3")
var showVersion bool
var language, checkType, location string
flag.BoolVar(&showVersion, "v", false, "Show version information")
flag.StringVar(&language, "l", "", "Specify language parameter (en or zh, default is zh)")
flag.StringVar(&checkType, "c", "", "Specify check type (both, ipv4, or ipv6, default is ipv4)")
flag.StringVar(&location, "loc", "", "Specify location (supports GZ, BJ, SH, CD; corresponding to Guangzhou, Beijing, Shanghai, Chengdu)")
// flag.BoolVar(&model.EnableLoger, "log", false, "Enable logging")
flag.Parse()
if showVersion {
fmt.Println(model.NextTraceVersion)
return
}
if language == "" {
language = "zh"
} else {
language = strings.ToLower(language)
}
if checkType == "" || checkType == "ipv4" {
checkType = "ipv4"
} else if strings.ToLower(checkType) == "both" {
checkType = "both"
} else if strings.ToLower(checkType) == "ipv6" {
checkType = "ipv6"
}
nt.TraceRoute(language, location, checkType)
}
7 changes: 7 additions & 0 deletions cmd/main_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package main

import "testing"

func Test(t *testing.T) {
main()
}
43 changes: 43 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
module github.com/oneclickvirt/nt3

go 1.22.4

require (
github.com/fatih/color v1.17.0
github.com/nxtrace/NTrace-core v1.3.1
)

require (
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/google/gopacket v1.1.19 // indirect
github.com/gorilla/websocket v1.5.1 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/lionsoul2014/ip2region v2.11.2+incompatible // indirect
github.com/magiconair/properties v1.8.7 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/oschwald/maxminddb-golang v1.12.0 // indirect
github.com/pelletier/go-toml/v2 v2.2.2 // indirect
github.com/rodaine/table v1.2.0 // indirect
github.com/sagikazarmark/locafero v0.4.0 // indirect
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
github.com/sourcegraph/conc v0.3.0 // indirect
github.com/spf13/afero v1.11.0 // indirect
github.com/spf13/cast v1.6.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/spf13/viper v1.18.2 // indirect
github.com/subosito/gotenv v1.6.0 // indirect
github.com/tidwall/gjson v1.17.1 // indirect
github.com/tidwall/match v1.1.1 // indirect
github.com/tidwall/pretty v1.2.1 // indirect
github.com/tsosunchia/powclient v0.1.5 // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842 // indirect
golang.org/x/net v0.25.0 // indirect
golang.org/x/sync v0.7.0 // indirect
golang.org/x/sys v0.20.0 // indirect
golang.org/x/text v0.15.0 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
Loading

0 comments on commit 1e437aa

Please sign in to comment.