The libp2p daemon can optionally use a Connection Manager to keep connection counts in check. The daemon exposes the manager through the API specified in this document.
At the moment, this is a living document. As such, it will be susceptible to changes until stabilization.
The data structures are defined in pb/p2pd.proto. All messages are varint-delimited. For the Connection Manager API, the relevant data types are:
ConnManagerRequest
All Connection Manager requests will be wrapped in a Request
message with Type: CONNMANAGER
.
Responses from the daemon will be in the form of a Response
.
Protocols described in pseudo-go. Items of the form [item, ...] are lists of many items.
Any response that may be an error, will take the form of:
Response{
Type: ERROR,
ErrorResponse: {
Msg: <error message>,
},
}
Clients can issue a TAG_PEER
request to add a tag to a peer.
Client
Request{
Type: CONNMANAGER,
ConnManager: ConnManagerRequest{
Type: TAG_PEER,
Peer: <peer id>,
Tag: <string>,
Weight: <int>,
},
}
Daemon Can return an error
Response{
Type: OK,
}
Clients can issue a UNTAG_PEER
request to remove a tag from a peer.
Client
Request{
Type: CONNMANAGER,
ConnManager: ConnManagerRequest{
Type: UNTAG_PEER,
Peer: <peer id>,
Tag: <string>,
},
}
Daemon Can return an error
Response{
Type: OK,
}
Clients can issue a TRIM
request to trim open connections.
Client
Request{
Type: CONNMANAGER,
ConnManager: ConnManagerRequest{
Type: TRIM,
},
}
Daemon Can return an error
Response{
Type: OK,
}