feat: one registry entry per Site, one shared Series-page read #95
@@ -124,7 +124,13 @@ func (p *Poller) storeCover(ctx context.Context, sr store.Series, sourceURL stri
|
|||||||
// absent, the entry's Fallback decides whether plain TLS may take over. One
|
// absent, the entry's Fallback decides whether plain TLS may take over. One
|
||||||
// routing rule for the poll and the acquirer, so the two cannot drift apart.
|
// routing rule for the poll and the acquirer, so the two cannot drift apart.
|
||||||
func fetcherFor(site string, browser, tls Fetcher) Fetcher {
|
func fetcherFor(site string, browser, tls Fetcher) Fetcher {
|
||||||
s := sites[site]
|
s, known := sites[site]
|
||||||
|
if !known {
|
||||||
|
// No registry entry means nothing to fetch or parse; fail closed even
|
||||||
|
// though the only caller gates first, so a future caller that skips
|
||||||
|
// the gate cannot hand an arbitrary https URL to the TLS fetcher.
|
||||||
|
return nil
|
||||||
|
}
|
||||||
if s.Browser == nil {
|
if s.Browser == nil {
|
||||||
return tls
|
return tls
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -959,6 +959,8 @@ func TestFetcherForRoutesNovelSites(t *testing.T) {
|
|||||||
// browser-less deployment: kagane is nothing, novelfull degrades to TLS
|
// browser-less deployment: kagane is nothing, novelfull degrades to TLS
|
||||||
{"kagane", nil, tls, nil},
|
{"kagane", nil, tls, nil},
|
||||||
{"novelfull", nil, tls, tls},
|
{"novelfull", nil, tls, tls},
|
||||||
|
// unknown site: fail closed — nothing to fetch or parse
|
||||||
|
{"mangadex", browser, tls, nil},
|
||||||
}
|
}
|
||||||
for _, tc := range cases {
|
for _, tc := range cases {
|
||||||
t.Run(tc.site, func(t *testing.T) {
|
t.Run(tc.site, func(t *testing.T) {
|
||||||
|
|||||||
Reference in New Issue
Block a user