Skip to content

Commit

Permalink
refactor(config): Swarm.ForgeClient
Browse files Browse the repository at this point in the history
  • Loading branch information
lidel committed Sep 18, 2024
1 parent ecfc8d9 commit fe307da
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 9 deletions.
1 change: 0 additions & 1 deletion config/experiments.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ type Experiments struct {
OptimisticProvide bool
OptimisticProvideJobsPoolSize int
GatewayOverLibp2p bool `json:",omitempty"`
P2PForgeClient bool `json:",omitempty"`

GraphsyncEnabled graphsyncEnabled `json:",omitempty"`
AcceleratedDHTClient experimentalAcceleratedDHTClient `json:",omitempty"`
Expand Down
30 changes: 30 additions & 0 deletions config/forge.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package config

import p2pforge "github.com/ipshipyard/p2p-forge/client"

// ForgeClient includes optional configuration of p2p-forge client of service
// for obtaining a domain and TLS certificate to improve connectivity for web
// browser clients. More: https://github.com/ipshipyard/p2p-forge#readme
type ForgeClient struct {
// Enables the p2p-forge feature
Enabled Flag `json:",omitempty"`

// Optional override of the parent domain that will be used
ForgeDomain *OptionalString `json:",omitempty"`

// Optional override of HTTP API that acts as ACME DNS-01 Challenge broker
ForgeEndpoint *OptionalString `json:",omitempty"`

// Optional Authorization token, used with private/test instances of p2p-forge
ForgeAuth *OptionalString `json:",omitempty"`

// Optional override of CA ACME API used by p2p-forge system
CAEndpoint *OptionalString `json:",omitempty"`
}

const (
DefaultForgeEnabled = false // experimental, opt-in for now (https://github.com/ipfs/kubo/pull/10521)
DefaultForgeDomain = p2pforge.DefaultForgeDomain
DefaultForgeEndpoint = p2pforge.DefaultForgeEndpoint
DefaultCAEndpoint = p2pforge.DefaultCAEndpoint
)
4 changes: 4 additions & 0 deletions config/swarm.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ type SwarmConfig struct {

// ResourceMgr configures the libp2p Network Resource Manager
ResourceMgr ResourceMgr

// ForgeClient controls the client of a service for obtaining a domain
// and TLS certificate to improve connectivity for web browser clients.
ForgeClient ForgeClient
}

type RelayClient struct {
Expand Down
5 changes: 3 additions & 2 deletions core/node/groups.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ func LibP2P(bcfg *BuildCfg, cfg *config.Config, userResourceOverrides rcmgr.Part
enableRelayTransport := cfg.Swarm.Transports.Network.Relay.WithDefault(true) // nolint
enableRelayService := cfg.Swarm.RelayService.Enabled.WithDefault(enableRelayTransport)
enableRelayClient := cfg.Swarm.RelayClient.Enabled.WithDefault(enableRelayTransport)
enableForgeClient := cfg.Swarm.ForgeClient.Enabled.WithDefault(config.DefaultForgeEnabled)

// Log error when relay subsystem could not be initialized due to missing dependency
if !enableRelayTransport {
Expand All @@ -133,8 +134,8 @@ func LibP2P(bcfg *BuildCfg, cfg *config.Config, userResourceOverrides rcmgr.Part

// Services (resource management)
fx.Provide(libp2p.ResourceManager(cfg.Swarm, userResourceOverrides)),
maybeProvide(libp2p.P2PForgeCertMgr, cfg.Experimental.P2PForgeClient),
maybeInvoke(libp2p.StartP2PForgeCertMgr, cfg.Experimental.P2PForgeClient),
maybeProvide(libp2p.P2PForgeCertMgr, enableForgeClient),
maybeInvoke(libp2p.StartP2PForgeCertMgr, enableForgeClient),
fx.Provide(libp2p.AddrFilters(cfg.Swarm.AddrFilters)),
fx.Provide(libp2p.AddrsFactory(cfg.Addresses.Announce, cfg.Addresses.AppendAnnounce, cfg.Addresses.NoAnnounce)),
fx.Provide(libp2p.SmuxTransport(cfg.Swarm.Transports)),
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/kubo-as-a-library/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ require (
github.com/ipld/go-car/v2 v2.13.1 // indirect
github.com/ipld/go-codec-dagpb v1.6.0 // indirect
github.com/ipld/go-ipld-prime v0.21.0 // indirect
github.com/ipshipyard/p2p-forge v0.0.0-20240918214012-dbeb701d58c3 // indirect
github.com/ipshipyard/p2p-forge v0.0.0-20240918220446-2ecd19ac95e1 // indirect
github.com/jackpal/go-nat-pmp v1.0.2 // indirect
github.com/jbenet/go-temp-err-catcher v0.1.0 // indirect
github.com/jbenet/goprocess v0.1.4 // indirect
Expand Down
4 changes: 2 additions & 2 deletions docs/examples/kubo-as-a-library/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -375,8 +375,8 @@ github.com/ipld/go-ipld-prime v0.21.0 h1:n4JmcpOlPDIxBcY037SVfpd1G+Sj1nKZah0m6QH
github.com/ipld/go-ipld-prime v0.21.0/go.mod h1:3RLqy//ERg/y5oShXXdx5YIp50cFGOanyMctpPjsvxQ=
github.com/ipld/go-ipld-prime/storage/bsadapter v0.0.0-20230102063945-1a409dc236dd h1:gMlw/MhNr2Wtp5RwGdsW23cs+yCuj9k2ON7i9MiJlRo=
github.com/ipld/go-ipld-prime/storage/bsadapter v0.0.0-20230102063945-1a409dc236dd/go.mod h1:wZ8hH8UxeryOs4kJEJaiui/s00hDSbE37OKsL47g+Sw=
github.com/ipshipyard/p2p-forge v0.0.0-20240918214012-dbeb701d58c3 h1:U63TlIHVN9XX5Dk0pbKVfoD0fYe9gZvslTcin9ANy1E=
github.com/ipshipyard/p2p-forge v0.0.0-20240918214012-dbeb701d58c3/go.mod h1:0DQ69wQJ5Xxx9xOdP7S7yyF4OqqYcrcbWi0qKNcwC9Q=
github.com/ipshipyard/p2p-forge v0.0.0-20240918220446-2ecd19ac95e1 h1:tYfEXvR65J5Pyk7GRhLWunA6MyAXhnakmXoS9Q1y+r8=
github.com/ipshipyard/p2p-forge v0.0.0-20240918220446-2ecd19ac95e1/go.mod h1:0DQ69wQJ5Xxx9xOdP7S7yyF4OqqYcrcbWi0qKNcwC9Q=
github.com/jackpal/go-nat-pmp v1.0.2 h1:KzKSgb7qkJvOUTqYl9/Hg/me3pWgBmERKrTGD7BdWus=
github.com/jackpal/go-nat-pmp v1.0.2/go.mod h1:QPH045xvCAeXUZOxsnwmrtiCoxIr9eob+4orBN1SBKc=
github.com/jbenet/go-cienv v0.1.0 h1:Vc/s0QbQtoxX8MwwSLWWh+xNNZvM3Lw7NsTcHrvvhMc=
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ require (
github.com/ipld/go-car/v2 v2.13.1
github.com/ipld/go-codec-dagpb v1.6.0
github.com/ipld/go-ipld-prime v0.21.0
github.com/ipshipyard/p2p-forge v0.0.0-20240918214012-dbeb701d58c3
github.com/ipshipyard/p2p-forge v0.0.0-20240918220446-2ecd19ac95e1
github.com/jbenet/go-temp-err-catcher v0.1.0
github.com/jbenet/goprocess v0.1.4
github.com/julienschmidt/httprouter v1.3.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -444,8 +444,8 @@ github.com/ipld/go-ipld-prime v0.21.0 h1:n4JmcpOlPDIxBcY037SVfpd1G+Sj1nKZah0m6QH
github.com/ipld/go-ipld-prime v0.21.0/go.mod h1:3RLqy//ERg/y5oShXXdx5YIp50cFGOanyMctpPjsvxQ=
github.com/ipld/go-ipld-prime/storage/bsadapter v0.0.0-20230102063945-1a409dc236dd h1:gMlw/MhNr2Wtp5RwGdsW23cs+yCuj9k2ON7i9MiJlRo=
github.com/ipld/go-ipld-prime/storage/bsadapter v0.0.0-20230102063945-1a409dc236dd/go.mod h1:wZ8hH8UxeryOs4kJEJaiui/s00hDSbE37OKsL47g+Sw=
github.com/ipshipyard/p2p-forge v0.0.0-20240918214012-dbeb701d58c3 h1:U63TlIHVN9XX5Dk0pbKVfoD0fYe9gZvslTcin9ANy1E=
github.com/ipshipyard/p2p-forge v0.0.0-20240918214012-dbeb701d58c3/go.mod h1:0DQ69wQJ5Xxx9xOdP7S7yyF4OqqYcrcbWi0qKNcwC9Q=
github.com/ipshipyard/p2p-forge v0.0.0-20240918220446-2ecd19ac95e1 h1:tYfEXvR65J5Pyk7GRhLWunA6MyAXhnakmXoS9Q1y+r8=
github.com/ipshipyard/p2p-forge v0.0.0-20240918220446-2ecd19ac95e1/go.mod h1:0DQ69wQJ5Xxx9xOdP7S7yyF4OqqYcrcbWi0qKNcwC9Q=
github.com/jackpal/go-nat-pmp v1.0.2 h1:KzKSgb7qkJvOUTqYl9/Hg/me3pWgBmERKrTGD7BdWus=
github.com/jackpal/go-nat-pmp v1.0.2/go.mod h1:QPH045xvCAeXUZOxsnwmrtiCoxIr9eob+4orBN1SBKc=
github.com/jbenet/go-cienv v0.1.0 h1:Vc/s0QbQtoxX8MwwSLWWh+xNNZvM3Lw7NsTcHrvvhMc=
Expand Down

0 comments on commit fe307da

Please sign in to comment.