2021-10-03 21:45:07 +00:00
|
|
|
|
package waku
|
|
|
|
|
|
2022-02-21 15:23:52 +00:00
|
|
|
|
import (
|
|
|
|
|
"time"
|
|
|
|
|
|
|
|
|
|
"github.com/urfave/cli/v2"
|
|
|
|
|
)
|
2021-11-06 13:20:22 +00:00
|
|
|
|
|
2022-07-25 15:28:17 +00:00
|
|
|
|
// RendezvousOptions are settings for enabling the rendezvous protocol for
|
|
|
|
|
// discovering new nodes
|
2021-10-03 21:45:07 +00:00
|
|
|
|
type RendezvousOptions struct {
|
2022-02-21 15:23:52 +00:00
|
|
|
|
Enable bool
|
|
|
|
|
Nodes cli.StringSlice
|
2021-10-03 21:45:07 +00:00
|
|
|
|
}
|
2021-11-17 16:19:42 +00:00
|
|
|
|
|
2022-07-25 15:28:17 +00:00
|
|
|
|
// RendezvousServerOptions are settings to enable the waku node to act as a
|
|
|
|
|
// rendezvous server
|
2021-10-03 21:45:07 +00:00
|
|
|
|
type RendezvousServerOptions struct {
|
2022-02-21 15:23:52 +00:00
|
|
|
|
Enable bool
|
|
|
|
|
DBPath string
|
2021-10-03 21:45:07 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-07-25 15:28:17 +00:00
|
|
|
|
// DiscV5Options are settings to enable a modified version of Ethereum’s Node
|
|
|
|
|
// Discovery Protocol v5 as a means for ambient node discovery.
|
2021-11-17 16:19:42 +00:00
|
|
|
|
type DiscV5Options struct {
|
2022-02-21 15:23:52 +00:00
|
|
|
|
Enable bool
|
|
|
|
|
Nodes cli.StringSlice
|
|
|
|
|
Port int
|
|
|
|
|
AutoUpdate bool
|
2021-11-17 16:19:42 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-07-25 15:28:17 +00:00
|
|
|
|
// RelayOptions are settings to enable the relay protocol which is a pubsub
|
|
|
|
|
// approach to peer-to-peer messaging with a strong focus on privacy,
|
|
|
|
|
// censorship-resistance, security and scalability.
|
2021-10-03 21:45:07 +00:00
|
|
|
|
type RelayOptions struct {
|
2022-02-21 15:23:52 +00:00
|
|
|
|
Enable bool
|
|
|
|
|
Topics cli.StringSlice
|
|
|
|
|
PeerExchange bool
|
|
|
|
|
MinRelayPeersToPublish int
|
2021-10-03 21:45:07 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-07-25 15:28:17 +00:00
|
|
|
|
// FilterOptions are settings used to enable filter protocol. This is a protocol
|
|
|
|
|
// that enables subscribing to messages that a peer receives. This is a more
|
|
|
|
|
// lightweight version of WakuRelay specifically designed for bandwidth
|
|
|
|
|
// restricted devices.
|
2021-10-03 21:45:07 +00:00
|
|
|
|
type FilterOptions struct {
|
2022-02-21 15:23:52 +00:00
|
|
|
|
Enable bool
|
|
|
|
|
DisableFullNode bool
|
|
|
|
|
Nodes cli.StringSlice
|
|
|
|
|
Timeout int
|
2021-10-03 21:45:07 +00:00
|
|
|
|
}
|
|
|
|
|
|
2021-10-09 18:18:53 +00:00
|
|
|
|
// LightpushOptions are settings used to enable the lightpush protocol. This is
|
|
|
|
|
// a lightweight protocol used to avoid having to run the relay protocol which
|
|
|
|
|
// is more resource intensive. With this protocol a message is pushed to a peer
|
|
|
|
|
// that supports both the lightpush protocol and relay protocol. That peer will
|
|
|
|
|
// broadcast the message and return a confirmation that the message was
|
|
|
|
|
// broadcasted
|
2021-10-03 21:45:07 +00:00
|
|
|
|
type LightpushOptions struct {
|
2022-02-21 15:23:52 +00:00
|
|
|
|
Enable bool
|
|
|
|
|
Nodes cli.StringSlice
|
2021-10-03 21:45:07 +00:00
|
|
|
|
}
|
|
|
|
|
|
2021-10-09 18:18:53 +00:00
|
|
|
|
// StoreOptions are settings used for enabling the store protocol, used to
|
|
|
|
|
// retrieve message history from other nodes as well as acting as a store
|
|
|
|
|
// node and provide message history to nodes that ask for it.
|
2021-10-03 21:45:07 +00:00
|
|
|
|
type StoreOptions struct {
|
2022-02-21 15:23:52 +00:00
|
|
|
|
Enable bool
|
2022-06-13 18:30:35 +00:00
|
|
|
|
PersistMessages bool
|
2022-02-21 15:23:52 +00:00
|
|
|
|
ShouldResume bool
|
2022-06-19 21:47:39 +00:00
|
|
|
|
RetentionMaxSeconds int
|
2022-02-21 15:23:52 +00:00
|
|
|
|
RetentionMaxMessages int
|
|
|
|
|
Nodes cli.StringSlice
|
2021-10-03 21:45:07 +00:00
|
|
|
|
}
|
|
|
|
|
|
2021-12-06 10:49:13 +00:00
|
|
|
|
// SwapOptions are settings used for configuring the swap protocol
|
|
|
|
|
type SwapOptions struct {
|
2022-06-19 21:47:39 +00:00
|
|
|
|
Enable bool
|
2022-02-21 15:23:52 +00:00
|
|
|
|
Mode int
|
|
|
|
|
PaymentThreshold int
|
|
|
|
|
DisconnectThreshold int
|
2021-12-06 10:49:13 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-06-19 21:47:39 +00:00
|
|
|
|
func (s *StoreOptions) RetentionMaxSecondsDuration() time.Duration {
|
|
|
|
|
return time.Duration(s.RetentionMaxSeconds) * time.Second
|
2021-11-06 13:20:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
2021-10-09 18:18:53 +00:00
|
|
|
|
// DNSDiscoveryOptions are settings used for enabling DNS-based discovery
|
|
|
|
|
// protocol that stores merkle trees in DNS records which contain connection
|
|
|
|
|
// information for nodes. It's very useful for bootstrapping a p2p network.
|
2021-10-03 21:45:07 +00:00
|
|
|
|
type DNSDiscoveryOptions struct {
|
2022-02-21 15:23:52 +00:00
|
|
|
|
Enable bool
|
|
|
|
|
URL string
|
|
|
|
|
Nameserver string
|
2021-10-03 21:45:07 +00:00
|
|
|
|
}
|
|
|
|
|
|
2021-10-09 18:18:53 +00:00
|
|
|
|
// MetricsOptions are settings used to start a prometheus server for obtaining
|
|
|
|
|
// useful node metrics to monitor the health of behavior of the go-waku node.
|
2021-10-03 21:45:07 +00:00
|
|
|
|
type MetricsOptions struct {
|
2022-02-21 15:23:52 +00:00
|
|
|
|
Enable bool
|
|
|
|
|
Address string
|
|
|
|
|
Port int
|
2021-10-03 21:45:07 +00:00
|
|
|
|
}
|
|
|
|
|
|
2021-11-02 09:54:34 +00:00
|
|
|
|
// RPCServerOptions are settings used to start a json rpc server
|
|
|
|
|
type RPCServerOptions struct {
|
2022-02-21 15:23:52 +00:00
|
|
|
|
Enable bool
|
|
|
|
|
Port int
|
|
|
|
|
Address string
|
2022-05-06 19:47:28 +00:00
|
|
|
|
Admin bool
|
|
|
|
|
Private bool
|
2021-11-02 09:54:34 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-07-25 15:28:17 +00:00
|
|
|
|
// WSOptions are settings used for enabling websockets and secure websockets
|
|
|
|
|
// support
|
2022-03-22 13:12:58 +00:00
|
|
|
|
type WSOptions struct {
|
|
|
|
|
Enable bool
|
|
|
|
|
Port int
|
|
|
|
|
Address string
|
|
|
|
|
Secure bool
|
|
|
|
|
KeyPath string
|
|
|
|
|
CertPath string
|
|
|
|
|
}
|
|
|
|
|
|
2021-10-09 18:18:53 +00:00
|
|
|
|
// Options contains all the available features and settings that can be
|
|
|
|
|
// configured via flags when executing go-waku as a service.
|
2021-10-03 21:45:07 +00:00
|
|
|
|
type Options struct {
|
2022-02-21 15:23:52 +00:00
|
|
|
|
Port int
|
|
|
|
|
Address string
|
2022-03-22 00:48:46 +00:00
|
|
|
|
Dns4DomainName string
|
2022-02-21 15:23:52 +00:00
|
|
|
|
NodeKey string
|
|
|
|
|
KeyFile string
|
2022-07-25 12:24:42 +00:00
|
|
|
|
KeyPasswd string
|
2022-02-21 15:23:52 +00:00
|
|
|
|
GenerateKey bool
|
|
|
|
|
Overwrite bool
|
|
|
|
|
StaticNodes cli.StringSlice
|
|
|
|
|
KeepAlive int
|
|
|
|
|
UseDB bool
|
|
|
|
|
DBPath string
|
|
|
|
|
AdvertiseAddress string
|
2022-06-19 21:47:39 +00:00
|
|
|
|
Version bool
|
2022-02-21 15:23:52 +00:00
|
|
|
|
ShowAddresses bool
|
|
|
|
|
LogLevel string
|
2022-06-01 20:03:26 +00:00
|
|
|
|
LogEncoding string
|
2022-06-13 18:30:35 +00:00
|
|
|
|
NAT string
|
2022-06-19 21:47:39 +00:00
|
|
|
|
PersistPeers bool
|
2022-02-21 15:23:52 +00:00
|
|
|
|
|
2022-03-22 13:12:58 +00:00
|
|
|
|
Websocket WSOptions
|
2022-02-21 15:23:52 +00:00
|
|
|
|
Relay RelayOptions
|
|
|
|
|
Store StoreOptions
|
|
|
|
|
Swap SwapOptions
|
|
|
|
|
Filter FilterOptions
|
|
|
|
|
LightPush LightpushOptions
|
|
|
|
|
DiscV5 DiscV5Options
|
|
|
|
|
Rendezvous RendezvousOptions
|
|
|
|
|
RendezvousServer RendezvousServerOptions
|
|
|
|
|
DNSDiscovery DNSDiscoveryOptions
|
|
|
|
|
Metrics MetricsOptions
|
|
|
|
|
RPCServer RPCServerOptions
|
2021-10-03 21:45:07 +00:00
|
|
|
|
}
|