Skip to content

Commit 8b79809

Browse files
author
𝐘𝐨𝐬𝐞𝐛𝐲𝐭𝐞
authored
Merge pull request #86 from NodePassProject/main
TLS Verification Logic Improvements, Channel Initialization Consistency
2 parents 0c932f8 + c607cb7 commit 8b79809

5 files changed

Lines changed: 30 additions & 31 deletions

File tree

README.md

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,9 @@ The [NodePassProject](https://github.com/NodePassProject) organization develops
112112

113113
## 📄 License
114114

115-
Project **NodePass** is licensed under the [BSD 3-Clause License](LICENSE).
115+
- Project **NodePass** is licensed under the [BSD 3-Clause License](LICENSE), which applies to the source code only.
116+
117+
- The **NodePass** name, logo, and official project identity are not covered by the code license and may not be used without explicit authorization.
116118

117119
## ⚖️ Disclaimer
118120

@@ -147,11 +149,6 @@ This project is provided "as is" without any warranties. Users assume all risks
147149
<a href="https://vps.town"><img src="https://cdn.yobc.de/assets/vpstown.png"></a>
148150
</td>
149151
</tr>
150-
<tr>
151-
<td width="240" align="center">
152-
<a href="https://evolution-host.com/vps-hosting.php"><img src="https://cdn.yobc.de/assets/evohost.png"></a>
153-
</td>
154-
</tr>
155152
</table>
156153

157154
## ⭐ Stargazers

README_zh.md

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,9 @@ nodepass "master://:10101/api?log=debug&tls=1"
112112

113113
## 📄 许可协议
114114

115-
**NodePass** 项目根据 [BSD 3-Clause 许可证](LICENSE)授权。
115+
- **NodePass** 项目根据 [BSD 3-Clause 许可证](LICENSE)授权,该许可仅适用于源代码本身。
116+
117+
- **NodePass** 项目名称、Logo 及官方身份标识不包含在代码许可中,未经明确授权不得使用。
116118

117119
## ⚖️ 免责声明
118120

@@ -147,13 +149,8 @@ nodepass "master://:10101/api?log=debug&tls=1"
147149
<a href="https://vps.town"><img src="https://cdn.yobc.de/assets/vpstown.png"></a>
148150
</td>
149151
</tr>
150-
<tr>
151-
<td width="240" align="center">
152-
<a href="https://evolution-host.com/vps-hosting.php"><img src="https://cdn.yobc.de/assets/evohost.png"></a>
153-
</td>
154-
</tr>
155152
</table>
156153

157-
## Star趋势
154+
## Star 趋势
158155

159156
[![Stargazers over time](https://starchart.cc/yosebyte/nodepass.svg?variant=adaptive)](https://starchart.cc/yosebyte/nodepass)

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/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: RAM cert 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: RAM cert 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请求

internal/server.go

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import (
1717
"syscall"
1818
"time"
1919

20+
"github.com/NodePassProject/cert"
2021
"github.com/NodePassProject/logs"
2122
"github.com/NodePassProject/nph2"
2223
"github.com/NodePassProject/npws"
@@ -37,6 +38,7 @@ func NewServer(parsedURL *url.URL, tlsCode string, tlsConfig *tls.Config, logger
3738
logger: logger,
3839
signalChan: make(chan Signal, semaphoreLimit),
3940
writeChan: make(chan []byte, semaphoreLimit),
41+
verifyChan: make(chan struct{}),
4042
tcpBufferPool: &sync.Pool{
4143
New: func() any {
4244
buf := make([]byte, tcpDataBufSize)
@@ -213,10 +215,6 @@ func (s *Server) initTunnelPool() error {
213215

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

@@ -270,6 +268,17 @@ func (s *Server) tunnelHandshake() error {
270268
case <-done:
271269
server.Close()
272270
s.clientIP = clientIP
271+
272+
if s.tlsCode == "1" {
273+
if newTLSConfig, err := cert.NewTLSConfig(""); err == nil {
274+
newTLSConfig.MinVersion = tls.VersionTLS13
275+
s.tlsConfig = newTLSConfig
276+
s.logger.Info("TLS code-1: RAM cert regenerated with TLS 1.3")
277+
} else {
278+
s.logger.Warn("Failed to regenerate RAM cert: %v", err)
279+
}
280+
}
281+
273282
s.tunnelListener, _ = net.ListenTCP("tcp", s.tunnelTCPAddr)
274283
return nil
275284
case <-s.ctx.Done():

0 commit comments

Comments
 (0)