From 007c01ac3e679eae656466a159e6934103292dd3 Mon Sep 17 00:00:00 2001 From: Keeyou Date: Sun, 5 May 2024 14:52:22 +0800 Subject: [PATCH] ui: add enable_post_quatumn_kyber button --- src/gtk/option_dialog.cpp | 29 ++- src/gtk/option_dialog.hpp | 5 +- src/gtk/yass_en.po | 4 + src/gtk/yass_zh_CN.po | 4 + src/gtk4/option_dialog.cpp | 21 +- src/gtk4/option_dialog.hpp | 4 +- src/gtk4/option_dialog.ui | 22 +- src/gtk4/yass_en.po | 4 + src/gtk4/yass_zh_CN.po | 4 + src/mac/Base.lproj/Main.storyboard | 336 ++++++++++++++++++----------- src/mac/OptionViewController.h | 3 +- src/mac/OptionViewController.mm | 6 +- src/mac/en.lproj/Main.strings | 18 +- src/mac/zh-Hans.lproj/Main.strings | 18 +- src/win32/resource.hpp | 3 +- src/win32/yass.rc | 29 ++- src/win32/yass_frame.cpp | 9 + 17 files changed, 362 insertions(+), 157 deletions(-) diff --git a/src/gtk/option_dialog.cpp b/src/gtk/option_dialog.cpp index 90c943841..2410ca2f2 100644 --- a/src/gtk/option_dialog.cpp +++ b/src/gtk/option_dialog.cpp @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-2.0 -/* Copyright (c) 2021-2022 Chilledheart */ +/* Copyright (c) 2021-2024 Chilledheart */ #include "gtk/option_dialog.hpp" @@ -32,20 +32,25 @@ OptionDialog::OptionDialog(const std::string& title, GtkWindow* parent, bool mod auto tcp_keep_alive_idle_timeout_label = gtk_label_new(_("TCP keep alive after idle")); auto tcp_keep_alive_interval_label = gtk_label_new(_("TCP keep alive interval")); + auto enable_post_quantum_kyber_label = gtk_label_new(_("Kyber post-quantum key agreement for TLS")); + gtk_grid_attach(grid, GTK_WIDGET(tcp_keep_alive_label), 0, 0, 1, 1); gtk_grid_attach(grid, GTK_WIDGET(tcp_keep_alive_cnt_label), 0, 1, 1, 1); gtk_grid_attach(grid, GTK_WIDGET(tcp_keep_alive_idle_timeout_label), 0, 2, 1, 1); gtk_grid_attach(grid, GTK_WIDGET(tcp_keep_alive_interval_label), 0, 3, 1, 1); + gtk_grid_attach(grid, GTK_WIDGET(enable_post_quantum_kyber_label), 0, 4, 1, 1); tcp_keep_alive_ = GTK_CHECK_BUTTON(gtk_check_button_new()); tcp_keep_alive_cnt_ = GTK_ENTRY(gtk_entry_new()); tcp_keep_alive_idle_timeout_ = GTK_ENTRY(gtk_entry_new()); tcp_keep_alive_interval_ = GTK_ENTRY(gtk_entry_new()); + enable_post_quantum_kyber_ = GTK_CHECK_BUTTON(gtk_check_button_new()); gtk_grid_attach(grid, GTK_WIDGET(tcp_keep_alive_), 1, 0, 1, 1); gtk_grid_attach(grid, GTK_WIDGET(tcp_keep_alive_cnt_), 1, 1, 1, 1); gtk_grid_attach(grid, GTK_WIDGET(tcp_keep_alive_idle_timeout_), 1, 2, 1, 1); gtk_grid_attach(grid, GTK_WIDGET(tcp_keep_alive_interval_), 1, 3, 1, 1); + gtk_grid_attach(grid, GTK_WIDGET(enable_post_quantum_kyber_), 1, 4, 1, 1); okay_button_ = GTK_BUTTON(gtk_button_new()); gtk_button_set_label(okay_button_, _("Okay")); @@ -61,8 +66,8 @@ OptionDialog::OptionDialog(const std::string& title, GtkWindow* parent, bool mod g_signal_connect(G_OBJECT(cancel_button_), "clicked", G_CALLBACK(cancel_callback), nullptr); - gtk_grid_attach(grid, GTK_WIDGET(okay_button_), 0, 4, 1, 1); - gtk_grid_attach(grid, GTK_WIDGET(cancel_button_), 1, 4, 1, 1); + gtk_grid_attach(grid, GTK_WIDGET(okay_button_), 0, 5, 1, 1); + gtk_grid_attach(grid, GTK_WIDGET(cancel_button_), 1, 5, 1, 1); gtk_container_add(GTK_CONTAINER(gtk_dialog_get_content_area(impl_)), GTK_WIDGET(grid)); @@ -76,7 +81,10 @@ OptionDialog::~OptionDialog() { } void OptionDialog::OnOkayButtonClicked() { - OnSave(); + if (!OnSave()) { + return; + } + config::SaveConfig(); gtk_dialog_response(impl_, GTK_RESPONSE_ACCEPT); } @@ -96,22 +104,31 @@ void OptionDialog::LoadChanges() { gtk_entry_set_text(tcp_keep_alive_idle_timeout_, tcp_keep_alive_idle_timeout_str.c_str()); auto tcp_keep_alive_interval_str = std::to_string(absl::GetFlag(FLAGS_tcp_keep_alive_interval)); gtk_entry_set_text(tcp_keep_alive_interval_, tcp_keep_alive_interval_str.c_str()); + + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(enable_post_quantum_kyber_), + absl::GetFlag(FLAGS_enable_post_quantum_kyber)); } -void OptionDialog::OnSave() { +bool OptionDialog::OnSave() { auto tcp_keep_alive = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(tcp_keep_alive_)); auto tcp_keep_alive_cnt = StringToIntegerU(gtk_entry_get_text(tcp_keep_alive_cnt_)); auto tcp_keep_alive_idle_timeout = StringToIntegerU(gtk_entry_get_text(tcp_keep_alive_idle_timeout_)); auto tcp_keep_alive_interval = StringToIntegerU(gtk_entry_get_text(tcp_keep_alive_interval_)); + auto enable_post_quantum_kyber = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(enable_post_quantum_kyber_)); + if (!tcp_keep_alive_cnt.has_value() || !tcp_keep_alive_idle_timeout.has_value() || !tcp_keep_alive_interval.has_value()) { LOG(WARNING) << "invalid options"; - return; + return false; } absl::SetFlag(&FLAGS_tcp_keep_alive, tcp_keep_alive); absl::SetFlag(&FLAGS_tcp_keep_alive_cnt, tcp_keep_alive_cnt.value()); absl::SetFlag(&FLAGS_tcp_keep_alive_idle_timeout, tcp_keep_alive_idle_timeout.value()); absl::SetFlag(&FLAGS_tcp_keep_alive_interval, tcp_keep_alive_interval.value()); + + absl::SetFlag(&FLAGS_enable_post_quantum_kyber, enable_post_quantum_kyber); + + return true; } diff --git a/src/gtk/option_dialog.hpp b/src/gtk/option_dialog.hpp index f4e1b7994..3ccc4acff 100644 --- a/src/gtk/option_dialog.hpp +++ b/src/gtk/option_dialog.hpp @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-2.0 -/* Copyright (c) 2021-2022 Chilledheart */ +/* Copyright (c) 2021-2024 Chilledheart */ #ifndef OPTION_DIALOG #define OPTION_DIALOG @@ -19,12 +19,13 @@ class OptionDialog { private: void LoadChanges(); - void OnSave(); + bool OnSave(); GtkCheckButton* tcp_keep_alive_; GtkEntry* tcp_keep_alive_cnt_; GtkEntry* tcp_keep_alive_idle_timeout_; GtkEntry* tcp_keep_alive_interval_; + GtkCheckButton* enable_post_quantum_kyber_; GtkButton* okay_button_; GtkButton* cancel_button_; diff --git a/src/gtk/yass_en.po b/src/gtk/yass_en.po index 209632ca9..431c953cb 100644 --- a/src/gtk/yass_en.po +++ b/src/gtk/yass_en.po @@ -33,6 +33,10 @@ msgstr "TCP keep alive after idle" msgid "TCP keep alive interval" msgstr "TCP keep alive interval" +#: option_dialog.ui:50 +msgid "Kyber post-quantum key agreement for TLS" +msgstr "Kyber post-quantum key agreement for TLS" + #: option_dialog.cpp:54 msgid "Okay" msgstr "Okay" diff --git a/src/gtk/yass_zh_CN.po b/src/gtk/yass_zh_CN.po index 5cb7d9572..3411971e4 100644 --- a/src/gtk/yass_zh_CN.po +++ b/src/gtk/yass_zh_CN.po @@ -34,6 +34,10 @@ msgstr "TCP 在闲置以后的保活次数" msgid "TCP keep alive interval" msgstr "TCP 保活间隔" +#: option_dialog.ui:50 +msgid "Kyber post-quantum key agreement for TLS" +msgstr "TLS的Kyber后量子密钥协商" + #: option_dialog.cpp:54 msgid "Okay" msgstr "确认" diff --git a/src/gtk4/option_dialog.cpp b/src/gtk4/option_dialog.cpp index b5793fe83..61c71cf38 100644 --- a/src/gtk4/option_dialog.cpp +++ b/src/gtk4/option_dialog.cpp @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-2.0 -/* Copyright (c) 2021-2023 Chilledheart */ +/* Copyright (c) 2021-2024 Chilledheart */ #include "gtk4/option_dialog.hpp" @@ -19,6 +19,7 @@ struct _OptionGtkDialog { GtkWidget* tcp_keep_alive_cnt; GtkWidget* tcp_keep_alive_idle_timeout; GtkWidget* tcp_keep_alive_interval; + GtkWidget* enable_post_quantum_kyber; GtkWidget* okay_button; GtkWidget* cancel_button; @@ -40,6 +41,7 @@ static void option_dialog_class_init(OptionGtkDialogClass* cls) { gtk_widget_class_bind_template_child(GTK_WIDGET_CLASS(cls), OptionGtkDialog, tcp_keep_alive_cnt); gtk_widget_class_bind_template_child(GTK_WIDGET_CLASS(cls), OptionGtkDialog, tcp_keep_alive_idle_timeout); gtk_widget_class_bind_template_child(GTK_WIDGET_CLASS(cls), OptionGtkDialog, tcp_keep_alive_interval); + gtk_widget_class_bind_template_child(GTK_WIDGET_CLASS(cls), OptionGtkDialog, enable_post_quantum_kyber); gtk_widget_class_bind_template_child(GTK_WIDGET_CLASS(cls), OptionGtkDialog, okay_button); gtk_widget_class_bind_template_child(GTK_WIDGET_CLASS(cls), OptionGtkDialog, cancel_button); @@ -96,7 +98,10 @@ OptionDialog::~OptionDialog() { } void OptionDialog::OnOkayButtonClicked() { - OnSave(); + if (!OnSave()) { + return; + } + config::SaveConfig(); gtk_dialog_response(GTK_DIALOG(impl_), GTK_RESPONSE_ACCEPT); } @@ -116,23 +121,31 @@ void OptionDialog::LoadChanges() { gtk_editable_set_text(GTK_EDITABLE(impl_->tcp_keep_alive_cnt), tcp_keep_alive_cnt_str.c_str()); gtk_editable_set_text(GTK_EDITABLE(impl_->tcp_keep_alive_idle_timeout), tcp_keep_alive_idle_timeout_str.c_str()); gtk_editable_set_text(GTK_EDITABLE(impl_->tcp_keep_alive_interval), tcp_keep_alive_interval_str.c_str()); + + gtk_check_button_set_active(GTK_CHECK_BUTTON(impl_->enable_post_quantum_kyber), + absl::GetFlag(FLAGS_enable_post_quantum_kyber)); } -void OptionDialog::OnSave() { +bool OptionDialog::OnSave() { auto tcp_keep_alive = gtk_check_button_get_active(GTK_CHECK_BUTTON(impl_->tcp_keep_alive_check)); auto tcp_keep_alive_cnt = StringToIntegerU(gtk_editable_get_text(GTK_EDITABLE(impl_->tcp_keep_alive_cnt))); auto tcp_keep_alive_idle_timeout = StringToIntegerU(gtk_editable_get_text(GTK_EDITABLE(impl_->tcp_keep_alive_idle_timeout))); auto tcp_keep_alive_interval = StringToIntegerU(gtk_editable_get_text(GTK_EDITABLE(impl_->tcp_keep_alive_interval))); + auto enable_post_quantum_kyber = gtk_check_button_get_active(GTK_CHECK_BUTTON(impl_->enable_post_quantum_kyber)); + if (!tcp_keep_alive_cnt.has_value() || !tcp_keep_alive_idle_timeout.has_value() || !tcp_keep_alive_interval.has_value()) { LOG(WARNING) << "invalid options"; - return; + return false; } absl::SetFlag(&FLAGS_tcp_keep_alive, tcp_keep_alive); absl::SetFlag(&FLAGS_tcp_keep_alive_cnt, tcp_keep_alive_cnt.value()); absl::SetFlag(&FLAGS_tcp_keep_alive_idle_timeout, tcp_keep_alive_idle_timeout.value()); absl::SetFlag(&FLAGS_tcp_keep_alive_interval, tcp_keep_alive_interval.value()); + + absl::SetFlag(&FLAGS_enable_post_quantum_kyber, enable_post_quantum_kyber); + return true; } diff --git a/src/gtk4/option_dialog.hpp b/src/gtk4/option_dialog.hpp index ca87acc78..19f6a4993 100644 --- a/src/gtk4/option_dialog.hpp +++ b/src/gtk4/option_dialog.hpp @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-2.0 -/* Copyright (c) 2021-2023 Chilledheart */ +/* Copyright (c) 2021-2024 Chilledheart */ #ifndef OPTION_DIALOG #define OPTION_DIALOG @@ -26,7 +26,7 @@ class OptionDialog { private: void LoadChanges(); - void OnSave(); + bool OnSave(); private: OptionGtkDialog* impl_; diff --git a/src/gtk4/option_dialog.ui b/src/gtk4/option_dialog.ui index 383af5d4f..e628bef2c 100644 --- a/src/gtk4/option_dialog.ui +++ b/src/gtk4/option_dialog.ui @@ -55,6 +55,16 @@ + + + Kyber post-quantum key agreement for TLS: + 1 + + 0 + 4 + + + @@ -87,12 +97,20 @@ + + + + 1 + 4 + + + Okay 0 - 4 + 5 @@ -101,7 +119,7 @@ Cancel 1 - 4 + 5 diff --git a/src/gtk4/yass_en.po b/src/gtk4/yass_en.po index 7b9922039..b261ef754 100644 --- a/src/gtk4/yass_en.po +++ b/src/gtk4/yass_en.po @@ -37,6 +37,10 @@ msgstr "TCP keep alive after idle:" msgid "TCP keep alive interval:" msgstr "TCP keep alive interval:" +#: option_dialog.ui:50 +msgid "Kyber post-quantum key agreement for TLS:" +msgstr "Kyber post-quantum key agreement for TLS:" + #: option_dialog.ui:92 msgid "Okay" msgstr "Okay" diff --git a/src/gtk4/yass_zh_CN.po b/src/gtk4/yass_zh_CN.po index cb59cb8c0..b64abbb29 100644 --- a/src/gtk4/yass_zh_CN.po +++ b/src/gtk4/yass_zh_CN.po @@ -38,6 +38,10 @@ msgstr "TCP 在闲置以后的保活次数:" msgid "TCP keep alive interval:" msgstr "TCP 保活间隔:" +#: option_dialog.ui:50 +msgid "Kyber post-quantum key agreement for TLS:" +msgstr "TLS的Kyber后量子密钥协商:" + #: option_dialog.ui:92 msgid "Okay" msgstr "确认" diff --git a/src/mac/Base.lproj/Main.storyboard b/src/mac/Base.lproj/Main.storyboard index b8aa8ebf3..729791805 100644 --- a/src/mac/Base.lproj/Main.storyboard +++ b/src/mac/Base.lproj/Main.storyboard @@ -590,139 +590,231 @@ - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + diff --git a/src/mac/OptionViewController.h b/src/mac/OptionViewController.h index 2c1db047c..30b2ff333 100644 --- a/src/mac/OptionViewController.h +++ b/src/mac/OptionViewController.h @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-2.0 -/* Copyright (c) 2022 Chilledheart */ +/* Copyright (c) 2022-2024 Chilledheart */ #ifndef YASS_OPTION_VIEW_CONTROLLER #define YASS_OPTION_VIEW_CONTROLLER @@ -13,6 +13,7 @@ NS_ASSUME_NONNULL_BEGIN @property(weak) IBOutlet NSTextField* tcpKeepAliveCnt; @property(weak) IBOutlet NSTextField* tcpKeepAliveIdleTimeout; @property(weak) IBOutlet NSTextField* tcpKeepAliveInterval; +@property(weak) IBOutlet NSButton* enablePostQuantumKyber; @end diff --git a/src/mac/OptionViewController.mm b/src/mac/OptionViewController.mm index 173e46114..49e66b0b6 100644 --- a/src/mac/OptionViewController.mm +++ b/src/mac/OptionViewController.mm @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-2.0 -/* Copyright (c) 2022 Chilledheart */ +/* Copyright (c) 2022-2024 Chilledheart */ #import "mac/OptionViewController.h" @@ -22,6 +22,8 @@ - (void)viewDidLoad { self.tcpKeepAliveCnt.intValue = absl::GetFlag(FLAGS_tcp_keep_alive_cnt); self.tcpKeepAliveIdleTimeout.intValue = absl::GetFlag(FLAGS_tcp_keep_alive_idle_timeout); self.tcpKeepAliveInterval.intValue = absl::GetFlag(FLAGS_tcp_keep_alive_interval); + [self.enablePostQuantumKyber + setState:(absl::GetFlag(FLAGS_enable_post_quantum_kyber) ? NSControlStateValueOn : NSControlStateValueOff)]; } - (void)viewDidDisappear { @@ -33,6 +35,8 @@ - (IBAction)OnOkButtonClicked:(id)sender { absl::SetFlag(&FLAGS_tcp_keep_alive_cnt, self.tcpKeepAliveCnt.intValue); absl::SetFlag(&FLAGS_tcp_keep_alive_idle_timeout, self.tcpKeepAliveIdleTimeout.intValue); absl::SetFlag(&FLAGS_tcp_keep_alive_interval, self.tcpKeepAliveInterval.intValue); + absl::SetFlag(&FLAGS_enable_post_quantum_kyber, self.enablePostQuantumKyber.state == NSControlStateValueOn); + config::SaveConfig(); [self dismissViewController:self]; } diff --git a/src/mac/en.lproj/Main.strings b/src/mac/en.lproj/Main.strings index 246b13795..e6e010793 100644 --- a/src/mac/en.lproj/Main.strings +++ b/src/mac/en.lproj/Main.strings @@ -20,18 +20,27 @@ /* Class = "NSMenu"; title = "Main Menu"; ObjectID = "AYu-sK-qS6"; */ "AYu-sK-qS6.title" = "Main Menu"; +/* Class = "NSTextFieldCell"; title = "TCP Keep Alive"; ObjectID = "z0q-m8-6KJ"; */ +"z0q-m8-6KJ.title" = "TCP Keep Alive"; + +/* Class = "NSButtonCell"; title = "Enable"; ObjectID = "IpF-Ur-Zlh"; */ +"IpF-Ur-Zlh.title" = "Enable"; + /* Class = "NSTextFieldCell"; title = "TCP Keep Alive Count"; ObjectID = "DwU-MU-ncE"; */ "DwU-MU-ncE.title" = "TCP Keep Alive Count"; /* Class = "NSTextFieldCell"; title = "TCP Keep Alive Idle Timeout"; ObjectID = "EnC-Oa-kda"; */ "EnC-Oa-kda.title" = "TCP Keep Alive Idle Timeout"; +/* Class = "NSTextFieldCell"; title = "Kyber post-quantum key agreement for TLS"; ObjectID = "EY5-8C-G6C"; */ +"EY5-8C-G6C.title" = "Kyber post-quantum key agreement for TLS"; + +/* Class = "NSButtonCell"; title = "Enable"; ObjectID = "aFJ-Zj-eao"; */ +"aFJ-Zj-eao.title" = "Enable"; + /* Class = "NSWindow"; title = "Yet Another Shadow Socket"; ObjectID = "IQv-IB-iLA"; */ "IQv-IB-iLA.title" = "Yet Another Shadow Socket"; -/* Class = "NSButtonCell"; title = "Enable"; ObjectID = "IpF-Ur-Zlh"; */ -"IpF-Ur-Zlh.title" = "Enable"; - /* Class = "NSButtonCell"; title = "Stop"; ObjectID = "JYa-MA-4KH"; */ "JYa-MA-4KH.title" = "Stop"; @@ -80,9 +89,6 @@ /* Class = "NSButtonCell"; title = "OK"; ObjectID = "yzs-Gu-p7Y"; */ "yzs-Gu-p7Y.title" = "OK"; -/* Class = "NSTextFieldCell"; title = "TCP Keep Alive"; ObjectID = "z0q-m8-6KJ"; */ -"z0q-m8-6KJ.title" = "TCP Keep Alive"; - /* Class = "NSTextFieldCell"; title = "DNS over HTTPS URL"; ObjectID = "yxt-ql-TD8"; */ "yxt-ql-TD8.title" = "DNS over HTTPS URL"; diff --git a/src/mac/zh-Hans.lproj/Main.strings b/src/mac/zh-Hans.lproj/Main.strings index 76b628f4c..843323d0e 100644 --- a/src/mac/zh-Hans.lproj/Main.strings +++ b/src/mac/zh-Hans.lproj/Main.strings @@ -20,18 +20,27 @@ /* Class = "NSMenu"; title = "Main Menu"; ObjectID = "AYu-sK-qS6"; */ "AYu-sK-qS6.title" = "主菜单"; +/* Class = "NSTextFieldCell"; title = "TCP Keep Alive"; ObjectID = "z0q-m8-6KJ"; */ +"z0q-m8-6KJ.title" = "TCP 保活"; + +/* Class = "NSButtonCell"; title = "Enable"; ObjectID = "IpF-Ur-Zlh"; */ +"IpF-Ur-Zlh.title" = "启用"; + /* Class = "NSTextFieldCell"; title = "TCP Keep Alive Count"; ObjectID = "DwU-MU-ncE"; */ "DwU-MU-ncE.title" = "TCP 保活数目"; /* Class = "NSTextFieldCell"; title = "TCP Keep Alive Idle Timeout"; ObjectID = "EnC-Oa-kda"; */ "EnC-Oa-kda.title" = "TCP 在闲置以后的保活次数"; +/* Class = "NSTextFieldCell"; title = "Kyber post-quantum key agreement for TLS"; ObjectID = "EY5-8C-G6C"; */ +"EY5-8C-G6C.title" = "TLS的Kyber后量子密钥协商"; + +/* Class = "NSButtonCell"; title = "Enable"; ObjectID = "aFJ-Zj-eao"; */ +"aFJ-Zj-eao.title" = "启用"; + /* Class = "NSWindow"; title = "Yet Another Shadow Socket"; ObjectID = "IQv-IB-iLA"; */ "IQv-IB-iLA.title" = "YASS"; -/* Class = "NSButtonCell"; title = "Enable"; ObjectID = "IpF-Ur-Zlh"; */ -"IpF-Ur-Zlh.title" = "启用"; - /* Class = "NSButtonCell"; title = "Stop"; ObjectID = "JYa-MA-4KH"; */ "JYa-MA-4KH.title" = "停止"; @@ -80,9 +89,6 @@ /* Class = "NSButtonCell"; title = "OK"; ObjectID = "yzs-Gu-p7Y"; */ "yzs-Gu-p7Y.title" = "确认"; -/* Class = "NSTextFieldCell"; title = "TCP Keep Alive"; ObjectID = "z0q-m8-6KJ"; */ -"z0q-m8-6KJ.title" = "TCP 保活"; - /* Class = "NSTextFieldCell"; title = "DNS over HTTPS URL"; ObjectID = "yxt-ql-TD8"; */ "yxt-ql-TD8.title" = "基于 HTTPS 的 DNS (DoH) URL"; diff --git a/src/win32/resource.hpp b/src/win32/resource.hpp index cf46e09ec..4e64526e8 100644 --- a/src/win32/resource.hpp +++ b/src/win32/resource.hpp @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-2.0 -/* Copyright (c) 2021 Chilledheart */ +/* Copyright (c) 2021-2024 Chilledheart */ // Used by yass.rc #ifndef YASS_WIN32_RESOURCE_H @@ -96,6 +96,7 @@ #define IDC_CHECKBOX_TCP_KEEP_ALIVE 1025 #define IDC_EDIT_TCP_KEEP_ALIVE_TIMEOUT 1026 #define IDC_EDIT_TCP_KEEP_ALIVE_INTERVAL 1027 +#define IDC_CHECKBOX_ENABLE_POST_QUANTUM_KYBER 1028 #define IDC_YASS 2000 #define IDC_CONTEXTMENU 2500 diff --git a/src/win32/yass.rc b/src/win32/yass.rc index d068bb24c..d2371348a 100644 --- a/src/win32/yass.rc +++ b/src/win32/yass.rc @@ -188,10 +188,11 @@ END // Dialog // -IDD_OPTIONBOX DIALOG DISCARDABLE 0, 0, 210, 90 +IDD_OPTIONBOX DIALOGEX DISCARDABLE 0, 0, 210, 120 +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU CAPTION "Options" -FONT 8, "MS Sans Serif" +FONT 8, "MS Sans Serif", 0, 0, 0x0 BEGIN LTEXT "TCP Keep Alive",IDC_STATIC,10,15,80,12 AUTOCHECKBOX "", IDC_CHECKBOX_TCP_KEEP_ALIVE,120,15,80,12,ES_AUTOHSCROLL @@ -199,6 +200,26 @@ BEGIN EDITTEXT IDC_EDIT_TCP_KEEP_ALIVE_TIMEOUT,120,30,80,12,ES_AUTOHSCROLL LTEXT "TCP Keep Alive Interval",IDC_STATIC,10,45,80,12 EDITTEXT IDC_EDIT_TCP_KEEP_ALIVE_INTERVAL,120,45,80,12,ES_AUTOHSCROLL - DEFPUSHBUTTON "&Ok",IDOK,20,65,66,15 - PUSHBUTTON "&Cancel",IDCANCEL,110,65,66,15 + LTEXT "Kyber post-quantum key agreement for TLS",IDC_STATIC,10,60,80,24 + AUTOCHECKBOX "", IDC_CHECKBOX_ENABLE_POST_QUANTUM_KYBER,120,60,80,24,ES_AUTOHSCROLL + DEFPUSHBUTTON "&Ok",IDOK,20,95,66,15 + PUSHBUTTON "&Cancel",IDCANCEL,110,95,66,15 +END + +IDD_OPTIONBOX DIALOGEX DISCARDABLE 0, 0, 210, 120 +LANGUAGE LANG_CHINESE, SUBLANG_CHINESE_SIMPLIFIED +STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU +CAPTION "选项" +FONT 9, "SimSun", 0, 0, 0x0 +BEGIN + LTEXT "TCP 保活",IDC_STATIC,10,15,80,12 + AUTOCHECKBOX "", IDC_CHECKBOX_TCP_KEEP_ALIVE,120,15,80,12,ES_AUTOHSCROLL + LTEXT "TCP保持活动超时",IDC_STATIC,10,30,80,12 + EDITTEXT IDC_EDIT_TCP_KEEP_ALIVE_TIMEOUT,120,30,80,12,ES_AUTOHSCROLL + LTEXT "TCP 保活间隔",IDC_STATIC,10,45,80,12 + EDITTEXT IDC_EDIT_TCP_KEEP_ALIVE_INTERVAL,120,45,80,12,ES_AUTOHSCROLL + LTEXT "TLS的Kyber后量子密钥协商",IDC_STATIC,10,60,80,24 + AUTOCHECKBOX "", IDC_CHECKBOX_ENABLE_POST_QUANTUM_KYBER,120,60,80,24,ES_AUTOHSCROLL + DEFPUSHBUTTON "确认",IDOK,20,95,66,15 + PUSHBUTTON "取消",IDCANCEL,110,95,66,15 END diff --git a/src/win32/yass_frame.cpp b/src/win32/yass_frame.cpp index 573f02843..bcb943906 100644 --- a/src/win32/yass_frame.cpp +++ b/src/win32/yass_frame.cpp @@ -1060,9 +1060,13 @@ INT_PTR CALLBACK CYassFrame::OnAppOptionMessage(HWND hDlg, UINT message, WPARAM auto tcp_keep_alive = absl::GetFlag(FLAGS_tcp_keep_alive); auto tcp_keep_alive_timeout = absl::GetFlag(FLAGS_tcp_keep_alive_idle_timeout); auto tcp_keep_alive_interval = absl::GetFlag(FLAGS_tcp_keep_alive_interval); + + auto enable_post_quantum_kyber = absl::GetFlag(FLAGS_enable_post_quantum_kyber); CheckDlgButton(hDlg, IDC_CHECKBOX_TCP_KEEP_ALIVE, tcp_keep_alive ? BST_CHECKED : BST_UNCHECKED); SetDlgItemInt(hDlg, IDC_EDIT_TCP_KEEP_ALIVE_TIMEOUT, tcp_keep_alive_timeout, FALSE); SetDlgItemInt(hDlg, IDC_EDIT_TCP_KEEP_ALIVE_INTERVAL, tcp_keep_alive_interval, FALSE); + CheckDlgButton(hDlg, IDC_CHECKBOX_ENABLE_POST_QUANTUM_KYBER, + enable_post_quantum_kyber ? BST_CHECKED : BST_UNCHECKED); return static_cast(TRUE); } case WM_COMMAND: @@ -1076,9 +1080,14 @@ INT_PTR CALLBACK CYassFrame::OnAppOptionMessage(HWND hDlg, UINT message, WPARAM auto tcp_keep_alive_interval = GetDlgItemInt(hDlg, IDC_EDIT_TCP_KEEP_ALIVE_INTERVAL, &translated, FALSE); if (translated == FALSE) return static_cast(FALSE); + auto enable_post_quantum_kyber = + IsDlgButtonChecked(hDlg, IDC_CHECKBOX_ENABLE_POST_QUANTUM_KYBER) == BST_CHECKED; absl::SetFlag(&FLAGS_tcp_keep_alive, tcp_keep_alive); absl::SetFlag(&FLAGS_tcp_keep_alive_idle_timeout, tcp_keep_alive_timeout); absl::SetFlag(&FLAGS_tcp_keep_alive_interval, tcp_keep_alive_interval); + + absl::SetFlag(&FLAGS_enable_post_quantum_kyber, enable_post_quantum_kyber); + config::SaveConfig(); } if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL) { EndDialog(hDlg, LOWORD(wParam));