Documentation
¶
Overview ¶
Package outbound 提供带 SSRF 防护的出站 HTTP 客户端与 URL 校验。
主程序的通知、监控与部署插件共用同一套规则:公网目标允许 HTTP/HTTPS, 但拒绝云元数据、链路本地与保留网段;拨号阶段会重新校验解析结果, 避免 DNS 重绑定绕过配置阶段的检查。
Index ¶
- func DialSafe(ctx context.Context, network, address string) (net.Conn, error)
- func NewClient(timeout time.Duration, skipVerify bool) *http.Client
- func RedactURL(raw string) string
- func SafeError(err error) string
- func SanitizeErrorText(text string) string
- func ValidateServiceURL(raw string) error
- func ValidateURL(raw string) error
- func ValidateWebhookURL(raw string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewClient ¶
NewClient 返回带安全拨号器的 HTTP 客户端。 skipVerify 仅用于用户明确允许的自签证书场景。
默认不跟随重定向:证书私钥/API 凭据通常放在 POST body 或自定义头中, 307/308 会把它们重放到 Location 指向的主机。确需重定向的调用方应使用 独立的客户端并显式实现同源、HTTPS-only 策略。
func SanitizeErrorText ¶
SanitizeErrorText 脱敏错误文本中的 URL 路径与查询参数,避免把 token 写入日志。
func ValidateServiceURL ¶ added in v1.4.2
ValidateServiceURL 校验部署面板/通知服务等用户配置的 HTTP(S) 地址。 公网目标必须使用 HTTPS;回环、私网和明确的本地域名允许 HTTP,便于 自建面板、内网 webhook 等合理场景。HTTP 目标会解析域名,只要解析结果 中出现公网地址就拒绝,避免把凭据或证书私钥明文发送到公网。
func ValidateURL ¶
ValidateURL 校验用户配置的出站 HTTP(S) 地址。 只允许 http/https,拒绝 userinfo 与非法端口,避免把请求发送到 file:// 等非预期协议,或让 URL 中的凭据信息被误当作主机。
func ValidateWebhookURL ¶
ValidateWebhookURL 校验部署 webhook 地址。 Webhook 会携带证书私钥,因此公网地址必须使用 HTTPS; 回环/私网/.local/.internal 目标允许 HTTP,便于本地接收端。
Types ¶
This section is empty.