根据squid改写golang tls标准库
需求
golang 重写squid tls_bump验证squid tls_bump
获取 SNI
改完支持https透明代理
支持https 代理

定义bump相关数据结构
// Copyright 2012 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package mytls
import (
"net"
"net/http"
)
type BumpMode uint8
const (
bumpNone BumpMode = 0
bumpClientFirst BumpMode = 1
bumpServerFirst BumpMode = 2
bumpPeek BumpMode = 3
bumpStare BumpMode = 4
bumpBump BumpMode = 5
bumpSplice BumpMode = 6
bumpTerminate BumpMode = 7
/* bumpErr */
bumpEnd alert = 8
)
type XactionStep uint8
const (
tlsBump1 XactionStep = 0
tlsBump2 XactionStep = 1
tlsBump3 XactionStep = 2
)
type actBump struct {
step1 BumpMode
step2 BumpMode
step3 BumpMode
}
type ServerBump struct {
request *http.Request
session *ClientSessionState
cert *Certificate
act *actBump
step XactionStep
}
type TlsDetails struct {
compressionSupported bool
serverName string
doHeartBeats bool
tlsTicketsExtension bool
hasTlsTicket bool
tlsStatusRequest bool
unsupportedExtensions bool
tlsAppLayerProtoNeg string
clientRandom string
seessionID string
Ciphers map[int]string
}
type ParserState uint8
const (
atHelloNone ParserState = iota
atHelloStarted
atHelloReceived
atHelloDoneReceived
atNstReceived
atCcsReceived
atFinishReceived
)
type MessageSource uint8
const (
fromClient MessageSource = iota
fromServer
)
type BinaryTokenizer struct {
address *net.IP
data string //
parsed uint8
syncPoint uint8
expectMore bool
}
type SetHow uint8
const (
optUnspecified SetHow = iota
optImplicitly
optConfigured
)
type YesNoNone struct {
setHow SetHow
option bool
}
type HandShakeParser struct {
details *TlsDetails
state ParserState
resumingSession bool
messageSource MessageSource
currentContentType uint8
done []byte
fragments string
tkRecords *BinaryTokenizer
tkMessage *BinaryTokenizer
expectingModernRecords *YesNoNone
}
本文来自博客园,作者:{心亘久},转载请注明原文链接:https://www.cnblogs.com/zhaodejin/p/16022529.html

浙公网安备 33010602011771号