Skip to content

Commit 33ab05c

Browse files
committed
fixed read config (xxd) snapshot
1 parent 88e4f50 commit 33ab05c

10 files changed

Lines changed: 38 additions & 175 deletions

client/core/models/protocols/telemtProtocolConfig.cpp

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,6 @@ bool TelemtProtocolConfig::equalsDockerDeploymentSettings(const TelemtProtocolCo
9999
const auto normTransport = [](const QString &t) {
100100
return t.isEmpty() ? QString(protocols::telemt::transportModeStandard) : t;
101101
};
102-
const auto normWorkersMode = [](const QString &m) {
103-
return m.isEmpty() ? QString(protocols::telemt::workersModeAuto) : m;
104-
};
105102

106103
if (normPort(port) != normPort(other.port)) {
107104
return false;
@@ -133,18 +130,9 @@ bool TelemtProtocolConfig::equalsDockerDeploymentSettings(const TelemtProtocolCo
133130
if (userName != other.userName) {
134131
return false;
135132
}
136-
if (normWorkersMode(workersMode) != normWorkersMode(other.workersMode)) {
137-
return false;
138-
}
139-
if (workers != other.workers) {
140-
return false;
141-
}
142133
if (natEnabled != other.natEnabled) {
143134
return false;
144135
}
145-
if (natInternalIp != other.natInternalIp) {
146-
return false;
147-
}
148136
if (natExternalIp != other.natExternalIp) {
149137
return false;
150138
}

client/core/utils/constants/protocolConstants.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,10 @@ namespace amnezia
255255
constexpr char tlsEmulationKey[] = "telemt_tls_emulation";
256256
constexpr char useMiddleProxyKey[] = "telemt_use_middle_proxy";
257257
constexpr char userNameKey[] = "telemt_user_name";
258-
// Stored for UI only (Telemt server ignores these; same controls as MTProxy page)
258+
// additionalSecrets → extra_N users in [access.users]; natEnabled + natExternalIp →
259+
// [general] middle_proxy_nat_ip (single public IP, effective only when use_middle_proxy=true).
260+
// workers/workersMode/natInternalIp have no Telemt equivalent — kept for config compatibility,
261+
// not shown in UI and not written to config.toml.
259262
constexpr char additionalSecretsKey[] = "telemt_additional_secrets";
260263
constexpr char workersKey[] = "telemt_workers";
261264
constexpr char workersModeKey[] = "telemt_workers_mode";

client/core/utils/selfhosted/scriptsRegistry.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,14 @@ amnezia::ScriptVars amnezia::genTelemtVars(const ContainerConfig &containerConfi
375375
}
376376
}
377377
vars.append({ { "$TELEMT_ADDITIONAL_SECRETS", additionalList.join(QLatin1Char(',')) } });
378+
379+
// Telemt uses a single public IP override (middle_proxy_nat_ip), effective only in ME mode.
380+
// Empty → configure_container.sh omits the key and Telemt auto-detects via STUN.
381+
QString middleProxyNatIp;
382+
if (c.natEnabled && !c.natExternalIp.isEmpty()) {
383+
middleProxyNatIp = c.natExternalIp;
384+
}
385+
vars.append({ { "$TELEMT_MIDDLE_PROXY_NAT_IP", middleProxyNatIp } });
378386
}
379387

380388
return vars;

client/core/utils/selfhosted/sshSession.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,8 @@ QByteArray SshSession::getTextFileFromContainer(DockerContainer container, const
176176

177177
errorCode = ErrorCode::NoError;
178178

179-
QString script = QStringLiteral("sudo docker exec -i %1 sh -c \"xxd -p '%2'\"").arg(ContainerUtils::containerToString(container), path);
179+
QString script = QStringLiteral("sudo docker exec -i %1 sh -c \"xxd -p '%2' 2>/dev/null || od -An -v -tx1 '%2'\"")
180+
.arg(ContainerUtils::containerToString(container), path);
180181

181182
QString stdOut;
182183
auto cbReadStdOut = [&](const QString &data, libssh::Client &) {

client/server_scripts/telemt/configure_container.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ rm -f /data/config.toml
2828
if [ -n "$TELEMT_TAG" ]; then
2929
echo "ad_tag = \"$TELEMT_TAG\""
3030
fi
31+
if [ -n "$TELEMT_MIDDLE_PROXY_NAT_IP" ]; then
32+
echo "middle_proxy_nat_ip = \"$TELEMT_MIDDLE_PROXY_NAT_IP\""
33+
fi
3134
echo ""
3235
echo "[general.modes]"
3336
echo "classic = false"

client/ui/qml/Controls2/ListViewWithRadioButtonType.qml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ ListViewType {
2222

2323
property int selectedIndex: 0
2424

25+
// When set, the checkmark follows this value reactively (by matching delegate `name`),
26+
// so it stays correct after the bound value changes. Empty → fall back to selectedIndex.
27+
property string currentValue: ""
28+
2529
width: rootWidth
2630
height: root.contentItem.height
2731

@@ -131,7 +135,7 @@ ListViewType {
131135
}
132136

133137
ButtonGroup.group: buttonGroup
134-
checked: root.selectedIndex === index
138+
checked: root.currentValue !== "" ? (name === root.currentValue) : (root.selectedIndex === index)
135139

136140
onClicked: {
137141
root.selectedIndex = index

client/ui/qml/Pages2/PageProtocolXraySecuritySettings.qml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ PageType {
103103
drawerParent: root
104104
listView: ListViewWithRadioButtonType {
105105
rootWidth: root.width
106+
currentValue: alpn
106107
model: ListModel {
107108
Component.onCompleted: {
108109
var opts = XrayConfigModel.alpnOptions()
@@ -155,6 +156,7 @@ PageType {
155156
}
156157
}
157158
}
159+
currentValue: fingerprint
158160
clickedFunction: function () {
159161
fingerprint = selectedText
160162
tlsFingerprintDropDown.text = selectedText
@@ -225,6 +227,7 @@ PageType {
225227
}
226228
}
227229
}
230+
currentValue: fingerprint
228231
clickedFunction: function () {
229232
fingerprint = selectedText
230233
realityFingerprintDropDown.text = selectedText

client/ui/qml/Pages2/PageProtocolXrayTransportSettings.qml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,7 @@ PageType {
243243
drawerParent: root
244244
listView: ListViewWithRadioButtonType {
245245
rootWidth: root.width
246+
currentValue: xhttpMode
246247
model: ListModel {
247248
Component.onCompleted: {
248249
var opts = XrayConfigModel.xhttpModeOptions()
@@ -335,6 +336,7 @@ PageType {
335336
drawerParent: root
336337
listView: ListViewWithRadioButtonType {
337338
rootWidth: root.width
339+
currentValue: xhttpHeadersTemplate
338340
model: ListModel {
339341
Component.onCompleted: {
340342
var opts = XrayConfigModel.xhttpHeadersTemplateOptions()
@@ -379,6 +381,7 @@ PageType {
379381
drawerParent: root
380382
listView: ListViewWithRadioButtonType {
381383
rootWidth: root.width
384+
currentValue: xhttpUplinkMethod
382385
model: ListModel {
383386
Component.onCompleted: {
384387
var opts = XrayConfigModel.xhttpUplinkMethodOptions()
@@ -459,6 +462,7 @@ PageType {
459462
drawerParent: root
460463
listView: ListViewWithRadioButtonType {
461464
rootWidth: root.width
465+
currentValue: xhttpSessionPlacement
462466
model: ListModel {
463467
Component.onCompleted: {
464468
var opts = XrayConfigModel.xhttpSessionPlacementOptions()
@@ -503,6 +507,7 @@ PageType {
503507
drawerParent: root
504508
listView: ListViewWithRadioButtonType {
505509
rootWidth: root.width
510+
currentValue: xhttpSessionKey
506511
model: ListModel {
507512
Component.onCompleted: {
508513
var opts = XrayConfigModel.xhttpSessionKeyOptions()
@@ -547,6 +552,7 @@ PageType {
547552
drawerParent: root
548553
listView: ListViewWithRadioButtonType {
549554
rootWidth: root.width
555+
currentValue: xhttpSeqPlacement
550556
model: ListModel {
551557
Component.onCompleted: {
552558
var opts = XrayConfigModel.xhttpSeqPlacementOptions()
@@ -608,6 +614,7 @@ PageType {
608614
drawerParent: root
609615
listView: ListViewWithRadioButtonType {
610616
rootWidth: root.width
617+
currentValue: xhttpUplinkDataPlacement
611618
model: ListModel {
612619
Component.onCompleted: {
613620
var opts = XrayConfigModel.xhttpUplinkDataPlacementOptions()

client/ui/qml/Pages2/PageProtocolXrayXPaddingSettings.qml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ PageType {
120120
drawerParent: root
121121
listView: ListViewWithRadioButtonType {
122122
rootWidth: root.width
123+
currentValue: xPaddingPlacement
123124
model: ListModel {
124125
Component.onCompleted: {
125126
var opts = XrayConfigModel.xPaddingPlacementOptions()
@@ -164,6 +165,7 @@ PageType {
164165
drawerParent: root
165166
listView: ListViewWithRadioButtonType {
166167
rootWidth: root.width
168+
currentValue: xPaddingMethod
167169
model: ListModel {
168170
Component.onCompleted: {
169171
var opts = XrayConfigModel.xPaddingMethodOptions()

0 commit comments

Comments
 (0)