mirror of
https://github.com/MatsuriDayo/nekoray.git
synced 2025-12-18 13:04:37 +03:00
alpn settings
This commit is contained in:
@@ -17,30 +17,34 @@ namespace NekoRay::fmt {
|
||||
|
||||
if (network == "ws") {
|
||||
QJsonObject ws;
|
||||
if (!path.isEmpty()) ws["path"] = path;
|
||||
if (!host.isEmpty()) ws["headers"] = QJsonObject{{"Host", host}};
|
||||
if (!path.trimmed().isEmpty()) ws["path"] = path;
|
||||
if (!host.trimmed().isEmpty()) ws["headers"] = QJsonObject{{"Host", host}};
|
||||
streamSettings["wsSettings"] = ws;
|
||||
} else if (network == "h2") {
|
||||
QJsonObject h2;
|
||||
if (!path.isEmpty()) h2["path"] = path;
|
||||
if (!host.isEmpty()) h2["host"] = QList2QJsonArray(host.split(","));
|
||||
if (!path.trimmed().isEmpty()) h2["path"] = path;
|
||||
if (!host.trimmed().isEmpty()) h2["host"] = QList2QJsonArray(host.split(","));
|
||||
streamSettings["httpSettings"] = h2;
|
||||
} else if (network == "grpc") {
|
||||
QJsonObject grpc;
|
||||
if (!path.isEmpty()) grpc["serviceName"] = path;
|
||||
if (!path.trimmed().isEmpty()) grpc["serviceName"] = path;
|
||||
streamSettings["grpcSettings"] = grpc;
|
||||
}
|
||||
|
||||
if (security == "tls") {
|
||||
QJsonObject tls;
|
||||
if (!sni.isEmpty()) tls["serverName"] = sni;
|
||||
if (allow_insecure || dataStore->skip_cert) tls["allowInsecure"] = true;
|
||||
if (!certificate.isEmpty())
|
||||
if (!sni.trimmed().isEmpty()) tls["serverName"] = sni;
|
||||
if (!certificate.trimmed().isEmpty()) {
|
||||
tls["certificates"] = QJsonArray{
|
||||
QJsonObject{
|
||||
{"certificate", certificate},
|
||||
},
|
||||
};
|
||||
}
|
||||
if (!alpn.trimmed().isEmpty()) {
|
||||
tls["alpn"] = QList2QJsonArray(alpn.split(","));
|
||||
}
|
||||
streamSettings["tlsSettings"] = tls;
|
||||
}
|
||||
|
||||
@@ -94,7 +98,7 @@ namespace NekoRay::fmt {
|
||||
servers.push_back(server);
|
||||
settings["servers"] = servers;
|
||||
|
||||
if (!plugin.isEmpty()) {
|
||||
if (!plugin.trimmed().isEmpty()) {
|
||||
settings["plugin"] = SubStrBefore(plugin, ";");
|
||||
settings["pluginOpts"] = SubStrAfter(plugin, ";");
|
||||
}
|
||||
|
||||
@@ -11,13 +11,11 @@ namespace NekoRay::fmt {
|
||||
// ws/h2/grpc
|
||||
QString path = "";
|
||||
QString host = "";
|
||||
// ws
|
||||
int max_early_data = 0;
|
||||
QString early_data_header_name = "";
|
||||
// QUIC & KCP
|
||||
QString header_type = "";
|
||||
// tls
|
||||
QString sni = "";
|
||||
QString alpn = "";
|
||||
QString certificate = "";
|
||||
bool allow_insecure = false;
|
||||
|
||||
@@ -28,10 +26,9 @@ namespace NekoRay::fmt {
|
||||
_add(new configItem("path", &path, itemType::string));
|
||||
_add(new configItem("host", &host, itemType::string));
|
||||
_add(new configItem("sni", &sni, itemType::string));
|
||||
_add(new configItem("alpn", &alpn, itemType::string));
|
||||
_add(new configItem("cert", &certificate, itemType::string));
|
||||
_add(new configItem("insecure", &allow_insecure, itemType::boolean));
|
||||
_add(new configItem("ws_med", &max_early_data, itemType::integer));
|
||||
_add(new configItem("ws_edhn", &early_data_header_name, itemType::string));
|
||||
_add(new configItem("h_type", &header_type, itemType::string));
|
||||
}
|
||||
|
||||
|
||||
@@ -205,8 +205,6 @@ namespace NekoRay::sub {
|
||||
}
|
||||
}
|
||||
bean->stream->path = Node2QString(ws["path"]);
|
||||
bean->stream->max_early_data = Node2Int(proxy["max-early-data"]);
|
||||
bean->stream->early_data_header_name = Node2QString(ws["early-data-header-name"]);
|
||||
}
|
||||
|
||||
auto grpc = proxy["grpc-opts"];
|
||||
|
||||
@@ -273,10 +273,6 @@
|
||||
<source>Host</source>
|
||||
<translation>主机(Host)</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>SNI</source>
|
||||
<translation></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Custom</source>
|
||||
<translation>自定义</translation>
|
||||
@@ -997,10 +993,6 @@ End: %2</source>
|
||||
<source>Export V2ray config</source>
|
||||
<translation>导出 V2ray 配置</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>QR Code and link (Nekoray)</source>
|
||||
<translation>显示 QR Code 和分享链接 (Nekoray)</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Active Routing</source>
|
||||
<translation>当前路由规则</translation>
|
||||
@@ -1085,6 +1077,10 @@ End: %2</source>
|
||||
<source>Clone %1 item(s)</source>
|
||||
<translation>克隆 %1 个项目</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Copy links of selected (Nekoray)</source>
|
||||
<translation>批量复制选中项目的分享链接 (Nekoray)</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>ProxyItem</name>
|
||||
|
||||
@@ -173,6 +173,7 @@ void DialogEditProfile::typeSelected(const QString &newType) {
|
||||
ui->path->setText(stream->path);
|
||||
ui->host->setText(stream->host);
|
||||
ui->sni->setText(stream->sni);
|
||||
ui->alpn->setText(stream->alpn);
|
||||
ui->insecure->setChecked(stream->allow_insecure);
|
||||
CACHE.certificate = stream->certificate;
|
||||
} else {
|
||||
@@ -209,6 +210,14 @@ void DialogEditProfile::typeSelected(const QString &newType) {
|
||||
ui->port->setText(Int2String(ent->bean->serverPort));
|
||||
ui->port->setValidator(QRegExpValidator_Number, this));
|
||||
|
||||
// 星号
|
||||
for (auto label: findChildren<QLabel *>()) {
|
||||
auto text = label->text();
|
||||
if (!label->toolTip().isEmpty() && !text.endsWith("*")) {
|
||||
label->setText(text + "*");
|
||||
}
|
||||
}
|
||||
|
||||
editor_cache_updated_impl();
|
||||
ADJUST_SIZE
|
||||
|
||||
@@ -238,6 +247,7 @@ void DialogEditProfile::accept() {
|
||||
stream->path = ui->path->text();
|
||||
stream->host = ui->host->text();
|
||||
stream->sni = ui->sni->text();
|
||||
stream->alpn = ui->alpn->text();
|
||||
stream->allow_insecure = ui->insecure->isChecked();
|
||||
stream->certificate = CACHE.certificate;
|
||||
}
|
||||
|
||||
@@ -157,6 +157,9 @@
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="right_layout">
|
||||
<property name="sizeConstraint">
|
||||
<enum>QLayout::SetDefaultConstraint</enum>
|
||||
@@ -365,27 +368,17 @@
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QGridLayout" name="_3">
|
||||
<item row="1" column="1">
|
||||
<item row="2" column="1">
|
||||
<widget class="QPushButton" name="certificate_edit">
|
||||
<property name="text">
|
||||
<string notr="true">PushButton</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="toolTip">
|
||||
<string notr="true">服务器名称指示,明文。</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>SNI</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_6">
|
||||
<property name="toolTip">
|
||||
<string notr="true">固定证书</string>
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Certificate</string>
|
||||
@@ -395,6 +388,29 @@
|
||||
<item row="0" column="1">
|
||||
<widget class="MyLineEdit" name="sni"/>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="toolTip">
|
||||
<string notr="true">服务器名称指示,明文。</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true">SNI</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_8">
|
||||
<property name="toolTip">
|
||||
<string notr="true">应用层协议协商,明文。多个请以英文逗号分隔。</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true">ALPN</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="MyLineEdit" name="alpn"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
|
||||
@@ -344,7 +344,6 @@ MainWindow::MainWindow(QWidget *parent)
|
||||
connect(ui->menu_spmode_disabled, &QAction::triggered, this,
|
||||
[=]() { neko_set_spmode(NekoRay::SystemProxyMode::DISABLE); });
|
||||
connect(ui->menu_qr, &QAction::triggered, this, [=]() { display_qr_link(false); });
|
||||
connect(ui->menu_qr_nkr, &QAction::triggered, this, [=]() { display_qr_link(true); });
|
||||
connect(ui->menu_tcp_ping, &QAction::triggered, this, [=]() { speedtest_current_group(0); });
|
||||
connect(ui->menu_url_test, &QAction::triggered, this, [=]() { speedtest_current_group(1); });
|
||||
connect(ui->menu_full_test, &QAction::triggered, this, [=]() { speedtest_current_group(2); });
|
||||
@@ -963,6 +962,17 @@ void MainWindow::on_menu_copy_links_triggered() {
|
||||
MessageBoxInfo("NekoRay", tr("Copied %1 item(s)").arg(links.length()));
|
||||
}
|
||||
|
||||
void MainWindow::on_menu_copy_links_nkr_triggered() {
|
||||
auto ents = get_now_selected();
|
||||
QStringList links;
|
||||
for (const auto &ent: ents) {
|
||||
links += ent->bean->ToNekorayShareLink(ent->type);
|
||||
}
|
||||
if (links.length() == 0) return;
|
||||
QApplication::clipboard()->setText(links.join("\n"));
|
||||
MessageBoxInfo("NekoRay", tr("Copied %1 item(s)").arg(links.length()));
|
||||
}
|
||||
|
||||
void MainWindow::on_menu_export_config_triggered() {
|
||||
auto ents = get_now_selected();
|
||||
if (ents.count() != 1) return;
|
||||
|
||||
@@ -86,6 +86,8 @@ private slots:
|
||||
|
||||
void on_menu_copy_links_triggered();
|
||||
|
||||
void on_menu_copy_links_nkr_triggered();
|
||||
|
||||
void on_menu_export_config_triggered();
|
||||
|
||||
void display_qr_link(bool nkrFormat = false);
|
||||
|
||||
@@ -512,10 +512,10 @@
|
||||
<string>Share</string>
|
||||
</property>
|
||||
<addaction name="menu_qr"/>
|
||||
<addaction name="menu_qr_nkr"/>
|
||||
<addaction name="menu_export_config"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="menu_copy_links"/>
|
||||
<addaction name="menu_copy_links_nkr"/>
|
||||
</widget>
|
||||
<widget class="QMenu" name="menugroup">
|
||||
<property name="title">
|
||||
@@ -755,9 +755,12 @@
|
||||
<string notr="true">Ctrl+A</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="menu_qr_nkr">
|
||||
<action name="menu_copy_links_nkr">
|
||||
<property name="text">
|
||||
<string>QR Code and link (Nekoray)</string>
|
||||
<string>Copy links of selected (Nekoray)</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string notr="true">Ctrl+Alt+C</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionfake_2">
|
||||
|
||||
Reference in New Issue
Block a user