Skip to content

Commit 269ca7a

Browse files
author
𝐘𝐨𝐬𝐞𝐛𝐲𝐭𝐞
authored
refactor: simplify TLS code checks and enhance TLS-1 certificate verification
1 parent 0c932f8 commit 269ca7a

1 file changed

Lines changed: 9 additions & 11 deletions

File tree

internal/common.go

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1030,8 +1030,8 @@ func (c *Common) setControlConn() error {
10301030
}
10311031
}()
10321032

1033-
if c.tlsCode == "1" || c.tlsCode == "2" {
1034-
c.logger.Info("TLS certificate fingerprint verifying...")
1033+
if c.tlsCode == "1" {
1034+
c.logger.Info("TLS code-1: certificate fingerprint verifying...")
10351035
}
10361036
return nil
10371037
}
@@ -1107,11 +1107,11 @@ func (c *Common) healthCheck() error {
11071107
ticker := time.NewTicker(reportInterval)
11081108
defer ticker.Stop()
11091109

1110-
if c.tlsCode == "1" || c.tlsCode == "2" {
1110+
if c.tlsCode == "1" {
11111111
go func() {
11121112
select {
11131113
case <-c.ctx.Done():
1114-
case <-ticker.C:
1114+
case <-time.After(reportInterval):
11151115
c.incomingVerify()
11161116
}
11171117
}()
@@ -1203,15 +1203,15 @@ func (c *Common) incomingVerify() {
12031203
c.writeChan <- c.encode(signalData)
12041204
}
12051205

1206-
c.logger.Debug("TLS verify signal: cid %v -> %v", id, c.controlConn.RemoteAddr())
1206+
c.logger.Debug("TLS code-1: verify signal: cid %v -> %v", id, c.controlConn.RemoteAddr())
12071207
}
12081208

12091209
// commonLoop 共用处理循环
12101210
func (c *Common) commonLoop() {
12111211
for c.ctx.Err() == nil {
12121212
// 等待连接池准备就绪
12131213
if c.tunnelPool.Ready() {
1214-
if c.verifyChan != nil {
1214+
if c.tlsCode == "1" {
12151215
select {
12161216
case <-c.verifyChan:
12171217
// 证书验证完成
@@ -1475,7 +1475,7 @@ func (c *Common) commonOnce() error {
14751475
// 处理信号
14761476
switch signal.ActionType {
14771477
case "verify":
1478-
if c.tlsCode == "1" || c.tlsCode == "2" {
1478+
if c.tlsCode == "1" {
14791479
go c.outgoingVerify(signal)
14801480
}
14811481
case "tcp":
@@ -1594,12 +1594,10 @@ func (c *Common) outgoingVerify(signal Signal) {
15941594
return
15951595
}
15961596

1597-
c.logger.Info("TLS certificate fingerprint verified: %v", fingerPrint)
1597+
c.logger.Info("TLS code-1: certificate fingerprint verified: %v", fingerPrint)
15981598

15991599
// 通知验证完成
1600-
if c.verifyChan != nil {
1601-
c.verifyChan <- struct{}{}
1602-
}
1600+
c.verifyChan <- struct{}{}
16031601
}
16041602

16051603
// commonTCPOnce 共用处理单个TCP请求

0 commit comments

Comments
 (0)