init
This commit is contained in:
31
examples/https_to_https_proxy/main.go
Normal file
31
examples/https_to_https_proxy/main.go
Normal file
@@ -0,0 +1,31 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"log"
|
||||
"net/http"
|
||||
|
||||
"github.com/darkit/goproxy"
|
||||
)
|
||||
|
||||
func main() {
|
||||
// 创建证书缓存
|
||||
certCache := &goproxy.MemCertCache{}
|
||||
|
||||
// 创建代理实例
|
||||
proxy := goproxy.NewProxy(
|
||||
goproxy.WithDecryptHTTPS(certCache),
|
||||
goproxy.WithCACertAndKey("ca.crt", "ca.key"),
|
||||
goproxy.WithEnableECDSA(true),
|
||||
)
|
||||
|
||||
// 启动代理服务器
|
||||
log.Println("HTTPS 到 HTTPS 代理服务器启动在 :8443")
|
||||
log.Println("配置说明:")
|
||||
log.Printf("- 支持 HTTPS 解密\n")
|
||||
log.Printf("- 使用 ECDSA 证书\n")
|
||||
log.Printf("- 最低 TLS 版本: 1.2\n")
|
||||
log.Printf("- 最高 TLS 版本: 1.3\n")
|
||||
if err := http.ListenAndServeTLS(":8443", "server.crt", "server.key", proxy); err != nil {
|
||||
log.Fatalf("代理服务器启动失败: %v", err)
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user