From b06846610821a3d150ee1f338e8e22cbd250c45a Mon Sep 17 00:00:00 2001 From: Dreamacro <305009791@qq.com> Date: Thu, 19 Mar 2020 22:39:09 +0800 Subject: [PATCH] Improve: add session cache for trojan --- adapters/outbound/trojan.go | 9 +++++---- component/trojan/trojan.go | 10 ++++++---- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/adapters/outbound/trojan.go b/adapters/outbound/trojan.go index 14564bc0..a7a3ae93 100644 --- a/adapters/outbound/trojan.go +++ b/adapters/outbound/trojan.go @@ -76,10 +76,11 @@ func NewTrojan(option TrojanOption) (*Trojan, error) { server := net.JoinHostPort(option.Server, strconv.Itoa(option.Port)) tOption := &trojan.Option{ - Password: option.Password, - ALPN: option.ALPN, - ServerName: option.Server, - SkipCertVerify: option.SkipCertVerify, + Password: option.Password, + ALPN: option.ALPN, + ServerName: option.Server, + SkipCertVerify: option.SkipCertVerify, + ClientSessionCache: getClientSessionCache(), } if option.SNI != "" { diff --git a/component/trojan/trojan.go b/component/trojan/trojan.go index b20fa3ae..efb802d5 100644 --- a/component/trojan/trojan.go +++ b/component/trojan/trojan.go @@ -28,10 +28,11 @@ var ( ) type Option struct { - Password string - ALPN []string - ServerName string - SkipCertVerify bool + Password string + ALPN []string + ServerName string + SkipCertVerify bool + ClientSessionCache tls.ClientSessionCache } type Trojan struct { @@ -50,6 +51,7 @@ func (t *Trojan) StreamConn(conn net.Conn) (net.Conn, error) { MinVersion: tls.VersionTLS12, InsecureSkipVerify: t.option.SkipCertVerify, ServerName: t.option.ServerName, + ClientSessionCache: t.option.ClientSessionCache, } tlsConn := tls.Client(conn, tlsConfig)