Why

In order to allow relays with custom properties, and to regulate resources, there needs to be a way to authenticate iroh nodes.

How

The general idea is to restrict the NodeIds that can connect to a relay, and use the fact, that this is already communicated in the initial handshake.

enum Access {
  /// Allows anyone
  Everyone,
  /// Will only allow nodes for which this function returns `true`
  Restricted(Box<Fn(NodeId) -> bool>),
}

// In the toml config we could add these options, for more complex use cases
// a custom iroh-relay binary is required, using a custom implementation of the 
// validator function of `Access::Restricted`

enum AccessConfig {
  /// Allows everyone
  Everyone,
  /// Allows only these
  Allowlist(Vec<NodeId>),
  /// Allows everyone, except these
  Denylist(Vec<NodeId>),
}

Benefits

Drawbacks