Skip to content

Commit

Permalink
[ss] fix 128 bit shadowsocks password alireza0#208
Browse files Browse the repository at this point in the history
  • Loading branch information
alireza0 committed Oct 22, 2024
1 parent b019633 commit 5105c13
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 4 deletions.
25 changes: 22 additions & 3 deletions frontend/src/components/protocols/Shadowsocks.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,35 @@
hide-details
:label="$t('in.ssMethod')"
:items="ssMethods"
@update:model-value="changeMethod($event)"
v-model="data.method">
</v-select>
</v-col>
<v-col cols="12" sm="6" md="4">
<v-text-field v-model="data.password" :label="$t('types.pw')" hide-details></v-text-field>
</v-col>
<v-col cols="12" sm="6" md="4">
<Network :data="data" />
</v-col>
<v-col cols="12" sm="6" md="4" v-if="direction == 'out'">
<UoT :data="data" />
</v-col>
</v-row>
<v-row v-if="data.method.startsWith('2022')">
<v-col cols="12" sm="8">
<v-text-field
v-model="data.password"
:label="$t('types.pw')"
hide-details
append-inner-icon="mdi-refresh"
@click:append-inner="changeMethod(data.method)">
</v-text-field>
</v-col>
</v-row>
</v-card>
</template>

<script lang="ts">
import Network from '@/components/Network.vue'
import UoT from '@/components/UoT.vue';
import RandomUtil from '@/plugins/randomUtil';
export default {
props: ['direction','data'],
Expand All @@ -43,6 +53,15 @@ export default {
]
}
},
methods: {
changeMethod(ssMethod :string) {
if (ssMethod.startsWith('2022')) {
this.$props.data.password = ssMethod == "2022-blake3-aes-128-gcm" ? RandomUtil.randomShadowsocksPassword(16) : RandomUtil.randomShadowsocksPassword(32)
} else {
this.$props.data.password = ''
}
}
},
components: { Network, UoT }
}
</script>
2 changes: 1 addition & 1 deletion frontend/src/plugins/link.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export namespace LinkUtil {
}

function shadowsocksLink(user: Client, inbound: Shadowsocks, addrs: any[]): string[] {
const userPass = user.config.shadowsocks?.password
const userPass = inbound.method == "2022-blake3-aes-128-gcm" ? user.config.shadowsocks16?.password : user.config.shadowsocks?.password
const password = [userPass]
if (inbound.method.startsWith('2022')) password.push(inbound.password)
const params = {
Expand Down
4 changes: 4 additions & 0 deletions frontend/src/types/clients.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,5 +121,9 @@ export function randomConfigs(user: string): Config {
export function createClient<T extends Client>(json?: Partial<T>): Client {
defaultClient.name = RandomUtil.randomSeq(8)
const defaultObject: Client = { ...defaultClient, ...(json || {}) }

// Add missing config
defaultObject.config = { ...randomConfigs(defaultObject.name), ...defaultObject.config }

return defaultObject
}

0 comments on commit 5105c13

Please sign in to comment.