make libp2p user agent overridable

This commit is contained in:
Richard Guan 2023-01-31 21:40:55 +09:00
parent 34576d0c64
commit a8dace0f23
2 changed files with 9 additions and 1 deletions

View File

@ -66,9 +66,10 @@ var (
ConnectionManagerKey = special{9} // Libp2p option
AutoNATSvcKey = special{10} // Libp2p option
BandwidthReporterKey = special{11} // Libp2p option
ConnGaterKey = special{12} // libp2p option
ConnGaterKey = special{12} // Libp2p option
DAGStoreKey = special{13} // constructor returns multiple values
ResourceManagerKey = special{14} // Libp2p option
UserAgentKey = special{15} // Libp2p option
)
type invoke int

View File

@ -114,3 +114,10 @@ func NilRouting(mctx helpers.MetricsCtx) (BaseIpfsRouting, error) {
func RoutedHost(rh RawHost, r BaseIpfsRouting) host.Host {
return routedhost.Wrap(rh, r)
}
func UserAgentOption(agent string) func() (opts Libp2pOpts, err error) {
return func() (opts Libp2pOpts, err error) {
opts.Opts = append(opts.Opts, libp2p.UserAgent(agent))
return
}
}