This commit is contained in:
MHSanaei 2026-05-13 01:23:51 +02:00
parent c7e838c95a
commit 525fcf2a5a
No known key found for this signature in database
GPG key ID: 7E4060F2FBE5AB7A
2 changed files with 21 additions and 20 deletions

View file

@ -687,8 +687,9 @@ export class HysteriaMasquerade extends XrayCommonClass {
} }
static fromJson(json = {}) { static fromJson(json = {}) {
const type = ['proxy', 'file', 'string'].includes(json.type) ? json.type : 'proxy';
return new HysteriaMasquerade( return new HysteriaMasquerade(
json.type, type,
json.dir, json.dir,
json.url, json.url,
json.rewriteHost, json.rewriteHost,

View file

@ -1673,29 +1673,22 @@ watch(
</template> </template>
<!-- ====== Hysteria Masquerade ====== --> <!-- ====== Hysteria Masquerade ====== -->
<!-- Per https://xtls.github.io/config/transports/hysteria.html#masqobject -->
<template v-if="protocol === Protocols.HYSTERIA"> <template v-if="protocol === Protocols.HYSTERIA">
<a-divider :style="{ margin: '12px 0' }">Masquerade</a-divider> <a-form-item label="Masquerade">
<a-form-item label="Enable">
<a-switch v-model:checked="inbound.stream.hysteria.masqueradeSwitch" /> <a-switch v-model:checked="inbound.stream.hysteria.masqueradeSwitch" />
</a-form-item> </a-form-item>
<template v-if="inbound.stream.hysteria.masqueradeSwitch"> <template v-if="inbound.stream.hysteria.masqueradeSwitch">
<a-form-item label="Type"> <a-form-item label="Type">
<a-select v-model:value="inbound.stream.hysteria.masquerade.type" :style="{ width: '50%' }"> <a-select v-model:value="inbound.stream.hysteria.masquerade.type" :style="{ width: '50%' }">
<a-select-option value="proxy">Proxy</a-select-option> <a-select-option value="proxy">Proxy</a-select-option>
<a-select-option value="http">HTTP</a-select-option>
<a-select-option value="file">File</a-select-option> <a-select-option value="file">File</a-select-option>
<a-select-option value="string">String</a-select-option> <a-select-option value="string">String</a-select-option>
<a-select-option value="404">404</a-select-option>
</a-select> </a-select>
</a-form-item> </a-form-item>
<!-- File type --> <!-- Proxy type: url / rewriteHost / insecure -->
<a-form-item v-if="inbound.stream.hysteria.masquerade.type === 'file'" label="Directory"> <template v-if="inbound.stream.hysteria.masquerade.type === 'proxy'">
<a-input v-model:value="inbound.stream.hysteria.masquerade.dir" placeholder="/path/to/www" />
</a-form-item>
<!-- HTTP type -->
<template v-if="inbound.stream.hysteria.masquerade.type === 'http'">
<a-form-item label="URL"> <a-form-item label="URL">
<a-input v-model:value="inbound.stream.hysteria.masquerade.url" placeholder="https://example.com" /> <a-input v-model:value="inbound.stream.hysteria.masquerade.url" placeholder="https://example.com" />
</a-form-item> </a-form-item>
@ -1705,6 +1698,19 @@ watch(
<a-form-item label="Insecure"> <a-form-item label="Insecure">
<a-switch v-model:checked="inbound.stream.hysteria.masquerade.insecure" /> <a-switch v-model:checked="inbound.stream.hysteria.masquerade.insecure" />
</a-form-item> </a-form-item>
</template>
<!-- File type: dir -->
<a-form-item v-if="inbound.stream.hysteria.masquerade.type === 'file'" label="Directory">
<a-input v-model:value="inbound.stream.hysteria.masquerade.dir" placeholder="/path/to/www" />
</a-form-item>
<!-- String type: content / statusCode / headers -->
<template v-if="inbound.stream.hysteria.masquerade.type === 'string'">
<a-form-item label="Content">
<a-textarea v-model:value="inbound.stream.hysteria.masquerade.content"
:auto-size="{ minRows: 2, maxRows: 6 }" />
</a-form-item>
<a-form-item label="Status Code"> <a-form-item label="Status Code">
<a-input-number v-model:value="inbound.stream.hysteria.masquerade.statusCode" :min="100" :max="599" <a-input-number v-model:value="inbound.stream.hysteria.masquerade.statusCode" :min="100" :max="599"
placeholder="200" /> placeholder="200" />
@ -1717,8 +1723,8 @@ watch(
</a-button> </a-button>
</a-form-item> </a-form-item>
<a-form-item v-if="inbound.stream.hysteria.masquerade.headers.length > 0" :wrapper-col="{ span: 24 }"> <a-form-item v-if="inbound.stream.hysteria.masquerade.headers.length > 0" :wrapper-col="{ span: 24 }">
<a-input-group v-for="(h, idx) in inbound.stream.hysteria.masquerade.headers" :key="`mh-${idx}`" compact <a-input-group v-for="(h, idx) in inbound.stream.hysteria.masquerade.headers" :key="`mh-${idx}`"
class="mb-8"> compact class="mb-8">
<a-input :style="{ width: '45%' }" v-model:value="h.name" placeholder="Name"> <a-input :style="{ width: '45%' }" v-model:value="h.name" placeholder="Name">
<template #addonBefore>{{ idx + 1 }}</template> <template #addonBefore>{{ idx + 1 }}</template>
</a-input> </a-input>
@ -1731,12 +1737,6 @@ watch(
</a-input-group> </a-input-group>
</a-form-item> </a-form-item>
</template> </template>
<!-- String type -->
<a-form-item v-if="inbound.stream.hysteria.masquerade.type === 'string'" label="Content">
<a-textarea v-model:value="inbound.stream.hysteria.masquerade.content"
:auto-size="{ minRows: 2, maxRows: 6 }" />
</a-form-item>
</template> </template>
</template> </template>
</a-form> </a-form>