@@ -90,15 +90,15 @@ type BarkNotify struct {
9090 Password string `json:"password" yaml:"password"`
9191}
9292
93- // ProviderConfig holds provider-specific configuration
93+ // ProviderConfig holds provider-specific configuration.
9494type ProviderConfig struct {
9595 // Common fields across providers
9696 Email string `json:"email,omitempty" yaml:"email,omitempty"`
9797 Password string `json:"password,omitempty" yaml:"password,omitempty"`
9898 PasswordFile string `json:"password_file,omitempty" yaml:"password_file,omitempty"`
9999 LoginToken string `json:"login_token,omitempty" yaml:"login_token,omitempty"`
100100 LoginTokenFile string `json:"login_token_file,omitempty" yaml:"login_token_file,omitempty"`
101-
101+
102102 // Provider-specific fields
103103 AppKey string `json:"app_key,omitempty" yaml:"app_key,omitempty"`
104104 AppSecret string `json:"app_secret,omitempty" yaml:"app_secret,omitempty"`
@@ -140,46 +140,46 @@ type Mikrotik struct {
140140// Settings struct.
141141type Settings struct {
142142 // Legacy single provider fields (for backward compatibility)
143- Provider string `json:"provider" yaml:"provider"`
144- Email string `json:"email" yaml:"email"`
145- Password string `json:"password" yaml:"password"`
146- PasswordFile string `json:"password_file" yaml:"password_file"`
147- LoginToken string `json:"login_token" yaml:"login_token"`
148- LoginTokenFile string `json:"login_token_file" yaml:"login_token_file"`
149- AppKey string `json:"app_key" yaml:"app_key"`
150- AppSecret string `json:"app_secret" yaml:"app_secret"`
151- ConsumerKey string `json:"consumer_key" yaml:"consumer_key"`
152-
143+ Provider string `json:"provider" yaml:"provider"`
144+ Email string `json:"email" yaml:"email"`
145+ Password string `json:"password" yaml:"password"`
146+ PasswordFile string `json:"password_file" yaml:"password_file"`
147+ LoginToken string `json:"login_token" yaml:"login_token"`
148+ LoginTokenFile string `json:"login_token_file" yaml:"login_token_file"`
149+ AppKey string `json:"app_key" yaml:"app_key"`
150+ AppSecret string `json:"app_secret" yaml:"app_secret"`
151+ ConsumerKey string `json:"consumer_key" yaml:"consumer_key"`
152+
153153 // New multi-provider configuration
154- Providers map [string ]* ProviderConfig `json:"providers,omitempty" yaml:"providers,omitempty"`
155-
154+ Providers map [string ]* ProviderConfig `json:"providers,omitempty" yaml:"providers,omitempty"`
155+
156156 // Domain configuration
157- Domains []Domain `json:"domains" yaml:"domains"`
158-
159- // Network and IP configuration
160- IPUrl string `json:"ip_url" yaml:"ip_url"`
161- IPUrls []string `json:"ip_urls" yaml:"ip_urls"`
162- IPV6Url string `json:"ipv6_url" yaml:"ipv6_url"`
163- IPV6Urls []string `json:"ipv6_urls" yaml:"ipv6_urls"`
164- IPInterface string `json:"ip_interface" yaml:"ip_interface"`
165- IPType string `json:"ip_type" yaml:"ip_type"`
166- Resolver string `json:"resolver" yaml:"resolver"`
167-
157+ Domains []Domain `json:"domains" yaml:"domains"`
158+
159+ // Network and IP configuration
160+ IPUrl string `json:"ip_url" yaml:"ip_url"`
161+ IPUrls []string `json:"ip_urls" yaml:"ip_urls"`
162+ IPV6Url string `json:"ipv6_url" yaml:"ipv6_url"`
163+ IPV6Urls []string `json:"ipv6_urls" yaml:"ipv6_urls"`
164+ IPInterface string `json:"ip_interface" yaml:"ip_interface"`
165+ IPType string `json:"ip_type" yaml:"ip_type"`
166+ Resolver string `json:"resolver" yaml:"resolver"`
167+
168168 // Application configuration
169- Interval int `json:"interval" yaml:"interval"`
170- UserAgent string `json:"user_agent,omitempty" yaml:"user_agent,omitempty"`
171- Socks5Proxy string `json:"socks5_proxy" yaml:"socks5_proxy"`
172- UseProxy bool `json:"use_proxy" yaml:"use_proxy"`
173- DebugInfo bool `json:"debug_info" yaml:"debug_info"`
174- RunOnce bool `json:"run_once" yaml:"run_once"`
175- Proxied bool `json:"proxied" yaml:"proxied"`
176- SkipSSLVerify bool `json:"skip_ssl_verify" yaml:"skip_ssl_verify"`
177-
169+ Interval int `json:"interval" yaml:"interval"`
170+ UserAgent string `json:"user_agent,omitempty" yaml:"user_agent,omitempty"`
171+ Socks5Proxy string `json:"socks5_proxy" yaml:"socks5_proxy"`
172+ UseProxy bool `json:"use_proxy" yaml:"use_proxy"`
173+ DebugInfo bool `json:"debug_info" yaml:"debug_info"`
174+ RunOnce bool `json:"run_once" yaml:"run_once"`
175+ Proxied bool `json:"proxied" yaml:"proxied"`
176+ SkipSSLVerify bool `json:"skip_ssl_verify" yaml:"skip_ssl_verify"`
177+
178178 // Feature configuration
179- Notify Notify `json:"notify" yaml:"notify"`
180- Webhook Webhook `json:"webhook,omitempty" yaml:"webhook,omitempty"`
181- Mikrotik Mikrotik `json:"mikrotik" yaml:"mikrotik"`
182- WebPanel WebPanel `json:"web_panel" yaml:"web_panel"`
179+ Notify Notify `json:"notify" yaml:"notify"`
180+ Webhook Webhook `json:"webhook,omitempty" yaml:"webhook,omitempty"`
181+ Mikrotik Mikrotik `json:"mikrotik" yaml:"mikrotik"`
182+ WebPanel WebPanel `json:"web_panel" yaml:"web_panel"`
183183}
184184
185185// LoadSettings -- Load settings from config file.
@@ -341,16 +341,16 @@ func readSecretFromFile(source, value string) (string, error) {
341341 return strings .TrimSpace (string (content )), nil
342342}
343343
344- // GetProviderConfig returns the configuration for a specific provider
345- // Falls back to legacy global configuration if provider-specific config is not found
344+ // GetProviderConfig returns the configuration for a specific provider.
345+ // Falls back to legacy global configuration if provider-specific config is not found.
346346func (s * Settings ) GetProviderConfig (providerName string ) * ProviderConfig {
347347 // If providers map exists and has the specific provider
348348 if s .Providers != nil {
349349 if providerConfig , exists := s .Providers [providerName ]; exists {
350350 return providerConfig
351351 }
352352 }
353-
353+
354354 // Fall back to legacy global configuration
355355 return & ProviderConfig {
356356 Email : s .Email ,
@@ -364,29 +364,29 @@ func (s *Settings) GetProviderConfig(providerName string) *ProviderConfig {
364364 }
365365}
366366
367- // GetDomainProvider returns the provider for a specific domain
368- // Falls back to the global provider if domain doesn't specify one
367+ // GetDomainProvider returns the provider for a specific domain.
368+ // Falls back to the global provider if domain doesn't specify one.
369369func (s * Settings ) GetDomainProvider (domain * Domain ) string {
370370 if domain .Provider != "" {
371371 return domain .Provider
372372 }
373373 return s .Provider
374374}
375375
376- // IsMultiProvider returns true if the configuration uses multiple providers
376+ // IsMultiProvider returns true if the configuration uses multiple providers.
377377func (s * Settings ) IsMultiProvider () bool {
378378 return len (s .Providers ) > 0
379379}
380380
381- // loadProviderSecretsFromFile loads secrets from files for provider-specific configurations
381+ // loadProviderSecretsFromFile loads secrets from files for provider-specific configurations.
382382func loadProviderSecretsFromFile (settings * Settings ) error {
383383 if settings .Providers == nil {
384384 return nil
385385 }
386386
387387 for providerName , config := range settings .Providers {
388388 var err error
389-
389+
390390 if config .Password , err = readSecretFromFile (
391391 config .PasswordFile ,
392392 config .Password ,
@@ -401,6 +401,6 @@ func loadProviderSecretsFromFile(settings *Settings) error {
401401 return fmt .Errorf ("failed to load login token from file for provider %s: %w" , providerName , err )
402402 }
403403 }
404-
404+
405405 return nil
406406}
0 commit comments