PostgreSQL backup tool with Point-In-Time-Recovery and restore verification
TypeScript backupbackupsdatabasedatabase-backupdevopsdockergolangkubernetesmariadbmongodbmysqlpgpostgrespostgresqls3self-hostedsystem-administrationtoolsweb-ui
add HTTP proxy settings
Грицик Евгений961448607c24
diff --git a/backend/internal/features/notifiers/models/telegram/model.go b/backend/internal/features/notifiers/models/telegram/model.goindex 2d64d1bd..973e1a52 100644--- a/backend/internal/features/notifiers/models/telegram/model.go+++ b/backend/internal/features/notifiers/models/telegram/model.go@@ -10,6 +10,7 @@ import ("net/url""strconv""strings"+ "time""github.com/google/uuid"@@ -17,10 +18,13 @@ import ()type TelegramNotifier struct {- NotifierID uuid.UUID `json:"notifierId" gorm:"primaryKey;column:notifier_id"`- BotToken string `json:"botToken" gorm:"not null;column:bot_token"`- TargetChatID string `json:"targetChatId" gorm:"not null;column:target_chat_id"`- ThreadID *int64 `json:"threadId" gorm:"column:thread_id"`+ NotifierID uuid.UUID `json:"notifierId" gorm:"primaryKey;column:notifier_id"`+ BotToken string `json:"botToken" gorm:"not null;column:bot_token"`+ TargetChatID string `json:"targetChatId" gorm:"not null;column:target_chat_id"`+ ThreadID *int64 `json:"threadId" gorm:"column:thread_id"`+ IsHTTPProxyEnabled bool `json:"isHttpProxyEnabled" gorm:"column:is_http_proxy_enabled;type:boolean;not null;default:false"`+ HTTPProxyURL string `json:"httpProxyUrl" gorm:"column:http_proxy_url;type:text"`+ HasHTTPProxyURL bool `json:"hasHttpProxyUrl" gorm:"-"`}func (t *TelegramNotifier) TableName() string {@@ -36,6 +40,22 @@ func (t *TelegramNotifier) Validate(encryptor encryption.FieldEncryptor) error {return errors.New("target chat ID is required")}+ if t.IsHTTPProxyEnabled {+ if t.HTTPProxyURL == "" {+ return errors.New("HTTP proxy URL is required")+ }++ proxyURL, err := encryptor.Decrypt(t.HTTPProxyURL)+ if err != nil {+ return fmt.Errorf("failed to decrypt HTTP proxy URL: %w", err)+ }++ parsedProxyURL, err := url.Parse(proxyURL)+ if err != nil || parsedProxyURL.Scheme != "http" || parsedProxyURL.Host == "" {+ return errors.New("HTTP proxy URL must be a valid http:// URL")+ }+ }+return nil}@@ -73,7 +93,11 @@ func (t *TelegramNotifier) Send(req.Header.Set("Content-Type", "application/x-www-form-urlencoded")- client := &http.Client{}+ client, err := t.buildHTTPClient(encryptor)+ if err != nil {+ return err+ }+resp, err := client.Do(req)if err != nil {return fmt.Errorf("failed to send telegram message: %w", err)@@ -94,13 +118,50 @@ func (t *TelegramNotifier) Send(return nil}+func (t *TelegramNotifier) buildHTTPClient(+ encryptor encryption.FieldEncryptor,+) (*http.Client, error) {+ client := &http.Client{+ Timeout: 30 * time.Second,+ }++ if !t.IsHTTPProxyEnabled {+ return client, nil+ }++ proxyURL, err := encryptor.Decrypt(t.HTTPProxyURL)+ if err != nil {+ return nil, fmt.Errorf("failed to decrypt HTTP proxy URL: %w", err)+ }++ parsedProxyURL, err := url.Parse(proxyURL)+ if err != nil || parsedProxyURL.Scheme != "http" || parsedProxyURL.Host == "" {+ return nil, errors.New("HTTP proxy URL must be a valid http:// URL")+ }++ transport := http.DefaultTransport.(*http.Transport).Clone()+ transport.Proxy = http.ProxyURL(parsedProxyURL)+ client.Transport = transport++ return client, nil+}+func (t *TelegramNotifier) HideSensitiveData() {t.BotToken = ""+ t.HasHTTPProxyURL = t.IsHTTPProxyEnabled && t.HTTPProxyURL != ""+ t.HTTPProxyURL = ""}func (t *TelegramNotifier) Update(incoming *TelegramNotifier) {t.TargetChatID = incoming.TargetChatIDt.ThreadID = incoming.ThreadID+ t.IsHTTPProxyEnabled = incoming.IsHTTPProxyEnabled++ if !incoming.IsHTTPProxyEnabled {+ t.HTTPProxyURL = ""+ } else if incoming.HTTPProxyURL != "" {+ t.HTTPProxyURL = incoming.HTTPProxyURL+ }if incoming.BotToken != "" {t.BotToken = incoming.BotToken@@ -115,5 +176,16 @@ func (t *TelegramNotifier) EncryptSensitiveData(encryptor encryption.FieldEncryp}t.BotToken = encrypted}++ if !t.IsHTTPProxyEnabled {+ t.HTTPProxyURL = ""+ } else if t.HTTPProxyURL != "" {+ encrypted, err := encryptor.Encrypt(t.HTTPProxyURL)+ if err != nil {+ return fmt.Errorf("failed to encrypt HTTP proxy URL: %w", err)+ }+ t.HTTPProxyURL = encrypted+ }+return nil}diff --git a/backend/migrations/20260526120000_add_telegram_http_proxy.sql b/backend/migrations/20260526120000_add_telegram_http_proxy.sqlnew file mode 100644index 00000000..51432d55--- /dev/null+++ b/backend/migrations/20260526120000_add_telegram_http_proxy.sql@@ -0,0 +1,17 @@+-- +goose Up+-- +goose StatementBegin++ALTER TABLE telegram_notifiers+ ADD COLUMN is_http_proxy_enabled BOOLEAN NOT NULL DEFAULT FALSE,+ ADD COLUMN http_proxy_url TEXT;++-- +goose StatementEnd++-- +goose Down+-- +goose StatementBegin++ALTER TABLE telegram_notifiers+ DROP COLUMN IF EXISTS http_proxy_url,+ DROP COLUMN IF EXISTS is_http_proxy_enabled;++-- +goose StatementEnddiff --git a/frontend/src/entity/notifiers/models/telegram/TelegramNotifier.ts b/frontend/src/entity/notifiers/models/telegram/TelegramNotifier.tsindex b2a58f00..b40d8ec8 100644--- a/frontend/src/entity/notifiers/models/telegram/TelegramNotifier.ts+++ b/frontend/src/entity/notifiers/models/telegram/TelegramNotifier.ts@@ -2,6 +2,9 @@ export interface TelegramNotifier {botToken: string;targetChatId: string;threadId?: number;+ isHttpProxyEnabled?: boolean;+ httpProxyUrl?: string;+ hasHttpProxyUrl?: boolean;// temp fieldisSendToThreadEnabled?: boolean;diff --git a/frontend/src/features/notifiers/ui/edit/notifiers/EditTelegramNotifierComponent.tsx b/frontend/src/features/notifiers/ui/edit/notifiers/EditTelegramNotifierComponent.tsxindex 9c293e72..6764224a 100644--- a/frontend/src/features/notifiers/ui/edit/notifiers/EditTelegramNotifierComponent.tsx+++ b/frontend/src/features/notifiers/ui/edit/notifiers/EditTelegramNotifierComponent.tsx@@ -116,6 +116,71 @@ export function EditTelegramNotifierComponent({ notifier, setNotifier, setUnsave)}</div>+ <div className="mt-4 mb-1 flex w-full flex-col items-start sm:flex-row sm:items-center">+ <div className="mb-1 min-w-[150px] sm:mb-0">Use HTTP proxy</div>+ <div className="flex items-center">+ <Switch+ checked={notifier?.telegramNotifier?.isHttpProxyEnabled || false}+ onChange={(checked) => {+ if (!notifier?.telegramNotifier) return;++ setNotifier({+ ...notifier,+ telegramNotifier: {+ ...notifier.telegramNotifier,+ isHttpProxyEnabled: checked,+ httpProxyUrl: checked ? notifier.telegramNotifier.httpProxyUrl : undefined,+ hasHttpProxyUrl: checked ? notifier.telegramNotifier.hasHttpProxyUrl : false,+ },+ });+ setUnsaved();+ }}+ size="small"+ />++ <Tooltip className="cursor-pointer" title="Use HTTP proxy for Telegram API requests">+ <InfoCircleOutlined className="ml-2" style={{ color: 'gray' }} />+ </Tooltip>+ </div>+ </div>++ {notifier?.telegramNotifier?.isHttpProxyEnabled && (+ <div className="mb-1 flex w-full flex-col items-start sm:flex-row sm:items-center">+ <div className="mb-1 min-w-[150px] sm:mb-0">HTTP proxy URL</div>+ <div className="flex items-center">+ <Input.Password+ value={notifier?.telegramNotifier?.httpProxyUrl || ''}+ onChange={(e) => {+ if (!notifier?.telegramNotifier) return;++ setNotifier({+ ...notifier,+ telegramNotifier: {+ ...notifier.telegramNotifier,+ httpProxyUrl: e.target.value.trim(),+ },+ });+ setUnsaved();+ }}+ size="small"+ className="w-full max-w-[250px]"+ placeholder={+ notifier.telegramNotifier.hasHttpProxyUrl+ ? 'Configured'+ : 'http://proxy.example.com:3128'+ }+ />++ <Tooltip+ className="cursor-pointer"+ title="Proxy URL must start with http:// and may include username and password"+ >+ <InfoCircleOutlined className="ml-2" style={{ color: 'gray' }} />+ </Tooltip>+ </div>+ </div>+ )}+<div className="mt-4 mb-1 flex w-full flex-col items-start sm:flex-row sm:items-center"><div className="mb-1 min-w-[150px] sm:mb-0">Send to group topic</div><div className="flex items-center">diff --git a/frontend/src/features/notifiers/ui/show/notifier/ShowTelegramNotifierComponent.tsx b/frontend/src/features/notifiers/ui/show/notifier/ShowTelegramNotifierComponent.tsxindex 821b7cb5..3f1784db 100644--- a/frontend/src/features/notifiers/ui/show/notifier/ShowTelegramNotifierComponent.tsx+++ b/frontend/src/features/notifiers/ui/show/notifier/ShowTelegramNotifierComponent.tsx@@ -24,6 +24,13 @@ export function ShowTelegramNotifierComponent({ notifier }: Props) {{notifier.telegramNotifier.threadId}</div>)}++ {notifier?.telegramNotifier?.isHttpProxyEnabled && (+ <div className="mb-1 flex items-center">+ <div className="min-w-[110px]">HTTP proxy</div>+ Enabled+ </div>+ )}</>);}