settings

package
v0.0.0-...-a49236d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 16, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadSettings

func LoadSettings(configPath string, settings *Settings) error

LoadSettings -- Load settings from config file.

Types

type BarkNotify

type BarkNotify struct {
	Enabled    bool   `json:"enabled" yaml:"enabled"`
	Server     string `json:"server" yaml:"server"`
	Title      string `json:"title" yaml:"title"`
	Subtitle   string `json:"subtitle" yaml:"subtitle"`
	Body       string `json:"body" yaml:"body"`
	DeviceKeys string `json:"device_keys" yaml:"device_keys"`
	Params     string `json:"params" yaml:"params"`
	User       string `json:"user" yaml:"user"`
	Password   string `json:"password" yaml:"password"`
}

type DiscordNotify

type DiscordNotify struct {
	Enabled         bool   `json:"enabled" yaml:"enabled"`
	BotAPIToken     string `json:"bot_api_token" yaml:"bot_api_token"`
	BotAPITokenFile string `json:"bot_api_token_file" yaml:"bot_api_token_file"`
	Channel         string `json:"channel" yaml:"channel"`
	MsgTemplate     string `json:"message_template" yaml:"message_template"`
}

type Domain

type Domain struct {
	DomainName string   `json:"domain_name" yaml:"domain_name"`
	SubDomains []string `json:"sub_domains" yaml:"sub_domains"`
	Provider   string   `json:"provider,omitempty" yaml:"provider,omitempty"`
}

Domain struct.

type MailNotify

type MailNotify struct {
	Enabled          bool   `json:"enabled" yaml:"enabled"`
	SMTPServer       string `json:"smtp_server" yaml:"smtp_server"`
	SMTPUsername     string `json:"smtp_username" yaml:"smtp_username"`
	SMTPPassword     string `json:"smtp_password" yaml:"smtp_password"`
	SMTPPasswordFile string `json:"smtp_password_file" yaml:"smtp_password_file"`
	SMTPPort         int    `json:"smtp_port" yaml:"smtp_port"`
	SendFrom         string `json:"send_from" yaml:"send_from"`
	SendTo           string `json:"send_to" yaml:"send_to"`
}

MailNotify struct for SMTP notification.

type Mikrotik

type Mikrotik struct {
	Enabled   bool   `json:"enabled" yaml:"enabled"`
	Addr      string `json:"addr" yaml:"addr"`
	Username  string `json:"username" yaml:"username"`
	Password  string `json:"password" yaml:"password"`
	Interface string `json:"interface" yaml:"interface"`
}

type Notify

type Notify struct {
	Telegram TelegramNotify `json:"telegram" yaml:"telegram"`
	Mail     MailNotify     `json:"mail" yaml:"mail"`
	Slack    SlackNotify    `json:"slack" yaml:"slack"`
	Discord  DiscordNotify  `json:"discord" yaml:"discord"`
	Pushover PushoverNotify `json:"pushover" yaml:"pushover"`
	Bark     BarkNotify     `json:"bark" yaml:"bark"`
	Ntfy     NtfyNotify     `json:"ntfy" yaml:"ntfy"`
}

Notify struct.

type NtfyNotify

type NtfyNotify struct {
	Enabled     bool   `json:"enabled" yaml:"enabled"`
	Topic       string `json:"topic" yaml:"topic"`
	Server      string `json:"server" yaml:"server"`
	Token       string `json:"token" yaml:"token"`
	User        string `json:"user" yaml:"user"`
	Password    string `json:"password" yaml:"password"`
	Priority    string `json:"priority" yaml:"priority"`
	Tags        string `json:"tags" yaml:"tags"`
	Icon        string `json:"icon" yaml:"icon"`
	MsgTemplate string `json:"message_template" yaml:"message_template"`
}

NtfyNotify struct for ntfy notification.

type ProviderConfig

type ProviderConfig struct {
	// Common fields across providers
	Email          string `json:"email,omitempty" yaml:"email,omitempty"`
	Password       string `json:"password,omitempty" yaml:"password,omitempty"`
	PasswordFile   string `json:"password_file,omitempty" yaml:"password_file,omitempty"`
	LoginToken     string `json:"login_token,omitempty" yaml:"login_token,omitempty"`
	LoginTokenFile string `json:"login_token_file,omitempty" yaml:"login_token_file,omitempty"`

	// Provider-specific fields
	AppKey      string `json:"app_key,omitempty" yaml:"app_key,omitempty"`
	AppSecret   string `json:"app_secret,omitempty" yaml:"app_secret,omitempty"`
	ConsumerKey string `json:"consumer_key,omitempty" yaml:"consumer_key,omitempty"`
}

ProviderConfig holds provider-specific configuration.

type PushoverNotify

type PushoverNotify struct {
	Enabled     bool   `json:"enabled" yaml:"enabled"`
	Token       string `json:"token" yaml:"token"`
	TokenFile   string `json:"token_file" yaml:"token:_file"`
	User        string `json:"user" yaml:"user"`
	MsgTemplate string `json:"message_template" yaml:"message_template"`
	Device      string `json:"device" yaml:"device"`
	Title       string `json:"title" yaml:"title"`
	Priority    int    `json:"priority" yaml:"priority"`
	HTML        int    `json:"html" yaml:"html"`
}

type Settings

type Settings struct {
	// Legacy single provider fields (for backward compatibility)
	Provider       string `json:"provider" yaml:"provider"`
	Email          string `json:"email" yaml:"email"`
	Password       string `json:"password" yaml:"password"`
	PasswordFile   string `json:"password_file" yaml:"password_file"`
	LoginToken     string `json:"login_token" yaml:"login_token"`
	LoginTokenFile string `json:"login_token_file" yaml:"login_token_file"`
	AppKey         string `json:"app_key" yaml:"app_key"`
	AppSecret      string `json:"app_secret" yaml:"app_secret"`
	ConsumerKey    string `json:"consumer_key" yaml:"consumer_key"`

	// New multi-provider configuration
	Providers map[string]*ProviderConfig `json:"providers,omitempty" yaml:"providers,omitempty"`

	// Domain configuration
	Domains []Domain `json:"domains" yaml:"domains"`

	// Network and IP configuration
	IPUrl          string   `json:"ip_url" yaml:"ip_url"`
	IPUrls         []string `json:"ip_urls" yaml:"ip_urls"`
	IPV6Url        string   `json:"ipv6_url" yaml:"ipv6_url"`
	IPV6Urls       []string `json:"ipv6_urls" yaml:"ipv6_urls"`
	IPInterface    string   `json:"ip_interface" yaml:"ip_interface"`
	QueryInterface string   `json:"query_interface" yaml:"query_interface"`
	AllowPrivate   bool     `json:"allow_private" yaml:"allow_private"`
	IPType         string   `json:"ip_type" yaml:"ip_type"`
	Resolver       string   `json:"resolver" yaml:"resolver"`

	// Application configuration
	Interval      int    `json:"interval" yaml:"interval"`
	UserAgent     string `json:"user_agent,omitempty" yaml:"user_agent,omitempty"`
	Socks5Proxy   string `json:"socks5_proxy" yaml:"socks5_proxy"`
	UseProxy      bool   `json:"use_proxy" yaml:"use_proxy"`
	DebugInfo     bool   `json:"debug_info" yaml:"debug_info"`
	RunOnce       bool   `json:"run_once" yaml:"run_once"`
	Proxied       bool   `json:"proxied" yaml:"proxied"`
	SkipSSLVerify bool   `json:"skip_ssl_verify" yaml:"skip_ssl_verify"`

	// Feature configuration
	Notify   Notify   `json:"notify" yaml:"notify"`
	Webhook  Webhook  `json:"webhook,omitempty" yaml:"webhook,omitempty"`
	Mikrotik Mikrotik `json:"mikrotik" yaml:"mikrotik"`
	WebPanel WebPanel `json:"web_panel" yaml:"web_panel"`
}

Settings struct.

func (*Settings) GetDomainProvider

func (s *Settings) GetDomainProvider(domain *Domain) string

GetDomainProvider returns the provider for a specific domain. Falls back to the global provider if domain doesn't specify one.

func (*Settings) GetProviderConfig

func (s *Settings) GetProviderConfig(providerName string) *ProviderConfig

GetProviderConfig returns the configuration for a specific provider. Falls back to legacy global configuration if provider-specific config is not found.

func (*Settings) IsMultiProvider

func (s *Settings) IsMultiProvider() bool

IsMultiProvider returns true if the configuration uses multiple providers.

func (*Settings) SaveSettings

func (s *Settings) SaveSettings(configPath string) error

type SlackNotify

type SlackNotify struct {
	Enabled         bool   `json:"enabled" yaml:"enabled"`
	BotAPIToken     string `json:"bot_api_token" yaml:"bot_api_token"`
	BotAPITokenFile string `json:"bot_api_token_file" yaml:"bot_api_token_file"`
	Channel         string `json:"channel" yaml:"channel"`
	MsgTemplate     string `json:"message_template" yaml:"message_template"`
}

SlackNotify struct for Slack notification.

type TelegramNotify

type TelegramNotify struct {
	Enabled       bool   `json:"enabled" yaml:"enabled"`
	BotAPIKey     string `json:"bot_api_key" yaml:"bot_api_key"`
	BotAPIKeyFile string `json:"bot_api_key_file" yaml:"bot_api_key_file"`
	ChatID        string `json:"chat_id" yaml:"chat_id"`
	MsgTemplate   string `json:"message_template" yaml:"message_template"`
}

TelegramNotify struct for telegram notification.

type WebPanel

type WebPanel struct {
	Enabled  bool   `json:"enabled" yaml:"enabled"`
	Addr     string `json:"addr" yaml:"addr"`
	Username string `json:"username" yaml:"username"`
	Password string `json:"password" yaml:"password"`
}

type Webhook

type Webhook struct {
	Enabled     bool   `json:"enabled" yaml:"enabled"`
	URL         string `json:"url" yaml:"url"`
	RequestBody string `json:"request_body" yaml:"request_body"`
}

Webhook struct.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL