File tree Expand file tree Collapse file tree 3 files changed +26
-2
lines changed Expand file tree Collapse file tree 3 files changed +26
-2
lines changed Original file line number Diff line number Diff line change 6
6
"compress/gzip"
7
7
"context"
8
8
"crypto/rand"
9
+ "crypto/tls"
9
10
"encoding/hex"
10
11
"fmt"
11
12
"io"
@@ -153,6 +154,21 @@ func newReqID() string {
153
154
return hex .EncodeToString (b )
154
155
}
155
156
157
+ func (h * Midware ) preparetls (rw http.ResponseWriter , r * http.Request , conn * tcp.Conn ) {
158
+ if r .TLS == nil {
159
+ head := conn .Head ()
160
+ if head > 1 {
161
+ if conn .Protocol ()[head - 1 ] == "TLS" {
162
+ if conn , ok := conn .TopConn ().(* utils.RwConn ); ok {
163
+ r .TLS = new (tls.ConnectionState )
164
+ * r .TLS = conn .Rawconn .(* tls.Conn ).ConnectionState ()
165
+ }
166
+ }
167
+ }
168
+ }
169
+
170
+ }
171
+
156
172
func (h * Midware ) head (rw http.ResponseWriter , r * http.Request , conn * tcp.Conn ) {
157
173
ngrw := & NgResponseWriter {
158
174
writer : nil ,
Original file line number Diff line number Diff line change @@ -91,6 +91,7 @@ func (h *Midware) Handle(c *tcp.Conn) tcp.SerRet {
91
91
switch top {
92
92
case "HTTP1" :
93
93
http .Serve (utils .ConnGetSocket (c .TopConn ()), http .HandlerFunc (func (rw http.ResponseWriter , r * http.Request ) {
94
+ h .preparetls (rw , r , c )
94
95
h .head (rw , r , c )
95
96
}))
96
97
return tcp .Close
Original file line number Diff line number Diff line change @@ -54,10 +54,17 @@ func (c *Conn) TopConn() net.Conn {
54
54
return c .conn [c .head ]
55
55
}
56
56
func (c * Conn ) TopProtocol () string {
57
- c .mu .RLock ()
58
- defer c .mu .RUnlock ()
59
57
return c .proto [c .head ]
60
58
}
59
+
60
+ func (c * Conn ) Protocol () []string {
61
+ return c .proto
62
+ }
63
+
64
+ func (c * Conn ) Head () int {
65
+ return int (c .head )
66
+ }
67
+
61
68
func (c * Conn ) unsync_genProtocols () {
62
69
c .protos = ""
63
70
for _ , v := range c .proto {
You can’t perform that action at this time.
0 commit comments