redirect method
Redirects connection to given proxy
.
Implementation
@override
Future<void> redirect(ProxySettings proxy) async {
final client = await SocksTCPClient.connect([proxy],
desiredAddress.type == InternetAddressType.unix
? ((await InternetAddress.lookup(desiredAddress.address))[0])
: desiredAddress,
desiredPort,
);
add([
0x05, // Socks version
0x00, // Succeeded
0x00, // Reserved byte
0x01, // IPv4
0x00, 0x00, 0x00, 0x00, // address 0.0.0.0
0x00, 0x00, // port 0
]);
await flush();
// "Link" streams
unawaited(addStream(client)
..then((value) {
close();
}).ignore(),);
unawaited(client.addStream(this)
..then((value) {
client.close();
}).ignore(),);
}