feat(provider): add custom HTTP headers support for remote providers

Some subscription panels (e.g. Remnawave with incy/happ integration)
require device-identification headers to return the real server list
instead of a dummy config. Add a 'headers' field to the remote provider
options so users can attach arbitrary HTTP headers to subscription
fetch requests.

Signed-off-by: Arsolitt <arsolitt@gmail.com>
This commit is contained in:
Arsolitt
2026-07-01 21:52:16 +03:00
parent a27453e4f7
commit 1e826a201d
3 changed files with 30 additions and 0 deletions

View File

@@ -59,6 +59,7 @@ type ProviderRemote struct {
updateInterval time.Duration
exclude *regexp.Regexp
include *regexp.Regexp
headers http.Header
}
func NewProviderRemote(ctx context.Context, router adapter.Router, logFactory log.Factory, tag string, options option.ProviderRemoteOptions) (adapter.Provider, error) {
@@ -94,6 +95,7 @@ func NewProviderRemote(ctx context.Context, router adapter.Router, logFactory lo
url: options.URL,
userAgent: userAgent,
downloadDetour: options.DownloadDetour,
headers: options.Headers.Build(),
updateInterval: updateInterval,
exclude: (*regexp.Regexp)(options.Exclude),
include: (*regexp.Regexp)(options.Include),
@@ -191,6 +193,9 @@ func (s *ProviderRemote) fetch(ctx context.Context) error {
req.Header.Set("If-None-Match", s.lastEtag)
}
req.Header.Set("User-Agent", s.userAgent)
for name, values := range s.headers {
req.Header[name] = values
}
resp, err := client.Do(req.WithContext(ctx))
if err != nil {
return err