-
Notifications
You must be signed in to change notification settings - Fork 1k
/
options.go
46 lines (37 loc) · 922 Bytes
/
options.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package relay
import (
"github.com/libp2p/go-libp2p/core/peer"
)
type Resources struct {
// MaxCircuits is the maximum number of active relay connections
MaxCircuits int
// MaxCircuitsPerPeer is the maximum number of active relay connections per peer
MaxCircuitsPerPeer int
// BufferSize is the buffer size for relaying in each direction
BufferSize int
}
func DefaultResources() Resources {
return Resources{
MaxCircuits: 1024,
MaxCircuitsPerPeer: 64,
BufferSize: 4096,
}
}
type ACLFilter interface {
AllowHop(src, dest peer.ID) bool
}
type Option func(r *Relay) error
// WithResources specifies resource limits for the relay
func WithResources(rc Resources) Option {
return func(r *Relay) error {
r.rc = rc
return nil
}
}
// WithACL specifies an ACLFilter for access control
func WithACL(acl ACLFilter) Option {
return func(r *Relay) error {
r.acl = acl
return nil
}
}