diff --git a/CHANGELOG.md b/CHANGELOG.md index 2501de6a..03c14960 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - [#343](https://github.com/XenitAB/spegel/pull/343) Implement image event and add support for delete events. - [#344](https://github.com/XenitAB/spegel/pull/344) Add support for multi arch images. - [#347](https://github.com/XenitAB/spegel/pull/347) Add support for a custom http transport when proxying requests. +- [#352](https://github.com/XenitAB/spegel/pull/352) Add lip2p options to router. ### Changed diff --git a/pkg/routing/p2p.go b/pkg/routing/p2p.go index cd40c51e..f4dc98e8 100644 --- a/pkg/routing/p2p.go +++ b/pkg/routing/p2p.go @@ -35,7 +35,7 @@ type P2PRouter struct { registryPort uint16 } -func NewP2PRouter(ctx context.Context, addr string, bootstrapper Bootstrapper, registryPortStr string) (*P2PRouter, error) { +func NewP2PRouter(ctx context.Context, addr string, bootstrapper Bootstrapper, registryPortStr string, opts ...libp2p.Option) (*P2PRouter, error) { registryPort, err := strconv.ParseUint(registryPortStr, 10, 16) if err != nil { return nil, err @@ -65,11 +65,11 @@ func NewP2PRouter(ctx context.Context, addr string, bootstrapper Bootstrapper, r } return nil }) - opts := []libp2p.Option{ + opts = append(opts, libp2p.ListenAddrs(multiAddrs...), libp2p.PrometheusRegisterer(metrics.DefaultRegisterer), addrFactoryOpt, - } + ) host, err := libp2p.New(opts...) if err != nil { return nil, fmt.Errorf("could not create host: %w", err)