mirror of
https://github.com/zizifn/edgetunnel
synced 2024-11-22 18:07:07 +00:00
unify code style
This commit is contained in:
parent
a85341bddb
commit
0ed139d896
@ -673,17 +673,26 @@ async function socks5Connect(addressType, addressRemote, portRemote, log) {
|
|||||||
// 1--> ipv4 addressLength =4
|
// 1--> ipv4 addressLength =4
|
||||||
// 2--> domain name
|
// 2--> domain name
|
||||||
// 3--> ipv6 addressLength =16
|
// 3--> ipv6 addressLength =16
|
||||||
let DSTADDR;
|
let DSTADDR; // DSTADDR = ATYP + DST.ADDR
|
||||||
if (addressType === 1) {
|
switch (addressType) {
|
||||||
DSTADDR = new Uint8Array([1, ...addressRemote.split('.').map(Number)]);
|
case 1:
|
||||||
} else if (addressType === 2) {
|
DSTADDR = new Uint8Array(
|
||||||
|
[1, ...addressRemote.split('.').map(Number)]
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
DSTADDR = new Uint8Array(
|
DSTADDR = new Uint8Array(
|
||||||
[3, addressRemote.length, ...encoder.encode(addressRemote)]
|
[3, addressRemote.length, ...encoder.encode(addressRemote)]
|
||||||
);
|
);
|
||||||
} else if (addressType === 3) {
|
break;
|
||||||
|
case 3:
|
||||||
DSTADDR = new Uint8Array(
|
DSTADDR = new Uint8Array(
|
||||||
[4, ...addressRemote.split(':').flatMap(x => [parseInt(x.slice(0, 2), 16), parseInt(x.slice(2), 16)])]
|
[4, ...addressRemote.split(':').flatMap(x => [parseInt(x.slice(0, 2), 16), parseInt(x.slice(2), 16)])]
|
||||||
)
|
);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
log(`invild addressType is ${addressType}`);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
const socksRequest = new Uint8Array([5, 1, 0, ...DSTADDR, portRemote >> 8, portRemote & 0xff]);
|
const socksRequest = new Uint8Array([5, 1, 0, ...DSTADDR, portRemote >> 8, portRemote & 0xff]);
|
||||||
await writer.write(socksRequest);
|
await writer.write(socksRequest);
|
||||||
|
Loading…
Reference in New Issue
Block a user