ceremonyclient/go-libp2p/p2p/protocol/identify/opts.go

50 lines
1.3 KiB
Go
Raw Normal View History

2023-08-21 03:50:38 +00:00
package identify
type config struct {
2024-06-08 11:32:45 +00:00
protocolVersion string
userAgent string
disableSignedPeerRecord bool
metricsTracer MetricsTracer
disableObservedAddrManager bool
2023-08-21 03:50:38 +00:00
}
// Option is an option function for identify.
type Option func(*config)
// ProtocolVersion sets the protocol version string that will be used to
// identify the family of protocols used by the peer.
func ProtocolVersion(s string) Option {
return func(cfg *config) {
cfg.protocolVersion = s
}
}
// UserAgent sets the user agent this node will identify itself with to peers.
func UserAgent(ua string) Option {
return func(cfg *config) {
cfg.userAgent = ua
}
}
// DisableSignedPeerRecord disables populating signed peer records on the outgoing Identify response
// and ONLY sends the unsigned addresses.
func DisableSignedPeerRecord() Option {
return func(cfg *config) {
cfg.disableSignedPeerRecord = true
}
}
func WithMetricsTracer(tr MetricsTracer) Option {
return func(cfg *config) {
cfg.metricsTracer = tr
}
}
2024-06-08 11:32:45 +00:00
// DisableObservedAddrManager disables the observed address manager. It also
// effectively disables the nat emitter and EvtNATDeviceTypeChanged
func DisableObservedAddrManager() Option {
return func(cfg *config) {
cfg.disableObservedAddrManager = true
}
}