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:
@@ -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}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user