feat(netproxy): add network proxy module to provide unified network proxy connection.

feat(internal/controller): make email, ntft, webhook, qq_napcat able to use network proxy.
This commit is contained in:
2026-08-12 22:53:23 +08:00
parent 105fa47811
commit 56cc3485a7
7 changed files with 243 additions and 55 deletions
+8
View File
@@ -6,6 +6,7 @@ import (
gomail "gopkg.in/mail.v2"
"nukumizu-backend/config"
"nukumizu-backend/internal/netproxy"
"nukumizu-backend/internal/node"
"nukumizu-backend/internal/template"
"nukumizu-backend/postLog"
@@ -18,6 +19,13 @@ type EmailController struct {
// NewEmailController creates a new Email controller.
func NewEmailController(cfg config.EmailConfig) *EmailController {
if cfg.NetworkUseProxy {
// Route SMTP through the HTTP CONNECT proxy. NetDialTimeout is
// gomail's documented hook for overriding how the SMTP connection is
// dialed. There is a single global email channel, so overriding it
// unconditionally when the flag is set is safe.
gomail.NetDialTimeout = netproxy.DialWithTimeout(true)
}
return &EmailController{cfg: cfg}
}