Skip to content

Commit a110650

Browse files
committed
last commit...
1 parent 88417dc commit a110650

4 files changed

Lines changed: 69 additions & 2 deletions

File tree

android/app/src/main/java/dev/c0redev/volter/ui/screens/ConfigsScreen.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -620,6 +620,7 @@ private fun ConfigEditorDialog(
620620
val cfg = Config(
621621
server = server,
622622
token = token,
623+
dexoteServerPub = parsedCfg?.dexoteServerPub,
623624
routes = routesOut,
624625
exclude = excludeOut,
625626
tunCIDR6 = tun6Out,

android/app/src/test/java/dev/c0redev/volter/domain/model/ConfigDexotePubTest.kt

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,26 @@ class ConfigDexotePubTest {
2020
val back = Config.fromJson(cfg.toJson())
2121
assertNull(back.dexoteServerPub)
2222
}
23+
24+
@Test
25+
fun fromJsonCarriesPub() {
26+
val pub = "AAECAwQFBgcICQoLDA0ODxA="
27+
val cfg = Config(server = "1.2.3.4:443", token = "tok", dexoteServerPub = pub)
28+
val parsed = Config.fromJson(cfg.toJson())
29+
assertEquals(pub, parsed.dexoteServerPub)
30+
}
31+
32+
@Test
33+
fun editorSaveRoundTripPreservesPub() {
34+
val pub = "Zm9vYmFyYmF6cXV4MTIzNDU2Nzg5MA=="
35+
val parsedCfg = Config.fromJson(
36+
Config(server = "5.6.7.8:443", token = "tok", dexoteServerPub = pub).toJson(),
37+
)
38+
val rebuilt = Config(
39+
server = parsedCfg.server,
40+
token = parsedCfg.token,
41+
dexoteServerPub = parsedCfg.dexoteServerPub,
42+
)
43+
assertEquals(pub, rebuilt.dexoteServerPub)
44+
}
2345
}

internal/tui/dexote_pub_test.go

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
package tui
2+
3+
import (
4+
"testing"
5+
6+
"dev.c0redev.volter/internal/config"
7+
)
8+
9+
func TestConfigFromConnFormInputsPreservesDexotePub(t *testing.T) {
10+
pub := "AAECAwQFBgcICQoLDA0ODxA="
11+
uri := config.BuildConnectionURI("1.2.3.4:443", "tok", pub)
12+
if uri == "" {
13+
t.Fatal("BuildConnectionURI returned empty")
14+
}
15+
16+
inputs := newInputsWithValues("name", uri, "", "", "", "auto", "", "", "", "", "")
17+
out, errMsg := configFromConnFormInputs(inputs)
18+
if errMsg != "" {
19+
t.Fatalf("configFromConnFormInputs error: %s", errMsg)
20+
}
21+
if out.Server != "1.2.3.4:443" || out.Token != "tok" {
22+
t.Fatalf("server/token mismatch: %q %q", out.Server, out.Token)
23+
}
24+
if out.DexoteServerPub != pub {
25+
t.Fatalf("dexote pub dropped: got %q want %q", out.DexoteServerPub, pub)
26+
}
27+
}
28+
29+
func TestConfigFromConnFormInputsNoPubStaysEmpty(t *testing.T) {
30+
uri := config.BuildConnectionURI("9.9.9.9:443", "tok")
31+
inputs := newInputsWithValues("name", uri, "", "", "", "auto", "", "", "", "", "")
32+
out, errMsg := configFromConnFormInputs(inputs)
33+
if errMsg != "" {
34+
t.Fatalf("configFromConnFormInputs error: %s", errMsg)
35+
}
36+
if out.DexoteServerPub != "" {
37+
t.Fatalf("expected empty pub, got %q", out.DexoteServerPub)
38+
}
39+
}

internal/tui/model.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1236,6 +1236,10 @@ func configFromConnFormInputs(inputs []textinput.Model) (config.Config, string)
12361236
if !ok {
12371237
return config.Config{}, "connection: volter://... или host:port:key"
12381238
}
1239+
dexotePub := ""
1240+
if cc, ccok := config.ParseConnectionConfig(connRaw); ccok {
1241+
dexotePub = cc.DexoteServerPub
1242+
}
12391243
managedCfg := config.Config{}
12401244
if vk, vok := config.ParseVoultKeyURI(connRaw); vok {
12411245
managedCfg = config.ConfigFromVoultKey(vk)
@@ -1263,6 +1267,7 @@ func configFromConnFormInputs(inputs []textinput.Model) (config.Config, string)
12631267
out := config.Config{
12641268
Server: server,
12651269
Token: token,
1270+
DexoteServerPub: dexotePub,
12661271
Routes: strings.TrimSpace(inputs[2].Value()),
12671272
Exclude: strings.TrimSpace(inputs[3].Value()),
12681273
TunCIDR6: strings.TrimSpace(inputs[4].Value()),
@@ -1710,7 +1715,7 @@ func (m *Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
17101715
m.editing = true
17111716
m.editingName = m.cloudNames[idx]
17121717
cfg := m.cloudCfgs[idx]
1713-
m.editInputs = newInputsWithValues(m.cloudNames[idx], config.BuildConnectionURI(cfg.Server, cfg.Token), cfg.Routes, cfg.Exclude, cfg.TunCIDR6,
1718+
m.editInputs = newInputsWithValues(m.cloudNames[idx], config.BuildConnectionURI(cfg.Server, cfg.Token, cfg.DexoteServerPub), cfg.Routes, cfg.Exclude, cfg.TunCIDR6,
17141719
cfg.Transport, cfg.QuicServer, cfg.QuicServerName, cfg.QuicSkipVerifyFormField(), cfg.QuicCertPinSHA256, cfg.QuicCaCert)
17151720
m.editFocus = 0
17161721
m.editInputs[0].Focus()
@@ -1755,7 +1760,7 @@ func (m *Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
17551760
m.editing = true
17561761
m.editingName = m.names[idx]
17571762
cfg := m.cfgs[idx]
1758-
m.editInputs = newInputsWithValues(m.names[idx], config.BuildConnectionURI(cfg.Server, cfg.Token), cfg.Routes, cfg.Exclude, cfg.TunCIDR6,
1763+
m.editInputs = newInputsWithValues(m.names[idx], config.BuildConnectionURI(cfg.Server, cfg.Token, cfg.DexoteServerPub), cfg.Routes, cfg.Exclude, cfg.TunCIDR6,
17591764
cfg.Transport, cfg.QuicServer, cfg.QuicServerName, cfg.QuicSkipVerifyFormField(), cfg.QuicCertPinSHA256, cfg.QuicCaCert)
17601765
m.editFocus = 0
17611766
m.editInputs[0].Focus()

0 commit comments

Comments
 (0)