Skip to content

Commit

Permalink
Merge pull request #243 from nxtrace/main
Browse files Browse the repository at this point in the history
SYNC
  • Loading branch information
tsosunchia authored May 30, 2024
2 parents 94372d9 + d0fb43e commit e4fa907
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 3 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.22'
check-latest: true
go-version: '1.22.0'
- name: Checkout codebase
uses: actions/checkout@v4
- name: Test with unix
Expand Down
3 changes: 3 additions & 0 deletions cmd/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ func Excute() {
Help: "Choose the language for displaying [en, cn]"})
file := parser.String("", "file", &argparse.Options{Help: "Read IP Address or domain name from file"})
nocolor := parser.Flag("C", "nocolor", &argparse.Options{Help: "Disable Colorful Output"})
dontFragment := parser.Flag("", "dont-fragment", &argparse.Options{Default: false, Help: "Set the Don't Fragment bit (IPv4 TCP only)"})

err := parser.Parse(os.Args)
if err != nil {
Expand Down Expand Up @@ -112,6 +113,7 @@ func Excute() {
PktSize: *packetSize,
Timeout: time.Duration(*timeout) * time.Millisecond,
File: *file,
DontFragment: *dontFragment,
}

fastTrace.FastTest(*tcp, *output, paramsFastTrace)
Expand Down Expand Up @@ -270,6 +272,7 @@ func Excute() {
IPGeoSource: ipgeo.GetSource(*dataOrigin),
Timeout: time.Duration(*timeout) * time.Millisecond,
PktSize: *packetSize,
DontFragment: *dontFragment,
}

// 暂时弃用
Expand Down
1 change: 1 addition & 0 deletions fast_trace/fast_trace ipv6.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ func (f *FastTracer) tracert_v6(location string, ispCollection ISPCollection) {
SrcAddr: f.ParamsFastTrace.SrcAddr,
PktSize: f.ParamsFastTrace.PktSize,
Lang: f.ParamsFastTrace.Lang,
DontFragment: f.ParamsFastTrace.DontFragment,
}

if oe {
Expand Down
2 changes: 2 additions & 0 deletions fast_trace/fast_trace.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ type ParamsFastTrace struct {
PktSize int
Timeout time.Duration
File string
DontFragment bool
}

type IpListElement struct {
Expand Down Expand Up @@ -68,6 +69,7 @@ func (f *FastTracer) tracert(location string, ispCollection ISPCollection) {
SrcAddr: f.ParamsFastTrace.SrcAddr,
PktSize: f.ParamsFastTrace.PktSize,
Lang: f.ParamsFastTrace.Lang,
DontFragment: f.ParamsFastTrace.DontFragment,
}

if oe {
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/nxtrace/NTrace-core

go 1.22
go 1.22.0

require (
github.com/akamensky/argparse v1.4.0
Expand Down
3 changes: 3 additions & 0 deletions trace/tcp_ipv4.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,9 @@ func (t *TCPTracer) send(ttl int) error {
TTL: uint8(ttl),
//Flags: layers.IPv4DontFragment, // 我感觉没必要
}
if t.DontFragment {
ipHeader.Flags = layers.IPv4DontFragment
}
// 使用Uint16兼容32位系统,防止在rand的时候因使用int32而溢出
sequenceNumber := uint32(r.Intn(math.MaxUint16))
tcpHeader := &layers.TCP{
Expand Down
2 changes: 2 additions & 0 deletions trace/trace.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ type Config struct {
AsyncPrinter func(res *Result)
PktSize int
Maptrace bool
DontFragment bool
}

type Method string
Expand Down Expand Up @@ -81,6 +82,7 @@ func Traceroute(method Method, config Config) (*Result, error) {
if config.DestIP.To4() != nil {
tracer = &UDPTracer{Config: config}
} else {
//TODO: IPv6 UDP trace 在做了,指新建文件夹(
return nil, errors.New("IPv6 UDP Traceroute is not supported")
}
case TCPTrace:
Expand Down

0 comments on commit e4fa907

Please sign in to comment.