根据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
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
· 【自荐】一款简洁、开源的在线白板工具 Drawnix