forward method

  1. @override
Future<void> forward({
  1. bool? allowIPv6,
})
override

Apply default handler to connection.

TCP: Forward connection to requested host.

UDP: Forward connections to respective hosts.

Implementation

@override
Future<void> forward({
  bool? allowIPv6,
}) async {
  // Accept proxy connection and connect to target
  final target = await accept(allowIPv6: allowIPv6, connect: true);
  if (target == null)
    return;

  // "Link" streams
  unawaited(addStream(target)
    ..then((value) {
      close();
    }).ignore(),);
  unawaited(target.addStream(this)
    ..then((value) {
      target.close();
    }).ignore(),);
}