add comment

This commit is contained in:
zizifn
2023-05-08 23:24:01 +08:00
committed by zizifn
parent a67ac7f58e
commit 6235ecfb17
5 changed files with 84 additions and 1 deletions

View File

@@ -141,6 +141,7 @@ vlessWServer.on('connection', async function connection(ws, request) {
} `;
if (hasError) {
controller.error(`[${address}:${portWithRandomLog}] ${message} `);
return;
}
// const addressType = requestAddr >> 42
// const addressLength = requestAddr & 0x0f;
@@ -148,6 +149,10 @@ vlessWServer.on('connection', async function connection(ws, request) {
vlessResponseHeader = new Uint8Array([vlessVersion![0], 0]);
const rawClientData = vlessBuffer.slice(rawDataIndex!);
if (isUDP) {
// 如果仅仅是针对DNS 这样是没有必要的。因为xray 客户端 DNS A/AAA query 都有长度 header
// 所以直接和 DNS server over TCP。所以无需 runtime 支持 UDP API。
// DNS over UDP 和 TCP 唯一的区别就是 Header section format 多了长度
// https://www.rfc-editor.org/rfc/rfc1035#section-4.2.2
udpClientStream = makeUDPSocketStream(portRemote, address);
const writer = udpClientStream.writable.getWriter();
writer.write(rawClientData).catch((error) => console.log);

View File

@@ -0,0 +1,72 @@
{
"log": {
"loglevel": "debug"
},
"inbounds": [
{
"listen": "0.0.0.0",
"port": "4080",
"protocol": "socks",
"settings": {
"auth": "noauth",
"udp": true,
"ip": "0.0.0.0"
}
},
{
"listen": "0.0.0.0",
"port": "4081",
"protocol": "http"
}
],
"dns": {
"servers": ["8.8.8.8"]
},
"outbounds": [
{
"protocol": "vless",
"settings": {
"vnext": [
{
"address": "127.0.0.1",
"port": 4200,
"users": [
{
"id": "e2839021-2313-427f-977c-a1b1dec79ace",
"encryption": "none",
"level": 0
}
]
}
]
},
"streamSettings": {
"network": "ws"
// "wsSettings": {
// "path": "/node-vless"
// }
// "security": "tls"
},
"tag": "zizi-ws"
},
{
"protocol": "freedom",
"tag": "direct"
}
],
"routing": {
"domainStrategy": "IPIfNonMatch",
"rules": [
{
"type": "field",
"ip": ["8.8.8.8"],
"outboundTag": "zizi-ws"
},
{
"type": "field",
"ip": ["geoip:private"],
"outboundTag": "zizi-ws"
}
]
}
}

1
client-config/readme.md Normal file
View File

@@ -0,0 +1 @@
# Test local with DNS proxy

View File

@@ -6158,6 +6158,7 @@ vlessWServer.on('connection', function connection(ws, request) {
portWithRandomLog = `${portRemote}--${Math.random()} ${isUDP ? 'udp ' : 'tcp '} `;
if (hasError) {
controller.error(`[${address}:${portWithRandomLog}] ${message} `);
return;
}
// const addressType = requestAddr >> 42
// const addressLength = requestAddr & 0x0f;
@@ -6165,6 +6166,10 @@ vlessWServer.on('connection', function connection(ws, request) {
vlessResponseHeader = new Uint8Array([vlessVersion[0], 0]);
const rawClientData = vlessBuffer.slice(rawDataIndex);
if (isUDP) {
// 如果仅仅是针对DNS 这样是没有必要的。因为xray 客户端 DNS A/AAA query 都有长度,
// 所以直接和 DNS server 建立 TCP 就可以。所以无需 runtime 支持 UDP API。
// DNS over UDP 和 TCP 唯一的区别就是 Header section format 多了长度
// https://www.rfc-editor.org/rfc/rfc1035#section-4.2.2
udpClientStream = makeUDPSocketStream(portRemote, address);
const writer = udpClientStream.writable.getWriter();
writer.write(rawClientData).catch((error) => console.log);

File diff suppressed because one or more lines are too long