acceptAddressOnTCPPort method
Future<bool>
acceptAddressOnTCPPort(
- String address,
- int port, {
- bool sudo = false,
- required Set<
int> ? allowedPorts, - required bool allowAllPorts,
override
Add rule to accept connections on a specified TCP port
from the given address
.
address
: The address (IP or hostname) to accept connections from.port
: The TCP port number to accept connections on.sudo
: Whether elevated permissions are required to configure the port (default:false
).allowedPorts
: A set of allowed ports for validation. Ifnull
, validation is skipped.allowAllPorts
: Whether to allow connections on all ports, overridingallowedPorts
.
Returns a Future that completes with true
if the operation succeeded,
or false
if it failed.
Implementation
@override
Future<bool> acceptAddressOnTCPPort(String address, int port,
{bool sudo = false,
required Set<int>? allowedPorts,
required bool allowAllPorts}) async {
if (!allowAllPorts &&
(allowedPorts == null || !allowedPorts.contains(port))) {
return false;
}
acceptedAddressesOnPort.add((address, port));
return true;
}