mirror of
https://gitee.com/konyshe/goodlink.git
synced 2026-04-22 14:53:05 +08:00
Add TunKeyByteLen constant for fixed key length and update key generation logic across files. Adjust placeholder text for key input section to reflect new length range.
This commit is contained in:
@@ -7,6 +7,9 @@ import (
|
||||
"os"
|
||||
)
|
||||
|
||||
// TunKeyByteLen 连接密钥固定字节长度(Local/Remote 必须一致)
|
||||
const TunKeyByteLen = 48
|
||||
|
||||
var (
|
||||
Arg_pprof_addr string
|
||||
Arg_tun_local *bool
|
||||
|
||||
+2
-2
@@ -41,7 +41,7 @@ func handleState0_RegisterSession(sessionID string, redisJson *RedisJsonType, co
|
||||
log.Printf("注册会话失败: %v", err)
|
||||
return false, err
|
||||
}
|
||||
log.Printf("已注册会话到队列,等待Remote端认领: %s", sessionID)
|
||||
log.Printf("已注册会话,待Remote端处理: %s", sessionID)
|
||||
|
||||
// 等待Remote端认领并写入独立的session key
|
||||
sessionClaimed := false
|
||||
@@ -145,7 +145,7 @@ func GetLocalQuicConn(conn *net.UDPConn, addr *tun.AddrType, count int) (*tun.Tu
|
||||
var tun_active *tun.TunActive
|
||||
var tun_passive *tun.TunPassive
|
||||
|
||||
sessionIDBytes := go2.RandomBytes(24)
|
||||
sessionIDBytes := go2.RandomBytes(config.TunKeyByteLen)
|
||||
SessionID := string(sessionIDBytes)
|
||||
log.Printf("会话ID: %s", SessionID)
|
||||
|
||||
|
||||
@@ -167,7 +167,7 @@ func createWorkTypeSelector(configInfo *goodlink_config.ConfigInfo) fyne.CanvasO
|
||||
// 创建连接密钥输入区域
|
||||
func createKeyInputSection(configInfo *goodlink_config.ConfigInfo) fyne.CanvasObject {
|
||||
m_validated_key = widget.NewEntry()
|
||||
m_validated_key.SetPlaceHolder("自定义16-24字节长度")
|
||||
m_validated_key.SetPlaceHolder("16-64字节长度")
|
||||
if len(configInfo.TunKey) > 0 {
|
||||
m_validated_key.SetText(configInfo.TunKey)
|
||||
}
|
||||
@@ -182,7 +182,7 @@ func createKeyInputSection(configInfo *goodlink_config.ConfigInfo) fyne.CanvasOb
|
||||
// 创建密钥操作按钮组
|
||||
func createKeyButtons() fyne.CanvasObject {
|
||||
m_button_key_create = widget.NewButtonWithIcon("生成密钥", theme.ContentAddIcon(), func() {
|
||||
m_validated_key.SetText(string(go2.RandomBytes(24)))
|
||||
m_validated_key.SetText(string(go2.RandomBytes(config.TunKeyByteLen)))
|
||||
})
|
||||
|
||||
key_copy_button := widget.NewButtonWithIcon("复制密钥", theme.ContentCopyIcon(), func() {
|
||||
@@ -211,7 +211,7 @@ func GetMainUI(myWindow *fyne.Window) *fyne.Container {
|
||||
|
||||
// 如果密钥为空,自动生成密钥
|
||||
if len(configInfo.TunKey) == 0 {
|
||||
configInfo.TunKey = string(go2.RandomBytes(24))
|
||||
configInfo.TunKey = string(go2.RandomBytes(config.TunKeyByteLen))
|
||||
log.Println("自动生成密钥:", configInfo.TunKey)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user