Skip to content

Commit 2e6faf6

Browse files
authored
fix: generate correct keys for shadowsocks inbounds
1 parent f88b7b0 commit 2e6faf6

File tree

4 files changed

+12
-6
lines changed

4 files changed

+12
-6
lines changed

web/assets/js/model/inbound.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2150,7 +2150,7 @@ Inbound.TrojanSettings.Fallback = class extends XrayCommonClass {
21502150
Inbound.ShadowsocksSettings = class extends Inbound.Settings {
21512151
constructor(protocol,
21522152
method = SSMethods.BLAKE3_AES_256_GCM,
2153-
password = RandomUtil.randomShadowsocksPassword(),
2153+
password = '',
21542154
network = 'tcp,udp',
21552155
shadowsockses = [new Inbound.ShadowsocksSettings.Shadowsocks()],
21562156
ivCheck = false,
@@ -2188,7 +2188,7 @@ Inbound.ShadowsocksSettings = class extends Inbound.Settings {
21882188
Inbound.ShadowsocksSettings.Shadowsocks = class extends XrayCommonClass {
21892189
constructor(
21902190
method = '',
2191-
password = RandomUtil.randomShadowsocksPassword(),
2191+
password = '',
21922192
email = RandomUtil.randomLowerAndNum(8),
21932193
limitIp = 0,
21942194
totalGB = 0,

web/assets/js/util/index.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,14 @@ class RandomUtil {
138138
}
139139
}
140140

141-
static randomShadowsocksPassword() {
142-
const array = new Uint8Array(32);
141+
static randomShadowsocksPassword(method = SSMethods.BLAKE3_AES_256_GCM) {
142+
let length = 32;
143+
144+
if ([SSMethods.BLAKE3_AES_128_GCM].includes(method)) {
145+
length = 16;
146+
}
147+
148+
const array = new Uint8Array(length);
143149

144150
window.crypto.getRandomValues(array);
145151

web/html/form/client.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
<span>{{ i18n "reset" }}</span>
2323
</template>
2424
{{ i18n "password" }}
25-
<a-icon v-if="inbound.protocol === Protocols.SHADOWSOCKS"@click="client.password = RandomUtil.randomShadowsocksPassword()" type="sync"></a-icon>
25+
<a-icon v-if="inbound.protocol === Protocols.SHADOWSOCKS" @click="client.password = RandomUtil.randomShadowsocksPassword(inbound.settings.method)" type="sync"></a-icon>
2626
<a-icon v-if="inbound.protocol === Protocols.TROJAN" @click="client.password = RandomUtil.randomSeq(10)"type="sync"> </a-icon>
2727
</a-tooltip>
2828
</template>

web/html/form/protocol/shadowsocks.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
<a-tooltip>
3232
<template slot="title">
3333
<span>{{ i18n "reset" }}</span>
34-
</template> Password <a-icon @click="inbound.settings.password = RandomUtil.randomShadowsocksPassword()" type="sync"></a-icon>
34+
</template> Password <a-icon @click="inbound.settings.password = RandomUtil.randomShadowsocksPassword(inbound.settings.method)" type="sync"></a-icon>
3535
</a-tooltip>
3636
</template>
3737
<a-input v-model.trim="inbound.settings.password"></a-input>

0 commit comments

Comments
 (0)