auto generate cert keys
This commit is contained in:
@@ -163,6 +163,11 @@ func (a *APIHandler) getHandler(c *gin.Context) {
|
|||||||
count := c.Query("c")
|
count := c.Query("c")
|
||||||
changes := a.ConfigService.GetChanges(actor, chngKey, count)
|
changes := a.ConfigService.GetChanges(actor, chngKey, count)
|
||||||
jsonObj(c, changes, nil)
|
jsonObj(c, changes, nil)
|
||||||
|
case "keypairs":
|
||||||
|
kType := c.Query("k")
|
||||||
|
options := c.Query("o")
|
||||||
|
keypair := a.ServerService.GenKeypair(kType, options)
|
||||||
|
jsonObj(c, keypair, nil)
|
||||||
default:
|
default:
|
||||||
jsonMsg(c, "API call", nil)
|
jsonMsg(c, "API call", nil)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -159,3 +159,23 @@ func (s *ServerService) GetLogs(service string, count string, level string) []st
|
|||||||
|
|
||||||
return lines
|
return lines
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *ServerService) GenKeypair(keyType string, options string) []string {
|
||||||
|
if len(keyType) == 0 {
|
||||||
|
return []string{"No keypair to generate"}
|
||||||
|
}
|
||||||
|
sbExec := s.GetBinaryPath()
|
||||||
|
cmdArgs := []string{"generate", keyType + "-keypair"}
|
||||||
|
if keyType == "tls" || keyType == "ech" {
|
||||||
|
cmdArgs = append(cmdArgs, options)
|
||||||
|
}
|
||||||
|
// Run the command
|
||||||
|
cmd := exec.Command(sbExec, cmdArgs...)
|
||||||
|
var out bytes.Buffer
|
||||||
|
cmd.Stdout = &out
|
||||||
|
err := cmd.Run()
|
||||||
|
if err != nil {
|
||||||
|
return []string{"Failed to generate keypair"}
|
||||||
|
}
|
||||||
|
return strings.Split(out.String(), "\n")
|
||||||
|
}
|
||||||
|
|||||||
@@ -30,9 +30,23 @@
|
|||||||
>{{ $t('tls.useText') }}</v-btn>
|
>{{ $t('tls.useText') }}</v-btn>
|
||||||
</v-btn-toggle>
|
</v-btn-toggle>
|
||||||
</v-col>
|
</v-col>
|
||||||
|
<v-spacer></v-spacer>
|
||||||
|
<v-col cols="auto">
|
||||||
|
<v-btn
|
||||||
|
variant="tonal"
|
||||||
|
density="compact"
|
||||||
|
icon="mdi-key-star"
|
||||||
|
@click="genECH"
|
||||||
|
:loading="loading">
|
||||||
|
<v-icon />
|
||||||
|
<v-tooltip activator="parent" location="top">
|
||||||
|
{{ $t('actions.generate') }}
|
||||||
|
</v-tooltip>
|
||||||
|
</v-btn>
|
||||||
|
</v-col>
|
||||||
</v-row>
|
</v-row>
|
||||||
<v-row v-if="useEchPath == 0">
|
<v-row v-if="useEchPath == 0">
|
||||||
<v-col cols="12" sm="6">
|
<v-col cols="12">
|
||||||
<v-text-field
|
<v-text-field
|
||||||
:label="$t('tls.keyPath')"
|
:label="$t('tls.keyPath')"
|
||||||
hide-details
|
hide-details
|
||||||
@@ -41,19 +55,21 @@
|
|||||||
</v-col>
|
</v-col>
|
||||||
</v-row>
|
</v-row>
|
||||||
<v-row v-else>
|
<v-row v-else>
|
||||||
<v-col cols="12" sm="6">
|
<v-col cols="12">
|
||||||
<v-textarea
|
<v-textarea
|
||||||
:label="$t('tls.key')"
|
:label="$t('tls.key')"
|
||||||
hide-details
|
hide-details
|
||||||
|
rows="3"
|
||||||
v-model="echKeyText">
|
v-model="echKeyText">
|
||||||
</v-textarea>
|
</v-textarea>
|
||||||
</v-col>
|
</v-col>
|
||||||
</v-row>
|
</v-row>
|
||||||
<v-row>
|
<v-row>
|
||||||
<v-col cols="12" sm="6">
|
<v-col cols="12">
|
||||||
<v-textarea
|
<v-textarea
|
||||||
:label="$t('tls.cert')"
|
:label="$t('tls.cert')"
|
||||||
hide-details
|
hide-details
|
||||||
|
rows="3"
|
||||||
v-model="echConfigText">
|
v-model="echConfigText">
|
||||||
</v-textarea>
|
</v-textarea>
|
||||||
</v-col>
|
</v-col>
|
||||||
@@ -63,15 +79,61 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
import { i18n } from '@/locales'
|
||||||
|
import HttpUtils from '@/plugins/httputil'
|
||||||
import { ech } from '@/types/inTls'
|
import { ech } from '@/types/inTls'
|
||||||
|
import { push } from 'notivue'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
props: ['iTls','oTls'],
|
props: ['iTls','oTls'],
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
useEchPath: 0
|
useEchPath: 0,
|
||||||
|
loading: false,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
methods: {
|
||||||
|
async genECH(){
|
||||||
|
this.loading = true
|
||||||
|
const msg = await HttpUtils.get('api/keypairs', { k: "ech", o: this.iTls.server_name?? "''" })
|
||||||
|
this.loading = false
|
||||||
|
if (msg.success && this.iTls.ech && this.oTls.ech) {
|
||||||
|
this.iTls.ech.key_path=undefined
|
||||||
|
this.useEchPath = 1
|
||||||
|
if (msg.obj.length>0){
|
||||||
|
let config = <string[]>[]
|
||||||
|
let key = <string[]>[]
|
||||||
|
let isConfig = false
|
||||||
|
let isKey = false
|
||||||
|
|
||||||
|
msg.obj.forEach((line:string) => {
|
||||||
|
if (line === "-----BEGIN ECH CONFIGS-----") {
|
||||||
|
isConfig = true
|
||||||
|
isKey = false
|
||||||
|
} else if (line === "-----END ECH CONFIGS-----") {
|
||||||
|
isConfig = false
|
||||||
|
} else if (line === "-----BEGIN ECH KEYS-----") {
|
||||||
|
isKey = true
|
||||||
|
isConfig = false
|
||||||
|
} else if (line === "-----END ECH KEYS-----") {
|
||||||
|
isKey = false
|
||||||
|
} else if (isConfig) {
|
||||||
|
config.push(line)
|
||||||
|
} else if (isKey) {
|
||||||
|
key.push(line)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
this.iTls.ech.key = key?? undefined
|
||||||
|
this.oTls.ech.config = config?? undefined
|
||||||
|
|
||||||
|
} else {
|
||||||
|
push.error({
|
||||||
|
message: i18n.global.t('error') + ": " + msg.obj
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
computed: {
|
computed: {
|
||||||
ech() {
|
ech() {
|
||||||
return <ech>this.$props.iTls.ech
|
return <ech>this.$props.iTls.ech
|
||||||
|
|||||||
@@ -90,6 +90,20 @@
|
|||||||
>{{ $t('tls.useText') }}</v-btn>
|
>{{ $t('tls.useText') }}</v-btn>
|
||||||
</v-btn-toggle>
|
</v-btn-toggle>
|
||||||
</v-col>
|
</v-col>
|
||||||
|
<v-spacer></v-spacer>
|
||||||
|
<v-col cols="auto">
|
||||||
|
<v-btn
|
||||||
|
variant="tonal"
|
||||||
|
density="compact"
|
||||||
|
icon="mdi-key-star"
|
||||||
|
@click="genSelfSigned"
|
||||||
|
:loading="loading">
|
||||||
|
<v-icon />
|
||||||
|
<v-tooltip activator="parent" location="top">
|
||||||
|
{{ $t('actions.generate') }}
|
||||||
|
</v-tooltip>
|
||||||
|
</v-btn>
|
||||||
|
</v-col>
|
||||||
</v-row>
|
</v-row>
|
||||||
<v-row v-if="usePath == 0">
|
<v-row v-if="usePath == 0">
|
||||||
<v-col cols="12" sm="6">
|
<v-col cols="12" sm="6">
|
||||||
@@ -108,14 +122,14 @@
|
|||||||
</v-col>
|
</v-col>
|
||||||
</v-row>
|
</v-row>
|
||||||
<v-row v-else>
|
<v-row v-else>
|
||||||
<v-col cols="12" sm="6">
|
<v-col cols="12">
|
||||||
<v-textarea
|
<v-textarea
|
||||||
:label="$t('tls.cert')"
|
:label="$t('tls.cert')"
|
||||||
hide-details
|
hide-details
|
||||||
v-model="certText">
|
v-model="certText">
|
||||||
</v-textarea>
|
</v-textarea>
|
||||||
</v-col>
|
</v-col>
|
||||||
<v-col cols="12" sm="6">
|
<v-col cols="12">
|
||||||
<v-textarea
|
<v-textarea
|
||||||
:label="$t('tls.key')"
|
:label="$t('tls.key')"
|
||||||
hide-details
|
hide-details
|
||||||
@@ -158,26 +172,42 @@
|
|||||||
v-model="server_port">
|
v-model="server_port">
|
||||||
</v-text-field>
|
</v-text-field>
|
||||||
</v-col>
|
</v-col>
|
||||||
|
<v-spacer></v-spacer>
|
||||||
|
<v-col cols="auto">
|
||||||
|
<v-btn
|
||||||
|
variant="tonal"
|
||||||
|
density="compact"
|
||||||
|
icon="mdi-key-star"
|
||||||
|
@click="genRealityKey"
|
||||||
|
:loading="loading">
|
||||||
|
<v-icon />
|
||||||
|
<v-tooltip activator="parent" location="top">
|
||||||
|
{{ $t('actions.generate') }}
|
||||||
|
</v-tooltip>
|
||||||
|
</v-btn>
|
||||||
|
</v-col>
|
||||||
</v-row>
|
</v-row>
|
||||||
<v-row>
|
<v-row>
|
||||||
<v-col cols="12" md="6">
|
<v-col cols="12">
|
||||||
<v-text-field
|
<v-text-field
|
||||||
:label="$t('tls.privKey')"
|
:label="$t('tls.privKey')"
|
||||||
hide-details
|
hide-details
|
||||||
v-model="inTls.reality.private_key">
|
v-model="inTls.reality.private_key">
|
||||||
</v-text-field>
|
</v-text-field>
|
||||||
</v-col>
|
</v-col>
|
||||||
<v-col cols="12" md="6">
|
<v-col cols="12">
|
||||||
<v-text-field
|
<v-text-field
|
||||||
:label="$t('tls.pubKey')"
|
:label="$t('tls.pubKey')"
|
||||||
hide-details
|
hide-details
|
||||||
v-model="outTls.reality.public_key">
|
v-model="outTls.reality.public_key">
|
||||||
</v-text-field>
|
</v-text-field>
|
||||||
</v-col>
|
</v-col>
|
||||||
<v-col cols="12" md="4">
|
<v-col cols="12">
|
||||||
<v-text-field
|
<v-text-field
|
||||||
label="Short IDs"
|
label="Short IDs"
|
||||||
hide-details
|
hide-details
|
||||||
|
append-icon="mdi-refresh"
|
||||||
|
@click:append="randomSID"
|
||||||
v-model="short_id">
|
v-model="short_id">
|
||||||
</v-text-field>
|
</v-text-field>
|
||||||
</v-col>
|
</v-col>
|
||||||
@@ -261,6 +291,10 @@ import { iTls, defaultInTls } from '@/types/inTls'
|
|||||||
import { oTls, defaultOutTls } from '@/types/outTls'
|
import { oTls, defaultOutTls } from '@/types/outTls'
|
||||||
import AcmeVue from '@/components/Acme.vue'
|
import AcmeVue from '@/components/Acme.vue'
|
||||||
import EchVue from '@/components/Ech.vue'
|
import EchVue from '@/components/Ech.vue'
|
||||||
|
import HttpUtils from '@/plugins/httputil'
|
||||||
|
import { push } from 'notivue'
|
||||||
|
import { i18n } from '@/locales'
|
||||||
|
import RandomUtil from '@/plugins/randomUtil'
|
||||||
export default {
|
export default {
|
||||||
props: ['visible', 'data', 'index'],
|
props: ['visible', 'data', 'index'],
|
||||||
emits: ['close', 'save'],
|
emits: ['close', 'save'],
|
||||||
@@ -334,7 +368,10 @@ export default {
|
|||||||
},
|
},
|
||||||
changeTlsType(){
|
changeTlsType(){
|
||||||
if (this.tlsType) {
|
if (this.tlsType) {
|
||||||
this.tls.server = <iTls>{ enabled: true, reality: { enabled: true, handshake: { server_port: 443 } }, server_name: "" }
|
this.tls.server = <iTls>{
|
||||||
|
enabled: true,
|
||||||
|
reality: { enabled: true, handshake: { server_port: 443 }, short_id: RandomUtil.randomShortId() },
|
||||||
|
server_name: "" }
|
||||||
this.tls.client = <oTls>{ reality: { public_key: "" } }
|
this.tls.client = <oTls>{ reality: { public_key: "" } }
|
||||||
} else {
|
} else {
|
||||||
this.tls.server = <iTls>{ enabled: true }
|
this.tls.server = <iTls>{ enabled: true }
|
||||||
@@ -350,6 +387,71 @@ export default {
|
|||||||
this.$emit('save', this.tls)
|
this.$emit('save', this.tls)
|
||||||
this.loading = false
|
this.loading = false
|
||||||
},
|
},
|
||||||
|
async genSelfSigned(){
|
||||||
|
this.loading = true
|
||||||
|
const msg = await HttpUtils.get('api/keypairs', { k: "tls", o: this.inTls.server_name?? "''" })
|
||||||
|
this.loading = false
|
||||||
|
if (msg.success) {
|
||||||
|
this.inTls.key_path=undefined
|
||||||
|
this.inTls.certificate_path=undefined
|
||||||
|
this.usePath = 1
|
||||||
|
if (msg.obj.length>0){
|
||||||
|
let privateKey = <string[]>[]
|
||||||
|
let publicKey = <string[]>[]
|
||||||
|
let isPrivateKey = false
|
||||||
|
let isPublicKey = false
|
||||||
|
|
||||||
|
msg.obj.forEach((line:string) => {
|
||||||
|
if (line === "-----BEGIN PRIVATE KEY-----") {
|
||||||
|
isPrivateKey = true
|
||||||
|
isPublicKey = false
|
||||||
|
} else if (line === "-----END PRIVATE KEY-----") {
|
||||||
|
isPrivateKey = false
|
||||||
|
} else if (line === "-----BEGIN CERTIFICATE-----") {
|
||||||
|
isPublicKey = true
|
||||||
|
isPrivateKey = false
|
||||||
|
} else if (line === "-----END CERTIFICATE-----") {
|
||||||
|
isPublicKey = false
|
||||||
|
} else if (isPrivateKey) {
|
||||||
|
privateKey.push(line)
|
||||||
|
} else if (isPublicKey) {
|
||||||
|
publicKey.push(line)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
this.inTls.key = privateKey?? undefined
|
||||||
|
this.inTls.certificate = publicKey?? undefined
|
||||||
|
|
||||||
|
} else {
|
||||||
|
push.error({
|
||||||
|
message: i18n.global.t('error') + ": " + msg.obj
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
async genRealityKey(){
|
||||||
|
this.loading = true
|
||||||
|
const msg = await HttpUtils.get('api/keypairs', { k: "reality" })
|
||||||
|
this.loading = false
|
||||||
|
if (msg.success) {
|
||||||
|
msg.obj.forEach((line:string) => {
|
||||||
|
if (this.inTls.reality && this.outTls.reality){
|
||||||
|
if (line.startsWith("PrivateKey")){
|
||||||
|
this.inTls.reality.private_key = line.substring(12)
|
||||||
|
}
|
||||||
|
if (line.startsWith("PublicKey")){
|
||||||
|
this.outTls.reality.public_key = line.substring(11)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
push.error({
|
||||||
|
message: i18n.global.t('error') + ": " + msg.obj
|
||||||
|
})
|
||||||
|
}
|
||||||
|
},
|
||||||
|
randomSID(){
|
||||||
|
this.short_id = RandomUtil.randomShortId().join(',')
|
||||||
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
inTls(): iTls {
|
inTls(): iTls {
|
||||||
|
|||||||
@@ -87,13 +87,14 @@ export default {
|
|||||||
actions: {
|
actions: {
|
||||||
action: "Action",
|
action: "Action",
|
||||||
add: "Add",
|
add: "Add",
|
||||||
new: "Add",
|
new: "New",
|
||||||
edit: "Edit",
|
edit: "Edit",
|
||||||
del: "Delete",
|
del: "Delete",
|
||||||
save: "Save",
|
save: "Save",
|
||||||
update: "Update",
|
update: "Update",
|
||||||
submit: "Submit",
|
submit: "Submit",
|
||||||
set: "Set",
|
set: "Set",
|
||||||
|
generate: "Generate",
|
||||||
disable: "Disable",
|
disable: "Disable",
|
||||||
close: "Close",
|
close: "Close",
|
||||||
restartApp: "Restart App",
|
restartApp: "Restart App",
|
||||||
|
|||||||
@@ -86,13 +86,14 @@ export default {
|
|||||||
actions: {
|
actions: {
|
||||||
action: "فرمان",
|
action: "فرمان",
|
||||||
add: "ایجاد",
|
add: "ایجاد",
|
||||||
new: "ایجاد",
|
new: "جدید",
|
||||||
edit: "ویرایش",
|
edit: "ویرایش",
|
||||||
del: "حذف",
|
del: "حذف",
|
||||||
save: "ذخیره",
|
save: "ذخیره",
|
||||||
update: "بروزرسانی",
|
update: "بروزرسانی",
|
||||||
submit: "ارسال",
|
submit: "ارسال",
|
||||||
set: "تنظیم",
|
set: "تنظیم",
|
||||||
|
generate: "تولید",
|
||||||
disable: "غیرفعال",
|
disable: "غیرفعال",
|
||||||
close: "بستن",
|
close: "بستن",
|
||||||
restartApp: "ریستارت پنل",
|
restartApp: "ریستارت پنل",
|
||||||
|
|||||||
@@ -87,13 +87,14 @@ export default {
|
|||||||
actions: {
|
actions: {
|
||||||
action: "Hành động",
|
action: "Hành động",
|
||||||
add: "Thêm",
|
add: "Thêm",
|
||||||
new: "Thêm",
|
new: "Mới",
|
||||||
edit: "Chỉnh sửa",
|
edit: "Chỉnh sửa",
|
||||||
del: "Xóa",
|
del: "Xóa",
|
||||||
save: "Lưu",
|
save: "Lưu",
|
||||||
update: "Cập nhật",
|
update: "Cập nhật",
|
||||||
submit: "Gửi",
|
submit: "Gửi",
|
||||||
set: "Đặt",
|
set: "Đặt",
|
||||||
|
generate: "Tạo ra",
|
||||||
disable: "Vô hiệu hóa",
|
disable: "Vô hiệu hóa",
|
||||||
close: "Đóng",
|
close: "Đóng",
|
||||||
restartApp: "Khởi động lại ứng dụng",
|
restartApp: "Khởi động lại ứng dụng",
|
||||||
|
|||||||
@@ -87,13 +87,14 @@ export default {
|
|||||||
actions: {
|
actions: {
|
||||||
action: "操作",
|
action: "操作",
|
||||||
add: "添加",
|
add: "添加",
|
||||||
new: "添加",
|
new: "新建",
|
||||||
edit: "编辑",
|
edit: "编辑",
|
||||||
del: "删除",
|
del: "删除",
|
||||||
save: "保存",
|
save: "保存",
|
||||||
update: "更新",
|
update: "更新",
|
||||||
submit: "提交",
|
submit: "提交",
|
||||||
set: "设置",
|
set: "设置",
|
||||||
|
generate: "生成",
|
||||||
disable: "禁用",
|
disable: "禁用",
|
||||||
close: "关闭",
|
close: "关闭",
|
||||||
restartApp: "重启面板",
|
restartApp: "重启面板",
|
||||||
|
|||||||
@@ -88,13 +88,14 @@ export default {
|
|||||||
actions: {
|
actions: {
|
||||||
action: "操作",
|
action: "操作",
|
||||||
add: "添加",
|
add: "添加",
|
||||||
new: "添加",
|
new: "新建",
|
||||||
edit: "編輯",
|
edit: "編輯",
|
||||||
del: "刪除",
|
del: "刪除",
|
||||||
save: "保存",
|
save: "保存",
|
||||||
update: "更新",
|
update: "更新",
|
||||||
submit: "提交",
|
submit: "提交",
|
||||||
set: "設置",
|
set: "設置",
|
||||||
|
generate: "生成",
|
||||||
disable: "禁用",
|
disable: "禁用",
|
||||||
close: "關閉",
|
close: "關閉",
|
||||||
restartApp: "重啟面板",
|
restartApp: "重啟面板",
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { Hysteria, Hysteria2, InTypes, Inbound, Naive, Shadowsocks, TUIC, Trojan, VLESS, VMess } from "@/types/inbounds"
|
import { Hysteria, Hysteria2, InTypes, Inbound, Naive, Shadowsocks, TUIC, Trojan, VLESS, VMess } from "@/types/inbounds"
|
||||||
import { HTTP, WebSocket, gRPC, HTTPUpgrade, Transport, TrspTypes } from "@/types/transport";
|
import { HTTP, WebSocket, gRPC, HTTPUpgrade, Transport, TrspTypes } from "@/types/transport"
|
||||||
|
import RandomUtil from "./randomUtil"
|
||||||
|
|
||||||
export interface Link {
|
export interface Link {
|
||||||
type: "local" | "external" | "sub"
|
type: "local" | "external" | "sub"
|
||||||
@@ -185,7 +186,7 @@ export namespace LinkUtil {
|
|||||||
allowInsecure: tlsClient?.insecure ? 1 : null,
|
allowInsecure: tlsClient?.insecure ? 1 : null,
|
||||||
fp: tlsClient?.utls?.enabled ? tlsClient.utls.fingerprint : null,
|
fp: tlsClient?.utls?.enabled ? tlsClient.utls.fingerprint : null,
|
||||||
pbk: tlsClient?.reality?.public_key?? null,
|
pbk: tlsClient?.reality?.public_key?? null,
|
||||||
sid: inbound.tls?.reality?.enabled ? (inbound.tls?.reality?.short_id?.length>0 ? inbound.tls.reality.short_id[0] : null) : null
|
sid: inbound.tls?.reality?.enabled ? (inbound.tls?.reality?.short_id?.length>0 ? inbound.tls.reality.short_id[RandomUtil.randomInt(inbound.tls.reality.short_id.length)] : null) : null
|
||||||
}
|
}
|
||||||
const uri = new URL(`vless://${u?.uuid}@${addr}:${inbound.listen_port}`)
|
const uri = new URL(`vless://${u?.uuid}@${addr}:${inbound.listen_port}`)
|
||||||
for (const [key, value] of Object.entries({...params, ...tParams})){
|
for (const [key, value] of Object.entries({...params, ...tParams})){
|
||||||
@@ -211,7 +212,7 @@ export namespace LinkUtil {
|
|||||||
allowInsecure: tlsClient?.insecure ? 1 : null,
|
allowInsecure: tlsClient?.insecure ? 1 : null,
|
||||||
fp: tlsClient?.utls?.enabled ? tlsClient.utls.fingerprint : null,
|
fp: tlsClient?.utls?.enabled ? tlsClient.utls.fingerprint : null,
|
||||||
pbk: tlsClient?.reality?.public_key?? null,
|
pbk: tlsClient?.reality?.public_key?? null,
|
||||||
sid: inbound.tls?.reality?.enabled ? (inbound.tls?.reality?.short_id?.length>0 ? inbound.tls.reality.short_id[0] : null) : null
|
sid: inbound.tls?.reality?.enabled ? (inbound.tls?.reality?.short_id?.length>0 ? inbound.tls.reality.short_id[RandomUtil.randomInt(inbound.tls.reality.short_id.length)] : null) : null
|
||||||
}
|
}
|
||||||
const uri = new URL(`trojan://${u?.password}@${addr}:${inbound.listen_port}`)
|
const uri = new URL(`trojan://${u?.password}@${addr}:${inbound.listen_port}`)
|
||||||
for (const [key, value] of Object.entries({...params, ...tParams})){
|
for (const [key, value] of Object.entries({...params, ...tParams})){
|
||||||
|
|||||||
@@ -35,8 +35,8 @@ const RandomUtil = {
|
|||||||
return btoa(String.fromCharCode(...array))
|
return btoa(String.fromCharCode(...array))
|
||||||
},
|
},
|
||||||
randomShortId(): string[] {
|
randomShortId(): string[] {
|
||||||
let shortIds = ['','','','']
|
let shortIds = new Array(24).fill('')
|
||||||
for (var ii = 0; ii < 4; ii++) {
|
for (var ii = 0; ii < 24; ii++) {
|
||||||
for (var jj = 0; jj < this.randomInt(8); jj++){
|
for (var jj = 0; jj < this.randomInt(8); jj++){
|
||||||
let randomNum = this.randomInt(256)
|
let randomNum = this.randomInt(256)
|
||||||
shortIds[ii] += ('0' + randomNum.toString(16)).slice(-2)
|
shortIds[ii] += ('0' + randomNum.toString(16)).slice(-2)
|
||||||
|
|||||||
Reference in New Issue
Block a user