mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-11-09 14:45:02 +03:00
perf(sub): decode TUIC and AmneziaWG settings once per request
genTuicLink and genAmneziaWGLink, and their Clash and JSON siblings, parsed the inbound's whole settings, every client included, for each link they built, bypassing the per-request caches the other generators use. Building the links of n clients of one inbound, as the export of all links does, cost n full parses of an n-client document. Typed per-request caches next to settingsByInbound now hold the decoded TUIC instance, indexed by email, and the AmneziaWG server block, and every generator reads through them.
This commit is contained in:
@@ -520,7 +520,7 @@ func TestSubJsonServiceWireguard(t *testing.T) {
|
||||
AllowedIPs: []string{"10.0.0.2/32", "fd00::2/128"},
|
||||
}
|
||||
|
||||
raw := NewSubJsonService("", "", "", "", nil).genWireguard(inbound, client)
|
||||
raw := NewSubJsonService("", "", "", "", nil).genWireguard(&SubService{}, inbound, client)
|
||||
if raw == nil {
|
||||
t.Fatal("genWireguard returned nil for a valid wireguard client")
|
||||
}
|
||||
@@ -564,7 +564,7 @@ func TestSubJsonServiceWireguardNoKey(t *testing.T) {
|
||||
inbound := &model.Inbound{Listen: "203.0.113.9", Port: 51820, Protocol: model.WireGuard, Settings: `{}`}
|
||||
client := model.Client{Email: "user"}
|
||||
|
||||
if raw := NewSubJsonService("", "", "", "", nil).genWireguard(inbound, client); raw != nil {
|
||||
if raw := NewSubJsonService("", "", "", "", nil).genWireguard(&SubService{}, inbound, client); raw != nil {
|
||||
t.Fatalf("genWireguard = %s, want nil for a keyless wireguard client", raw)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user