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

@@ -13,7 +13,7 @@ func TestParseArgs(t *testing.T) {
wantVal map[string]string
uris []string
}{
{"short attached", []string{"-x16", "https://e.com"}, Run, map[string]string{"max-connection-per-server": "16"}, []string{"https://e.com"}},
{"short attached", []string{"-m3", "https://e.com"}, Run, map[string]string{"max-tries": "3"}, []string{"https://e.com"}},
{"long equals + bool", []string{"--split=8", "-c", "u"}, Run, map[string]string{"split": "8", "continue": "true"}, []string{"u"}},
{"long separate value", []string{"--out", "f.bin", "u"}, Run, map[string]string{"out": "f.bin"}, []string{"u"}},
{"bool bundle", []string{"-cq", "u"}, Run, map[string]string{"continue": "true", "quiet": "true"}, []string{"u"}},
@@ -22,7 +22,7 @@ func TestParseArgs(t *testing.T) {
{"permute flag after uri", []string{"u", "--split=8"}, Run, map[string]string{"split": "8"}, []string{"u"}},
{"permute interleaved", []string{"a", "-c", "b", "--quiet"}, Run, map[string]string{"continue": "true", "quiet": "true"}, []string{"a", "b"}},
{"dash dash terminator", []string{"--split=8", "--", "--not-a-flag", "u"}, Run, map[string]string{"split": "8"}, []string{"--not-a-flag", "u"}},
{"long int + magnet uri", []string{"--bt-stop-timeout=120", "magnet:x"}, Run, map[string]string{"bt-stop-timeout": "120"}, []string{"magnet:x"}},
{"long int + magnet uri", []string{"--timeout=120", "magnet:x"}, Run, map[string]string{"timeout": "120"}, []string{"magnet:x"}},
{"help", []string{"--help"}, ShowHelp, nil, nil},
{"help short", []string{"-h"}, ShowHelp, nil, nil},
{"version", []string{"-v"}, ShowVersion, nil, nil},
@@ -95,13 +95,18 @@ func TestParseSize(t *testing.T) {
}
func TestParseValueRange(t *testing.T) {
x := byLong["max-connection-per-server"]
if _, err := parseValue(x, "16"); err != nil {
// A synthetic bounded Int exercises the Min/Max range check independent of
// which options happen to carry bounds.
o := &Opt{Long: "n", Kind: Int, Min: 1, Max: 16}
if _, err := parseValue(o, "16"); err != nil {
t.Errorf("parseValue 16: %v", err)
}
if _, err := parseValue(x, "99"); err == nil {
if _, err := parseValue(o, "99"); err == nil {
t.Errorf("parseValue 99: want out-of-range error")
}
if _, err := parseValue(o, "0"); err == nil {
t.Errorf("parseValue 0: want below-minimum error")
}
a := byLong["file-allocation"]
if _, err := parseValue(a, "bogus"); err == nil {
t.Errorf("parseValue enum bogus: want error")
@@ -156,17 +161,17 @@ func TestParseValueBool(t *testing.T) {
}
func TestParseValueSizeBounds(t *testing.T) {
k := byLong["min-split-size"] // 1M..1024M (no G unit)
k := &Opt{Long: "sz", Kind: Size, Min: 1 << 20, Max: 1 << 30} // 1M..1024M
if _, err := parseValue(k, "20M"); err != nil {
t.Errorf("parseValue min-split-size 20M: %v", err)
t.Errorf("parseValue 20M: %v", err)
}
if _, err := parseValue(k, "512K"); err == nil {
t.Errorf("parseValue min-split-size 512K: want below-minimum error")
t.Errorf("parseValue 512K: want below-minimum error")
}
// 1025M exceeds the 1<<30 cap and still parses, so it tests the bounds path
// (where "2G" would have failed earlier as an unknown unit).
if _, err := parseValue(k, "1025M"); err == nil {
t.Errorf("parseValue min-split-size 1025M: want above-maximum error")
t.Errorf("parseValue 1025M: want above-maximum error")
}
}
@@ -204,7 +209,7 @@ func TestExplicitConfMissingFatal(t *testing.T) {
func TestOptionsGetters(t *testing.T) {
o := newOptions()
o.vals["split"] = "8"
o.vals["min-split-size"] = "20M"
o.vals["max-overall-download-limit"] = "20M"
o.vals["continue"] = "true"
o.vals["seed-ratio"] = "1.5"
if err := o.finalize(); err != nil { // parse the raw values once, as Parse does
@@ -213,8 +218,8 @@ func TestOptionsGetters(t *testing.T) {
if o.Int("split") != 8 {
t.Errorf("Int split = %d", o.Int("split"))
}
if o.Size("min-split-size") != 20<<20 {
t.Errorf("Size min-split-size = %d", o.Size("min-split-size"))
if o.Size("max-overall-download-limit") != 20<<20 {
t.Errorf("Size max-overall-download-limit = %d", o.Size("max-overall-download-limit"))
}
if !o.Bool("continue") {
t.Errorf("Bool continue = false")