Skip to content
This repository has been archived by the owner on Mar 9, 2022. It is now read-only.

Commit

Permalink
refactor: use custom types
Browse files Browse the repository at this point in the history
This enables us to swap defaults in go-ipfs without touching the config
file generated during `ipfs init`

#146 (comment)
#146 (comment)
  • Loading branch information
lidel committed Oct 26, 2021
1 parent 0226122 commit 0fb5b58
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 15 deletions.
1 change: 1 addition & 0 deletions profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ fetching may be degraded.
c.Swarm.ConnMgr.LowWater = 20
c.Swarm.ConnMgr.HighWater = 40
c.Swarm.ConnMgr.GracePeriod = time.Minute.String()
c.Swarm.RelayService.Enabled = False
return nil
},
},
Expand Down
30 changes: 15 additions & 15 deletions swarm.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,11 @@ type SwarmConfig struct {
// `Transports.Relay` if specified.
DisableRelay bool `json:",omitempty"`

// DisableRelayService disables the limited relay (circuit v2 relay).
DisableRelayService bool

RelayServiceOpts RelayResources
RelayService RelayService

// EnableAutoRelay enables the "auto relay" feature.
//
// When both EnableAutoRelay and EnableRelayHop are set, this go-ipfs node
// When both EnableAutoRelay and RelayService.Enabled are set, this go-ipfs node
// will advertise itself as a public relay. Otherwise it will find and use
// advertised public relays when it determines that it's not reachable
// from the public internet.
Expand All @@ -39,36 +36,39 @@ type SwarmConfig struct {
ConnMgr ConnMgr
}

// RelayResources configures the resources of the relay.
// For any value set to 0, a reasonable default will be used.
type RelayResources struct {
// RelayService configures the resources of the circuit v2 relay.
// For every field a reasonable default will be defined in go-ipfs.
type RelayService struct {
// Enables the limited relay (circuit v2 relay).
Enabled Flag

// Limit is the (optional) relayed connection limits.
Limit RelayLimit

// ReservationTTL is the duration of a new (or refreshed reservation).
ReservationTTL Duration

// MaxReservations is the maximum number of active relay slots.
MaxReservations int
MaxReservations OptionalInteger
// MaxCircuits is the maximum number of open relay connections for each peer; defaults to 16.
MaxCircuits int
MaxCircuits OptionalInteger
// BufferSize is the size of the relayed connection buffers.
BufferSize int
BufferSize OptionalInteger

// MaxReservationsPerPeer is the maximum number of reservations originating from the same peer.
MaxReservationsPerPeer int
MaxReservationsPerPeer OptionalInteger
// MaxReservationsPerIP is the maximum number of reservations originating from the same IP address.
MaxReservationsPerIP int
MaxReservationsPerIP OptionalInteger
// MaxReservationsPerASN is the maximum number of reservations origination from the same ASN.
MaxReservationsPerASN int
MaxReservationsPerASN OptionalInteger
}

// RelayLimit are the per relayed connection resource limits.
type RelayLimit struct {
// Duration is the time limit before resetting a relayed connection.
Duration Duration
// Data is the limit of data relayed (on each direction) before resetting the connection.
Data int64
Data OptionalInteger
}

type Transports struct {
Expand Down

0 comments on commit 0fb5b58

Please sign in to comment.