mirror of
https://github.com/libp2p/go-libp2p-resource-manager.git
synced 2025-03-31 22:50:19 +08:00
Update allowlist design doc with no extra cost for happy path
This commit is contained in:
parent
374b297cee
commit
600191a10c
@ -112,6 +112,14 @@ func TestAllowedWithPeer(t *testing.T) {
|
|||||||
endpoint: multiaddrA,
|
endpoint: multiaddrA,
|
||||||
peer: peerA,
|
peer: peerA,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "allowed peer multiple ips in allowlist",
|
||||||
|
isConnAllowed: true,
|
||||||
|
isAllowedWithPeer: true,
|
||||||
|
allowlist: []string{"/ip4/1.2.3.4/p2p/" + peer.Encode(peerA), "/ip4/1.2.3.4/p2p/" + peer.Encode(peerA)},
|
||||||
|
endpoint: multiaddrA,
|
||||||
|
peer: peerA,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: "allowed peer multiple ips in allowlist",
|
name: "allowed peer multiple ips in allowlist",
|
||||||
isConnAllowed: true,
|
isConnAllowed: true,
|
||||||
|
@ -20,6 +20,8 @@ This is the problem that the Allowlist is designed to solve.
|
|||||||
- A peer may be able to open a connection, but after the handshake, if it's
|
- A peer may be able to open a connection, but after the handshake, if it's
|
||||||
not an expected peer id we move it to the normal system scope.
|
not an expected peer id we move it to the normal system scope.
|
||||||
- We can have multiple PeerIDs for a given IP addr.
|
- We can have multiple PeerIDs for a given IP addr.
|
||||||
|
- No extra cost for the happy path when we are still below system and transient
|
||||||
|
limits.
|
||||||
|
|
||||||
## Proposed change
|
## Proposed change
|
||||||
|
|
||||||
@ -38,11 +40,12 @@ For example, an allowlist set could look like:
|
|||||||
/ip4/1.2.3.0/ipcidr/24
|
/ip4/1.2.3.0/ipcidr/24
|
||||||
```
|
```
|
||||||
|
|
||||||
When a new connection is opened, the resource manager checks if the multiaddr
|
When a new connection is opened, the resource manager tries to allocate with the
|
||||||
matches an item in the set of allowlisted multiaddrs. If so, it creates the
|
normal system and transient resource scopes. If that fails, it checks if the
|
||||||
connection resource scope using the allowlisted specific system and transient
|
multiaddr matches an item in the set of allowlisted multiaddrs. If so, it
|
||||||
resource scopes. Otherwise, it uses the normal system and transient resource
|
creates the connection resource scope using the allowlisted specific system and
|
||||||
scopes as it does today.
|
transient resource scopes. If it wasn't an allowlisted multiaddr it fails as
|
||||||
|
before.
|
||||||
|
|
||||||
When an allowlisted connection is tied to a peer id and transfered with
|
When an allowlisted connection is tied to a peer id and transfered with
|
||||||
`ConnManagementScope.SetPeer`, we check if that peer id matches the expected
|
`ConnManagementScope.SetPeer`, we check if that peer id matches the expected
|
||||||
|
Loading…
Reference in New Issue
Block a user