Skip to content

Commit eb610a0

Browse files
committed
fix: improve error handling in resolveEncryptionFromDecryption function
1 parent 88b75c8 commit eb610a0

File tree

1 file changed

+22
-14
lines changed

1 file changed

+22
-14
lines changed

src/common/helpers/xray-config/resolve-public-key.ts

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -75,25 +75,33 @@ export async function resolveEncryptionFromDecryption(
7575
const encryptionMap = new Map<string, string>();
7676

7777
for (const inbound of inbounds) {
78-
if (inbound.protocol !== 'vless') {
79-
continue;
80-
}
78+
try {
79+
if (inbound.protocol !== 'vless') {
80+
continue;
81+
}
8182

82-
if (!inbound.settings) {
83-
continue;
84-
}
83+
if (!inbound.settings) {
84+
continue;
85+
}
8586

86-
if (!inbound.settings.decryption) {
87-
continue;
88-
}
87+
if (!inbound.settings.decryption) {
88+
continue;
89+
}
8990

90-
if (inbound.settings.decryption === 'none') {
91-
continue;
92-
}
91+
if (inbound.settings.decryption === 'none') {
92+
continue;
93+
}
9394

94-
const encryption = await generateEncryptionFromDecryption(inbound.settings.decryption);
95+
if (encryptionMap.has(inbound.tag)) {
96+
continue;
97+
}
98+
99+
const encryption = await generateEncryptionFromDecryption(inbound.settings.decryption);
95100

96-
encryptionMap.set(inbound.tag, encryption.encryption);
101+
encryptionMap.set(inbound.tag, encryption.encryption);
102+
} catch {
103+
continue;
104+
}
97105
}
98106

99107
return encryptionMap;

0 commit comments

Comments
 (0)