Skip to content

Commit 6f50813

Browse files
author
𝐘𝐨𝐬𝐞𝐛𝐲𝐭𝐞
authored
refactor: initialize verifyChan in Client and Server structs for TLS verification
1 parent 269ca7a commit 6f50813

2 files changed

Lines changed: 2 additions & 7 deletions

File tree

internal/client.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ func NewClient(parsedURL *url.URL, logger *logs.Logger) (*Client, error) {
3333
logger: logger,
3434
signalChan: make(chan Signal, semaphoreLimit),
3535
writeChan: make(chan []byte, semaphoreLimit),
36+
verifyChan: make(chan struct{}),
3637
tcpBufferPool: &sync.Pool{
3738
New: func() any {
3839
buf := make([]byte, tcpDataBufSize)
@@ -282,9 +283,6 @@ func (c *Client) tunnelHandshake() error {
282283
c.maxPoolCapacity = config.Max
283284
c.tlsCode = config.TLS
284285
c.poolType = config.Type
285-
if c.tlsCode == "1" || c.tlsCode == "2" {
286-
c.verifyChan = make(chan struct{})
287-
}
288286

289287
c.logger.Info("Loading tunnel config: FLOW=%v|MAX=%v|TLS=%v|TYPE=%v",
290288
c.dataFlow, c.maxPoolCapacity, c.tlsCode, c.poolType)

internal/server.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ func NewServer(parsedURL *url.URL, tlsCode string, tlsConfig *tls.Config, logger
3737
logger: logger,
3838
signalChan: make(chan Signal, semaphoreLimit),
3939
writeChan: make(chan []byte, semaphoreLimit),
40+
verifyChan: make(chan struct{}),
4041
tcpBufferPool: &sync.Pool{
4142
New: func() any {
4243
buf := make([]byte, tcpDataBufSize)
@@ -213,10 +214,6 @@ func (s *Server) initTunnelPool() error {
213214

214215
// tunnelHandshake 与客户端进行HTTP握手
215216
func (s *Server) tunnelHandshake() error {
216-
if s.tlsCode == "1" || s.tlsCode == "2" {
217-
s.verifyChan = make(chan struct{})
218-
}
219-
220217
var clientIP string
221218
done := make(chan struct{})
222219

0 commit comments

Comments
 (0)