github.com/ipni/storetheindex@v0.8.30/assigner/config/daemon.go (about)

     1  package config
     2  
     3  // Daemon stores daemon settings.
     4  type Daemon struct {
     5  	// HTTPAddr is the HTTP host multiaddr for receiving direct announce
     6  	// messages. Set to "none" to disable HTTP hosting.
     7  	HTTPAddr string
     8  	// P2PAddr is the libp2p host multiaddr for receiving announce messages.
     9  	// Set to "none" to disable libp2p hosting.
    10  	P2PAddr string
    11  	// NoResourceManager disables the libp2p resource manager when true.
    12  	NoResourceManager bool
    13  }
    14  
    15  // NewDaemon returns Addresses with values set to their defaults.
    16  func NewDaemon() Daemon {
    17  	return Daemon{
    18  		HTTPAddr: "/ip4/0.0.0.0/tcp/3001",
    19  		P2PAddr:  "/ip4/0.0.0.0/tcp/3003",
    20  	}
    21  }
    22  
    23  // populateUnset replaces zero-values in the config with default values.
    24  func (c *Daemon) populateUnset() {
    25  	def := NewDaemon()
    26  
    27  	if c.HTTPAddr == "" {
    28  		c.HTTPAddr = def.HTTPAddr
    29  	}
    30  	if c.P2PAddr == "" {
    31  		c.P2PAddr = def.P2PAddr
    32  	}
    33  }