Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitcb302df

Browse files
authored
Merge pull request#331 from nxtrace/main
SYNC
2 parents3dc36ad +440aa44 commitcb302df

36 files changed

+4462
-388
lines changed

‎.cross_compile.sh‎

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ DIST_PREFIX="nexttrace"
77
DEBUG_MODE="${1:-}"# 支持 ./script.sh debug
88
TARGET_DIR="dist"
99
PLATFORMS="linux/386 linux/amd64 linux/arm64 linux/mips linux/mips64 linux/mipsle linux/mips64le windows/amd64 windows/arm64 openbsd/amd64 openbsd/arm64 freebsd/amd64 freebsd/arm64"
10+
UPX_BIN="${UPX_BIN:-$(command -v upx 2>/dev/null || true)}"
11+
UPX_FLAGS="${UPX_FLAGS:--9}"
1012

1113
# -------- Build metadata (robust) --------
1214
BUILD_VERSION="$(git describe --tags --always2>/dev/null|| true)"
@@ -26,6 +28,47 @@ if [[ "${DEBUG_MODE}" == "debug" ]]; then
2628
GO_BUILD_FLAGS=(-trimpath -gcflags"all=-N -l")
2729
fi
2830

31+
compress_with_upx() {
32+
local binary="${1:-}"
33+
local target_os="${2:-}"
34+
local target_arch="${3:-}"
35+
local target_arm="${4:-}"
36+
local note="${5:-}"
37+
if [["${target_os}"!="linux" ]];then
38+
return
39+
fi
40+
case"${target_arch}"in
41+
386|amd64|arm64)
42+
;;
43+
arm)
44+
if [["${target_arm}"!="7" ]];then
45+
return
46+
fi
47+
;;
48+
*)
49+
return
50+
;;
51+
esac
52+
if [[-z"${UPX_BIN}" ]];then
53+
return
54+
fi
55+
if [[!-f"${binary}" ]];then
56+
return
57+
fi
58+
if [["${note}"!="quiet" ]];then
59+
echo"upx =>${binary}"
60+
fi
61+
if!"${UPX_BIN}"${UPX_FLAGS}"${binary}">/dev/null;then
62+
echo"warn: upx failed for${binary}, keeping uncompressed">&2
63+
fi
64+
}
65+
66+
if [[-z"${UPX_BIN}" ]];then
67+
echo"info: upx not found; set UPX_BIN or install upx to enable binary compression">&2
68+
else
69+
echo"info: using upx at${UPX_BIN} with flags${UPX_FLAGS}">&2
70+
fi
71+
2972
# -------- Prepare out dir --------
3073
rm -rf --"${TARGET_DIR}"
3174
mkdir -p --"${TARGET_DIR}"
@@ -44,12 +87,14 @@ for pl in ${PLATFORMS}; do
4487

4588
echo"build =>${TARGET}"
4689
go build"${GO_BUILD_FLAGS[@]}" -o"${TARGET}" -ldflags"${LD_BASE}"
90+
compress_with_upx"${TARGET}""${GOOS}""${GOARCH}"
4791

4892
# Extra soft-float variants for linux/mips and linux/mipsle
4993
if [["${GOOS}"=="linux"&& ("${GOARCH}" =="mips"||"${GOARCH}" =="mipsle" ) ]];then
5094
TARGET_SOFT="${TARGET_DIR}/${DIST_PREFIX}_${GOOS}_${GOARCH}_softfloat"
5195
echo"build =>${TARGET_SOFT} (GOMIPS=softfloat)"
5296
GOMIPS=softfloat go build"${GO_BUILD_FLAGS[@]}" -o"${TARGET_SOFT}" -ldflags"${LD_BASE}"
97+
compress_with_upx"${TARGET_SOFT}""${GOOS}""${GOARCH}"
5398
fi
5499
done
55100

@@ -61,6 +106,7 @@ export GOARM='7'
61106
TARGET="${TARGET_DIR}/${DIST_PREFIX}_${GOOS}_${GOARCH}v7"
62107
echo"build =>${TARGET}"
63108
go build"${GO_BUILD_FLAGS[@]}" -o"${TARGET}" -ldflags"${LD_BASE}"
109+
compress_with_upx"${TARGET}""${GOOS}""${GOARCH}""${GOARM}"
64110

65111
# -------- Darwin targets with CGO + SDK libpcap --------
66112
if [["$(uname)"=="Darwin" ]];then
@@ -89,6 +135,7 @@ if [[ "$(uname)" == "Darwin" ]]; then
89135
TARGET="${TARGET_DIR}/${DIST_PREFIX}_${GOOS}_${GOARCH}"
90136
echo"build =>${TARGET}"
91137
go build"${GO_BUILD_FLAGS[@]}" -o"${TARGET}" -ldflags"${LD_BASE}"
138+
compress_with_upx"${TARGET}""${GOOS}""${GOARCH}"
92139
done
93140

94141
# 合并 Universal 2(存在 lipo 才合并)

‎.github/workflows/build.yml‎

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,18 @@ jobs:
109109
-name:Get project dependencies
110110
run:go mod download
111111

112+
-name:Install UPX (selected Linux targets)
113+
if:>
114+
matrix.goos == 'linux' && (
115+
matrix.goarch == 'amd64' ||
116+
matrix.goarch == '386' ||
117+
matrix.goarch == 'arm64' ||
118+
(matrix.goarch == 'arm' && matrix.goarm == '7')
119+
)
120+
run:|
121+
sudo apt-get update
122+
sudo apt-get install -y upx
123+
112124
-name:Build
113125
run:|
114126
mkdir -p dist
@@ -117,9 +129,22 @@ jobs:
117129
-X github.com/nxtrace/NTrace-core/config.BuildDate=${BUILD_DATE} \
118130
-X github.com/nxtrace/NTrace-core/config.CommitID=${COMMIT_SHA1} \
119131
-checklinkname=0 -w -s"
132+
if command -v upx >/dev/null 2>&1; then
133+
case "${GOOS}-${GOARCH}-${GOARM:-}" in
134+
linux-amd64-*) upx -9 "dist/${ASSET_NAME}" ;;
135+
linux-386-*) upx -9 "dist/${ASSET_NAME}" ;;
136+
linux-arm64-*) upx -9 "dist/${ASSET_NAME}" ;;
137+
linux-arm-7) upx -9 "dist/${ASSET_NAME}" ;;
138+
*)
139+
echo "skip upx for ${GOOS}/${GOARCH}${GOARM:+/v${GOARM}}"
140+
;;
141+
esac
142+
else
143+
echo "upx not available; skipping compression for ${GOOS}/${GOARCH}${GOARM:+/v${GOARM}}"
144+
fi
120145
121146
-name:Upload artifact
122-
uses:actions/upload-artifact@v4
147+
uses:actions/upload-artifact@v5
123148
with:
124149
name:${{ env.ASSET_NAME }}
125150
path:dist/${{ env.ASSET_NAME }}
@@ -197,7 +222,7 @@ jobs:
197222
-checklinkname=0 -w -s"
198223
199224
-name:Upload artifact
200-
uses:actions/upload-artifact@v4
225+
uses:actions/upload-artifact@v5
201226
with:
202227
name:${{ env.ASSET_NAME }}
203228
path:dist/${{ env.ASSET_NAME }}
@@ -209,7 +234,7 @@ jobs:
209234
needs:[ build-darwin ]
210235
steps:
211236
-name:Download darwin slices (flatten)
212-
uses:actions/download-artifact@v5
237+
uses:actions/download-artifact@v6
213238
with:
214239
pattern:nexttrace_darwin_*
215240
merge-multiple:true
@@ -231,7 +256,7 @@ jobs:
231256
ls -l dist
232257
233258
-name:Upload universal as artifact
234-
uses:actions/upload-artifact@v4
259+
uses:actions/upload-artifact@v5
235260
with:
236261
name:nexttrace_darwin_universal
237262
path:dist/nexttrace_darwin_universal
@@ -244,7 +269,7 @@ jobs:
244269
if:startsWith(github.ref, 'refs/tags/v')
245270
steps:
246271
-name:Download all artifacts (flatten)
247-
uses:actions/download-artifact@v5
272+
uses:actions/download-artifact@v6
248273
with:
249274
pattern:nexttrace_*
250275
merge-multiple:true

‎.gitignore‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,3 +169,6 @@ Temporary Items
169169
dist/
170170

171171
NTrace-core
172+
173+
.gocache
174+
.gomodcache

‎README.md‎

Lines changed: 43 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,11 @@ Please note, there are exceptions to this synchronization. If a version of NTrac
104104
pkg install root-repo
105105
pkg install nexttrace
106106
```
107+
108+
* ImmortalWrt installationcommand
109+
```shell
110+
opkg install nexttrace
111+
```
107112

108113
* macOS
109114
* macOS Homebrew's installation command
@@ -288,7 +293,7 @@ nexttrace --no-color 1.1.1.1
288293
export NO_COLOR=1
289294
```
290295

291-
####`NextTrace` supports users to select their own IP API (currently supports:`LeoMoeAPI`,`IP.SB`,`IPInfo`,`IPInsight`,`IPAPI.com`,`Ip2region`,`IPInfoLocal`,`CHUNZHEN`)
296+
####`NextTrace` supports users to select their own IP API (currently supports:`LeoMoeAPI`,`IP.SB`,`IPInfo`,`IPInsight`,`IPAPI.com`,`IPInfoLocal`,`CHUNZHEN`)
292297

293298
```bash
294299
# You can specify the IP database by yourself [IP-API.com here], if not specified, LeoMoeAPI will be used
@@ -301,7 +306,6 @@ nexttrace --data-provider ip-api.com
301306
## Current directory, nexttrace binary directory and FHS directories (Unix-like) will be searched.
302307
## To customize it, please use environment variables,
303308
export NEXTTRACE_IPINFOLOCALPATH=/xxx/yyy.mmdb
304-
## For the offline database Ip2region, you can download it manually and rename it to ip2region.db, or let NextTrace download it automatically
305309
## Please be aware: Due to the serious abuse of IP.SB, you will often be not able to query IP data from this source
306310
## IP-API.com has a stricter restiction on API calls, if you can't query IP data from this source, please try again in a few minutes
307311

@@ -325,6 +329,23 @@ nexttrace -d ip-api.com -m 20 -T -p 443 -q 5 -n 1.1.1.1
325329
nexttrace -T -q 2 --parallel-requests 1 -t -P 2001:4860:4860::8888
326330
```
327331

332+
###Globalping
333+
334+
[Globalping](https://globalping.io/) provides access to thousands of community-hosted probes to run network tests and measurements.
335+
336+
Run traceroute from a specified location by using the`--from` flag. The location field accepts continents, countries, regions, cities, ASNs, ISPs, or cloud regions.
337+
338+
```bash
339+
nexttrace google.com --from Germany
340+
nexttrace google.com --from comcast+california
341+
```
342+
343+
A limit of 250 tests per hour is set for all anonymous users. To double the limit to 500 per hour please set the`GLOBALPING_TOKEN` environment variable with your token.
344+
345+
```bash
346+
export GLOBALPING_TOKEN=your_token_here
347+
```
348+
328349
###IP Database
329350

330351
We use[bgp.tools](https://bgp.tools) as a data provider for routing tables.
@@ -348,17 +369,18 @@ Usage: nexttrace [-h|--help] [--init] [-4|--ipv4] [-6|--ipv6] [-T|--tcp]
348369
[--icmp-mode<integer>] [-q|--queries<integer>]
349370
[--parallel-requests<integer>] [-m|--max-hops<integer>]
350371
[--max-attempts<integer>] [-d|--data-provider
351-
(Ip2region|ip2region|IP.SB|ip.sb|IPInfo|ipinfo|IPInsight|ipinsight|IPAPI.com|ip-api.com|IPInfoLocal|ipinfolocal|chunzhen|LeoMoeAPI|leomoeapi|ipdb.one|disable-geoip)]
372+
(IP.SB|ip.sb|IPInfo|ipinfo|IPInsight|ipinsight|IPAPI.com|ip-api.com|IPInfoLocal|ipinfolocal|chunzhen|LeoMoeAPI|leomoeapi|ipdb.one|disable-geoip)]
352373
[--pow-provider (api.nxtrace.org|sakura)] [-n|--no-rdns]
353374
[-a|--always-rdns] [-P|--route-path] [-r|--report] [--dn42]
354375
[-o|--output] [-t|--table] [--raw] [-j|--json] [-c|--classic]
355376
[-f|--first<integer>] [-M|--map] [-e|--disable-mpls]
356377
[-V|--version] [-s|--source"<value>"] [--source-port
357-
<integer>] [-D|--dev"<value>"] [-z|--send-time<integer>]
358-
[-i|--ttl-time<integer>] [--timeout<integer>] [--psize
359-
<integer>] [_positionalArg_nexttrace_36"<value>"]
360-
[--dot-server (dnssb|aliyun|dnspod|google|cloudflare)]
361-
[-g|--language (en|cn)] [--file"<value>"] [-C|--no-color]
378+
<integer>] [-D|--dev"<value>"] [--listen"<value>"]
379+
[--deploy] [-z|--send-time<integer>] [-i|--ttl-time
380+
<integer>] [--timeout<integer>] [--psize<integer>]
381+
[_positionalArg_nexttrace_38"<value>"] [--dot-server
382+
(dnssb|aliyun|dnspod|google|cloudflare)] [-g|--language
383+
(en|cn)] [--file"<value>"] [-C|--no-color] [--from"<value>"]
362384

363385
Arguments:
364386

@@ -387,7 +409,7 @@ Arguments:
387409
--max-attempts Set the max number of attempts per TTL
388410
(instead of a fixed auto value)
389411
-d --data-provider Choose IP Geograph Data Provider [IP.SB,
390-
IPInfo, IPInsight, IP-API.com, Ip2region,
412+
IPInfo, IPInsight, IP-API.com,
391413
IPInfoLocal, CHUNZHEN, disable-geoip].
392414
Default: LeoMoeAPI
393415
--pow-provider Choose PoW Provider [api.nxtrace.org,
@@ -419,6 +441,9 @@ Arguments:
419441
packets
420442
-D --dev Use the following Network Devices as the
421443
source addressin outgoing packets
444+
--listen Set listen addressfor web console (e.g.
445+
127.0.0.1:30080)
446+
--deploy Start the Gin powered web console
422447
-z --send-time Set how many [milliseconds] between
423448
sending each packet. Useful when some
424449
routers use rate-limitfor ICMP messages.
@@ -431,13 +456,18 @@ Arguments:
431456
sockets open before giving up on the
432457
connection. Default: 1000
433458
--psize Set the payload size. Default: 52
434-
--_positionalArg_nexttrace_36 IP Address or domain name
459+
--_positionalArg_nexttrace_38 IP Address or domain name
435460
--dot-server Use DoT Serverfor DNS Parse [dnssb,
436461
aliyun, dnspod, google, cloudflare]
437462
-g --language Choose the languagefor displaying [en,
438463
cn]. Default: cn
439464
--file Read IP Address or domain name from file
440465
-C --no-color Disable Colorful Output
466+
--from Run traceroute via Globalping
467+
(https://globalping.io/network) from a
468+
specified location. The location field
469+
accepts continents, countries, regions,
470+
cities, ASNs, ISPs, or cloud regions.
441471
```
442472

443473
##Project screenshot
@@ -511,6 +541,8 @@ This Project uses [JetBrain Open-Source Project License](https://jb.gg/OpenSourc
511541

512542
[PeeringDB](https://www.peeringdb.com) Provided some data support for this project free of charge
513543

544+
[Globalping](https://globalping.io) An open-source and free project that provides global access to run network tests like traceroute
545+
514546
[sjlleo](https://github.com/sjlleo) The perpetual leader, founder, and core contributors
515547

516548
[tsosunchia](https://github.com/tsosunchia) The project chair, infra maintainer, and core contributors
@@ -544,9 +576,8 @@ This Project uses [JetBrain Open-Source Project License](https://jb.gg/OpenSourc
544576
- How to obtain the freshly baked binary executable of the latest commit?
545577
>Please go to the most recent[Build & Release](https://github.com/nxtrace/NTrace-V1/actions/workflows/build.yml) workflow in GitHub Actions.
546578
547-
-Known Issues
579+
-Common questions
548580
+ On Windows, ICMP mode requires manual firewall allowance for ICMP/ICMPv6
549-
+ On Windows, TCP modes are currently unavailable
550581
+ On macOS, only ICMP mode does not require elevated privileges
551582
+ In some cases, running multiple instances of NextTrace simultaneously may interfere with each other’s results (observed so far only in TCP mode)
552583

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp