isAcceptedAddressOnPort method

Future<bool> isAcceptedAddressOnPort(
  1. String address,
  2. int port, {
  3. bool sudo = false,
  4. Set<int>? allowedPorts,
})

Checks whether a specific address is accepted on a TCP port. See also: listAcceptedAddressesOnTCPPorts.

  • address: The address to check.
  • port: The TCP port to check.
  • sudo: Whether sudo privileges should be used. Defaults to false.
  • allowedPorts: A set of allowed ports, or null to allow all ports.

Returns a Future that completes with true if the address is accepted on port, or false if it is not.

Implementation

Future<bool> isAcceptedAddressOnPort(String address, int port,
    {bool sudo = false, Set<int>? allowedPorts}) async {
  var accepts = await listAcceptedAddressesOnTCPPorts(
      sudo: sudo, allowedPorts: allowedPorts);
  var accepted = accepts.contains((address, port));
  return accepted;
}