Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ go.sum
test2
ksubdomain.yaml
dist/
ksubdomain
ksubdomainsimple
advanced
45 changes: 45 additions & 0 deletions agent-log.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@

---

## [2026-03-18] feature/stream-sdk — 所有 roadmap 任务完成

### 本次完成(接昨日进度)

**P2-2 httpx 管道** (commit 44eeef2)
- screen.go 移除所有输出路径的 `\r` 前缀
- 非 silent 时防止 padding 为负值

**P2-3 JSONL 下游兼容** (commit 44eeef2,同一次提交)
- 用 `bufio.Writer`(64 KiB)替换每条 `file.Sync()`
- 提取 `parseAnswers()` 共享函数,beautified.go 也复用
- 新增 AAAA 记录类型检测
- 字段名稳定:`domain` / `type` / `records` / `timestamp`

**P2-4 退出码语义** (commit 21c99a7)
- Runner 新增 `SuccessCount() uint64` 方法
- enum.go / verify.go:SuccessCount==0 时 os.Exit(1)

**P3-1 docs/quickstart.md** (commit a15ba1a)
**P3-2 docs/api.md** (commit a15ba1a)
**P3-3 docs/best-practices.md** (commit a15ba1a)
**P3-4 docs/faq.md** (commit a15ba1a)

**P3-5 内联注释** (commit e8dd7d1)
- RunEnumeration:goroutine 拓扑图
- sendCycleWithContext:批量/背压设计说明

**P3-6 `simple` 二进制** (commit 31d0301)
- 确认是编译产物,加 .gitignore
- examples/simple、examples/advanced 修复旧 API 引用

**P3-7 CI 矩阵** (commit 286460f)
- .github/workflows/ci.yml:5平台构建矩阵 + lint job

**P3-8 版本号自动化** (commit f9d107e)
- Version const → var,支持 ldflags 注入
- build.yml / build.sh 全部加 ldflags

### 结论
**全部 19 项 roadmap 任务已完成。**
- P0(3项):feature/dynamic-timeout 分支
- P1-P3(16项):feature/stream-sdk 分支
28 changes: 24 additions & 4 deletions build.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,24 @@
set CGO_LDFLAGS = "-Wl,-static -L/usr/lib/x86_64-linux-gnu/libpcap.a -lpcap -ldbus-1 -Wl,-Bdynamic"
set GOOS = "linux"
set GOARCH = "amd64"
go build -o ./ksubdomain ./cmd/ksubdomain/
#!/usr/bin/env bash
# build.sh — local cross-compile helper
# Usage: ./build.sh [version]
# version defaults to the output of `git describe --tags --always`

set -e

VERSION="${1:-$(git describe --tags --always 2>/dev/null || echo 'dev')}"
LDFLAGS="-X github.com/boy-hack/ksubdomain/v2/pkg/core/conf.Version=${VERSION}"

echo "Building version: ${VERSION}"

# Linux amd64 (static libpcap required on the build host)
CGO_LDFLAGS="-Wl,-static -L/usr/lib/x86_64-linux-gnu/libpcap.a -lpcap -Wl,-Bdynamic -ldbus-1 -lsystemd" \
GOOS=linux GOARCH=amd64 \
go build -ldflags "${LDFLAGS}" -o ./ksubdomain_linux_amd64 ./cmd/ksubdomain/
echo " -> ksubdomain_linux_amd64"

# Windows amd64 (CGO disabled; npcap is linked at runtime)
GOOS=windows GOARCH=amd64 CGO_ENABLED=0 \
go build -ldflags "${LDFLAGS}" -o ./ksubdomain_windows_amd64.exe ./cmd/ksubdomain/
echo " -> ksubdomain_windows_amd64.exe"

echo "Done."
11 changes: 10 additions & 1 deletion cmd/ksubdomain/enum.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,10 @@ var enumCommand = &cli.Command{
bandwidthValue = c.String("band")
}

// 收集网卡列表(支持重复 --eth 多网卡)
ethNames := c.StringSlice("interface")
etherInfos := options.GetDeviceConfigs(ethNames, defaultResolver)

opt := &options.Options{
Rate: options.Band2Rate(bandwidthValue),
Domain: render,
Expand All @@ -220,9 +224,10 @@ var enumCommand = &cli.Command{
WildcardFilterMode: c.String("wild-filter-mode"),
WildIps: wildIPS,
Predict: c.Bool("predict"),
EtherInfo: etherInfos[0], // 向后兼容
EtherInfos: etherInfos,
}
opt.Check()
opt.EtherInfo = options.GetDeviceConfig(defaultResolver)
ctx := context.Background()
r, err := runner.New(opt)
if err != nil {
Expand All @@ -231,6 +236,10 @@ var enumCommand = &cli.Command{
}
r.RunEnumeration(ctx)
r.Close()
// Exit 1 when nothing resolved — lets shell pipelines use && correctly.
if r.SuccessCount() == 0 {
os.Exit(1)
}
return nil
},
}
18 changes: 14 additions & 4 deletions cmd/ksubdomain/verify.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,11 @@ var commonFlags = []cli.Flag{

// Network interface
// Internationalization: interface (recommended) replaces eth (kept for compatibility)
&cli.StringFlag{
// 支持多次指定(--eth eth0 --eth eth1)以开启多网卡并发发包
&cli.StringSliceFlag{
Name: "interface",
Aliases: []string{"eth", "e", "i"},
Usage: "Network interface name (e.g., eth0, en0, wlan0) [Recommended: use --interface]",
Usage: "Network interface name(s); can be repeated for multi-NIC (e.g. --eth eth0 --eth eth1) [Recommended: use --interface]",
},

// Wildcard filter
Expand Down Expand Up @@ -257,7 +258,11 @@ var verifyCommand = &cli.Command{
// Fallback to old parameter for compatibility
bandwidthValue = c.String("band")
}


// 收集网卡列表(支持重复 --eth 多网卡)
ethNames := c.StringSlice("interface")
etherInfos := options.GetDeviceConfigs(ethNames, resolver)

opt := &options.Options{
Rate: options.Band2Rate(bandwidthValue),
Domain: render,
Expand All @@ -268,7 +273,8 @@ var verifyCommand = &cli.Command{
Method: options.VerifyType,
Writer: writer,
ProcessBar: processBar,
EtherInfo: options.GetDeviceConfig(resolver),
EtherInfo: etherInfos[0], // 向后兼容
EtherInfos: etherInfos,
WildcardFilterMode: c.String("wild-filter-mode"),
Predict: c.Bool("predict"),
}
Expand All @@ -281,6 +287,10 @@ var verifyCommand = &cli.Command{
}
r.RunEnumeration(ctx)
r.Close()
// Exit 1 when nothing resolved — lets shell pipelines use && correctly.
if r.SuccessCount() == 0 {
os.Exit(1)
}
return nil
},
}
Loading
Loading