From 0c26763147a2db5240847aee58516661f5353de9 Mon Sep 17 00:00:00 2001 From: lqqyt2423 <974923609@qq.com> Date: Mon, 20 Jun 2022 15:29:40 +0800 Subject: [PATCH] addon.TlsEstablishedServer --- proxy/addon.go | 5 +++++ proxy/interceptor.go | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/proxy/addon.go b/proxy/addon.go index ddde001..d10e055 100644 --- a/proxy/addon.go +++ b/proxy/addon.go @@ -19,6 +19,9 @@ type Addon interface { // A server connection has been closed (either by us or the server). ServerDisconnected(*ConnContext) + // The TLS handshake with the server has been completed successfully. + TlsEstablishedServer(*ConnContext) + // HTTP request headers were successfully read. At this point, the body is empty. Requestheaders(*Flow) @@ -40,6 +43,8 @@ func (addon *BaseAddon) ClientDisconnected(*ClientConn) {} func (addon *BaseAddon) ServerConnected(*ConnContext) {} func (addon *BaseAddon) ServerDisconnected(*ConnContext) {} +func (addon *BaseAddon) TlsEstablishedServer(*ConnContext) {} + func (addon *BaseAddon) Requestheaders(*Flow) {} func (addon *BaseAddon) Request(*Flow) {} func (addon *BaseAddon) Responseheaders(*Flow) {} diff --git a/proxy/interceptor.go b/proxy/interceptor.go index 5044f79..2e95f2d 100644 --- a/proxy/interceptor.go +++ b/proxy/interceptor.go @@ -125,6 +125,11 @@ func newMiddle(proxy *Proxy) (interceptor, error) { if err := connCtx.tlsHandshake(clientHello); err != nil { return nil, err } + + for _, addon := range connCtx.proxy.Addons { + addon.TlsEstablishedServer(connCtx) + } + return ca.GetCert(clientHello.ServerName) }, },