enable dns choose for node-vless

This commit is contained in:
zizifn
2023-02-25 14:20:42 +08:00
committed by zizifn
parent 2945b57f91
commit b661925fcb
3 changed files with 5854 additions and 1830 deletions

View File

@@ -5,6 +5,7 @@ import { index401, serverStaticFile } from './app/utils';
import * as uuid from 'uuid';
import * as lodash from 'lodash';
import { createReadStream } from 'node:fs';
import { setDefaultResultOrder } from 'node:dns';
import {
makeReadableWebSocketStream,
processVlessHeader,
@@ -16,6 +17,12 @@ import { Duplex, Readable } from 'stream';
const port = process.env.PORT;
const userID = process.env.UUID || '';
//'ipv4first' or 'verbatim'
const dnOder = process.env.DNSORDER || 'verbatim';
if (dnOder === 'ipv4first') {
setDefaultResultOrder(dnOder);
}
let isVaildUser = uuid.validate(userID);
if (!isVaildUser) {
console.log('not set valid UUID');
@@ -191,6 +198,7 @@ async function connect2Remote(port, host, log: Function): Promise<Socket> {
{
port: port,
host: host,
autoSelectFamily: true,
},
() => {
log(`connected`);