diff --git a/config/args.go b/config/args.go index fe6b9bb..16e2b94 100644 --- a/config/args.go +++ b/config/args.go @@ -7,6 +7,9 @@ import ( "os" ) +// TunKeyByteLen 连接密钥固定字节长度(Local/Remote 必须一致) +const TunKeyByteLen = 48 + var ( Arg_pprof_addr string Arg_tun_local *bool diff --git a/pro/local.go b/pro/local.go index 943ed74..38c3ba6 100644 --- a/pro/local.go +++ b/pro/local.go @@ -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) diff --git a/ui2/ui.go b/ui2/ui.go index 48ca13c..286d114 100644 --- a/ui2/ui.go +++ b/ui2/ui.go @@ -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) }