all: cut bloated HTTP-client and tuning options

This is a personal torrent client, not a web client or daemon, so the
rarely-used HTTP-client knobs and redundant tuning flags are gone — flag,
config field, implementation, and tests removed for each. The option
surface drops from 54 to 28.

Web-client cluster removed: --all-proxy (HTTP_PROXY env still works),
load/save-cookies, --referer, -U/--user-agent, --http-user/--http-passwd,
--conditional-get, --remote-time, --check-certificate, --ca-certificate,
--lowest-speed-limit. Pass --header for a one-off auth/cookie/UA header.

Redundant knobs removed: -x and -k (folded into -s), --connect-timeout,
--retry-wait, per-item --max-download-limit/-u, --bt-max-peers,
--bt-stop-timeout, --disable-ipv6, --auto-save-interval, --human-readable,
--stop, -T (a positional .torrent works). follow-torrent and human-readable
are now unconditional defaults.
This commit is contained in:
2026-06-22 08:30:12 +09:00
parent 2afcb861e4
commit cf9082ff72
15 changed files with 157 additions and 1053 deletions

View File

@@ -30,25 +30,24 @@ func TestMirrorPick(t *testing.T) {
}
}
// TestMaxConns checks the connection ceiling min(split, mirrors*x), floored
// at 1, since that decides how many segment workers fan out.
// TestMaxConns checks the connection ceiling: --split segment workers, floored
// at 1. Mirrors are alternate sources, not extra connections, so they do not
// raise the count.
func TestMaxConns(t *testing.T) {
cases := []struct{ split, x, mirrors, want int }{
{5, 1, 1, 1}, // default -x1 -s5: one connection
{5, 16, 1, 5}, // split is the ceiling on one server
{16, 16, 1, 16},
{5, 1, 3, 3}, // 3 mirrors * 1 per host < split
{16, 2, 3, 6}, // 3 mirrors * 2 per host < split
{0, 1, 1, 1}, // floor at 1
cases := []struct{ split, mirrors, want int }{
{5, 1, 5}, // split is the connection count on one server
{16, 1, 16},
{5, 3, 5}, // 3 mirrors, still split connections
{0, 1, 1}, // floor at 1
}
for _, c := range cases {
uris := make([]string, c.mirrors)
for i := range uris {
uris[i] = "http://h/x"
}
d := New(uris, Config{Split: c.split, MaxConnPerServer: c.x})
d := New(uris, Config{Split: c.split})
if d.maxConns != c.want {
t.Errorf("split=%d x=%d mirrors=%d: maxConns=%d, want %d", c.split, c.x, c.mirrors, d.maxConns, c.want)
t.Errorf("split=%d mirrors=%d: maxConns=%d, want %d", c.split, c.mirrors, d.maxConns, c.want)
}
}
}
@@ -77,8 +76,7 @@ func TestMirrorFallback(t *testing.T) {
// Primary is healthy (so the probe anchors size/validators), bad is a mirror
// that 404s every segment it's handed.
d := New([]string{good.URL + "/f.bin", bad.URL + "/f.bin"}, Config{
Dir: dir, Out: "f.bin", Split: 4, MaxConnPerServer: 2, MinSplit: 1,
Tries: 1, UserAgent: "got-test",
Dir: dir, Out: "f.bin", Split: 4, MinSplit: 1, Tries: 1,
})
if err := d.Run(context.Background()); err != nil {
t.Fatalf("Run with a 404 mirror should still complete via the healthy one: %v", err)
@@ -121,8 +119,7 @@ func TestMirrorDivergentRejected(t *testing.T) {
dir := t.TempDir()
out := filepath.Join(dir, "f.bin")
d := New([]string{primary.URL + "/f.bin", div.URL + "/f.bin"}, Config{
Dir: dir, Out: "f.bin", Split: 4, MaxConnPerServer: 2, MinSplit: 1,
Tries: 1, UserAgent: "got-test",
Dir: dir, Out: "f.bin", Split: 4, MinSplit: 1, Tries: 1,
})
if err := d.Run(context.Background()); err != nil {
t.Fatalf("Run: %v", err)