allows method

  1. @override
bool allows(
  1. dynamic operation
)
override

Checks if this permission allows the given operation.

Implementation

@override
bool allows(dynamic operation) {
  if (operation is! Map<String, dynamic>) return false;

  final opType = operation['type'];
  final opHost = operation['host'];
  final opPort = operation['port'];

  if (opType != 'network') return false;

  // Check if the operation is allowed
  final requiredConnect = operation['connect'] ?? false;
  final requiredListen = operation['listen'] ?? false;
  final requiredBind = operation['bind'] ?? false;

  if ((requiredConnect && !_connect) ||
      (requiredListen && !_listen) ||
      (requiredBind && !_bind)) {
    return false;
  }

  // Check host/port restrictions
  if (_host != null && opHost != null && opHost != _host) {
    return false;
  }
  if (_port != null && opPort != null && opPort != _port) {
    return false;
  }

  return true;
}