Skip to content

Commit

Permalink
Update helpers.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
vfarid committed May 31, 2024
1 parent f42aba2 commit d63a548
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/helpers.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { UUID, createHash } from "crypto"
import sha224 from 'crypto-js/sha224'
import CryptoJSHex from 'crypto-js/enc-hex'
import { v5 as uuidv5 } from "uuid"
import { Env, Config } from "./interfaces"
import { providersUri, proxiesUri } from "./variables"
Expand Down Expand Up @@ -27,7 +28,7 @@ export function IsValidUUID(uuid: string): boolean {
return /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(uuid)
}

export function GetVlessConfig(no: number, uuid: UUID, sni: string, address: string, port: number) {
export function GetVlessConfig(no: number, uuid: string, sni: string, address: string, port: number) {
if (address.toLowerCase() == sni.toLowerCase()) {
address = sni
}
Expand Down Expand Up @@ -136,10 +137,10 @@ export async function getProxies(env: Env): Promise<Array<string>> {
return proxyIPList
}

export function getUUID(sni: string) : UUID {
return uuidv5(sni.toLowerCase(), "ebc4a168-a6fe-47ce-bc25-6183c6212dcc") as UUID
export function getUUID(sni: string) : string {
return uuidv5(sni.toLowerCase(), "ebc4a168-a6fe-47ce-bc25-6183c6212dcc") as string
}

export function getSHA224Password(sni: string) : string {
return createHash("sha224").update(sni.toLowerCase()).digest("hex")
return sha224(sni.toLowerCase()).toString(CryptoJSHex)
}

0 comments on commit d63a548

Please sign in to comment.