Skip to content

Commit

Permalink
refactor: show default fingerprint in ui
Browse files Browse the repository at this point in the history
Not add it to configuration in slient.

fix(sub): add fingerprint for vmess
  • Loading branch information
xchacha20-poly1305 authored and arm64v8a committed Sep 24, 2023
1 parent 6029b42 commit a2fe705
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 7 deletions.
4 changes: 2 additions & 2 deletions fmt/Bean2CoreObj_box.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,14 @@ namespace NekoGui_fmt {
if (!alpn.trimmed().isEmpty()) {
tls["alpn"] = QList2QJsonArray(alpn.split(","));
}
auto fp = utlsFingerprint.isEmpty() ? NekoGui::dataStore->utlsFingerprint : utlsFingerprint;
QString fp = utlsFingerprint;
if (!reality_pbk.trimmed().isEmpty()) {
tls["reality"] = QJsonObject{
{"enabled", true},
{"public_key", reality_pbk},
{"short_id", reality_sid.split(",")[0]},
};
if (fp.isEmpty()) fp = "chrome";
if (fp.isEmpty()) fp = "random";
}
if (!fp.isEmpty()) {
tls["utls"] = QJsonObject{
Expand Down
5 changes: 2 additions & 3 deletions fmt/Bean2CoreObj_ray.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,8 @@ namespace NekoGui_fmt {
}

if (security == "tls") {
auto fp = utlsFingerprint.isEmpty() ? NekoGui::dataStore->utlsFingerprint : utlsFingerprint;
QJsonObject tls;
if (!fp.isEmpty()) tls["fingerprint"] = fp;
if (!utlsFingerprint.isEmpty()) tls["fingerprint"] = utlsFingerprint;
if (!sni.trimmed().isEmpty()) tls["serverName"] = sni;
if (reality_pbk.trimmed().isEmpty()) {
if (allow_insecure || NekoGui::dataStore->skip_cert) tls["allowInsecure"] = true;
Expand All @@ -65,7 +64,7 @@ namespace NekoGui_fmt {
tls["publicKey"] = reality_pbk;
tls["shortId"] = reality_sid;
tls["spiderX"] = reality_spx;
if (fp.isEmpty()) tls["fingerprint"] = "chrome";
if (utlsFingerprint.isEmpty()) tls["fingerprint"] = "chrome";
streamSettings["realitySettings"] = tls;
streamSettings["security"] = "reality";
}
Expand Down
6 changes: 5 additions & 1 deletion fmt/Bean2Link.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,11 @@ namespace NekoGui_fmt {

if (!stream->sni.isEmpty()) query.addQueryItem("sni", stream->sni);
if (stream->allow_insecure) query.addQueryItem("allowInsecure", "1");
if (!stream->utlsFingerprint.isEmpty()) query.addQueryItem("fp", stream->utlsFingerprint);
if (stream->utlsFingerprint.isEmpty()) {
query.addQueryItem("fp", NekoGui::dataStore->utlsFingerprint);
} else {
query.addQueryItem("fp", stream->utlsFingerprint);
}

if (security == "reality") {
query.addQueryItem("pbk", stream->reality_pbk);
Expand Down
6 changes: 6 additions & 0 deletions fmt/Link2Bean.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ namespace NekoGui_fmt {
stream->reality_sid = GetQueryValue(query, "sid", "");
stream->reality_spx = GetQueryValue(query, "spx", "");
stream->utlsFingerprint = GetQueryValue(query, "fp", "");
if (stream->utlsFingerprint.isEmpty()) {
stream->utlsFingerprint = NekoGui::dataStore->utlsFingerprint;
}

// type
if (stream->network == "ws") {
Expand Down Expand Up @@ -184,6 +187,9 @@ namespace NekoGui_fmt {
stream->reality_sid = GetQueryValue(query, "sid", "");
stream->reality_spx = GetQueryValue(query, "spx", "");
stream->utlsFingerprint = GetQueryValue(query, "fp", "");
if (stream->utlsFingerprint.isEmpty()) {
stream->utlsFingerprint = NekoGui::dataStore->utlsFingerprint;
}

// type
if (stream->network == "ws") {
Expand Down
8 changes: 8 additions & 0 deletions sub/GroupUpdater.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,9 @@ namespace NekoGui_sub {
bean->stream->alpn = Node2QStringList(proxy["alpn"]).join(",");
bean->stream->allow_insecure = Node2Bool(proxy["skip-cert-verify"]);
bean->stream->utlsFingerprint = Node2QString(proxy["client-fingerprint"]);
if (bean->stream->utlsFingerprint.isEmpty()) {
bean->stream->utlsFingerprint = NekoGui::dataStore->utlsFingerprint;
}

// sing-mux
auto smux = NodeChild(proxy, {"smux"});
Expand Down Expand Up @@ -348,6 +351,11 @@ namespace NekoGui_sub {
bean->stream->alpn = Node2QStringList(proxy["alpn"]).join(",");
if (Node2Bool(proxy["tls"])) bean->stream->security = "tls";
if (Node2Bool(proxy["skip-cert-verify"])) bean->stream->allow_insecure = true;
bean->stream->utlsFingerprint = Node2QString(proxy["client-fingerprint"]);
bean->stream->utlsFingerprint = Node2QString(proxy["client-fingerprint"]);
if (bean->stream->utlsFingerprint.isEmpty()) {
bean->stream->utlsFingerprint = NekoGui::dataStore->utlsFingerprint;
}

// sing-mux
auto smux = NodeChild(proxy, {"smux"});
Expand Down
6 changes: 5 additions & 1 deletion ui/edit/dialog_edit_profile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,11 @@ void DialogEditProfile::typeSelected(const QString &newType) {
ui->host->setText(stream->host);
ui->sni->setText(stream->sni);
ui->alpn->setText(stream->alpn);
ui->utlsFingerprint->setCurrentText(stream->utlsFingerprint);
if (newEnt) {
ui->utlsFingerprint->setCurrentText(NekoGui::dataStore->utlsFingerprint);
} else {
ui->utlsFingerprint->setCurrentText(stream->utlsFingerprint);
}
ui->insecure->setChecked(stream->allow_insecure);
ui->header_type->setCurrentText(stream->header_type);
ui->ws_early_data_name->setText(stream->ws_early_data_name);
Expand Down

0 comments on commit a2fe705

Please sign in to comment.