2023-07-06 21:40:57 +00:00
|
|
|
|
package main
|
2021-10-03 21:45:07 +00:00
|
|
|
|
|
2022-02-21 15:23:52 +00:00
|
|
|
|
import (
|
2022-08-15 17:13:45 +00:00
|
|
|
|
"crypto/ecdsa"
|
2022-02-21 15:23:52 +00:00
|
|
|
|
"time"
|
|
|
|
|
|
2022-08-15 17:13:45 +00:00
|
|
|
|
"github.com/ethereum/go-ethereum/common"
|
|
|
|
|
"github.com/multiformats/go-multiaddr"
|
2022-02-21 15:23:52 +00:00
|
|
|
|
"github.com/urfave/cli/v2"
|
2023-05-02 15:10:45 +00:00
|
|
|
|
"github.com/waku-org/go-waku/waku/cliutils"
|
2022-02-21 15:23:52 +00:00
|
|
|
|
)
|
2021-11-06 13:20:22 +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
|
2023-01-12 02:20:23 +00:00
|
|
|
|
Port uint
|
2022-02-21 15:23:52 +00:00
|
|
|
|
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
|
2023-05-02 15:10:45 +00:00
|
|
|
|
ProtectedTopics []cliutils.ProtectedTopic
|
2022-02-21 15:23:52 +00:00
|
|
|
|
PeerExchange bool
|
|
|
|
|
MinRelayPeersToPublish int
|
2021-10-03 21:45:07 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-07-06 21:40:57 +00:00
|
|
|
|
// RLNRelayOptions are settings used to enable RLN Relay. This is a protocol
|
|
|
|
|
// used to rate limit messages and penalize those attempting to send more than
|
|
|
|
|
// N messages per epoch
|
2022-07-05 21:28:34 +00:00
|
|
|
|
type RLNRelayOptions struct {
|
|
|
|
|
Enable bool
|
2022-09-11 21:08:58 +00:00
|
|
|
|
CredentialsPath string
|
2022-11-08 20:20:08 +00:00
|
|
|
|
CredentialsPassword string
|
2023-08-01 18:15:01 +00:00
|
|
|
|
CredentialsIndex uint
|
2023-08-18 13:59:37 +00:00
|
|
|
|
TreePath string
|
2023-08-01 18:15:01 +00:00
|
|
|
|
MembershipGroupIndex uint
|
2022-07-05 21:28:34 +00:00
|
|
|
|
PubsubTopic string
|
|
|
|
|
ContentTopic string
|
|
|
|
|
Dynamic bool
|
2022-08-15 17:13:45 +00:00
|
|
|
|
ETHPrivateKey *ecdsa.PrivateKey
|
2022-07-05 21:28:34 +00:00
|
|
|
|
ETHClientAddress string
|
2022-08-15 17:13:45 +00:00
|
|
|
|
MembershipContractAddress common.Address
|
2022-07-05 21:28:34 +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
|
2023-04-13 19:28:46 +00:00
|
|
|
|
UseV1 bool
|
2022-02-21 15:23:52 +00:00
|
|
|
|
DisableFullNode bool
|
2022-08-15 17:13:45 +00:00
|
|
|
|
Nodes []multiaddr.Multiaddr
|
2023-04-13 19:28:46 +00:00
|
|
|
|
NodesV1 []multiaddr.Multiaddr
|
2022-08-15 17:13:45 +00:00
|
|
|
|
Timeout time.Duration
|
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
|
2022-08-15 17:13:45 +00:00
|
|
|
|
Nodes []multiaddr.Multiaddr
|
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-11-25 20:54:11 +00:00
|
|
|
|
DatabaseURL string
|
2022-08-15 17:13:45 +00:00
|
|
|
|
RetentionTime time.Duration
|
2022-02-21 15:23:52 +00:00
|
|
|
|
RetentionMaxMessages int
|
2022-11-25 20:54:11 +00:00
|
|
|
|
ResumeNodes []multiaddr.Multiaddr
|
2022-08-15 17:13:45 +00:00
|
|
|
|
Nodes []multiaddr.Multiaddr
|
2023-08-08 15:46:32 +00:00
|
|
|
|
Vacuum bool
|
|
|
|
|
Migration bool
|
2021-10-03 21:45:07 +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
|
2022-09-14 19:19:11 +00:00
|
|
|
|
URLs cli.StringSlice
|
2022-02-21 15:23:52 +00:00
|
|
|
|
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-10-20 13:18:23 +00:00
|
|
|
|
Enable bool
|
|
|
|
|
Port int
|
|
|
|
|
Address string
|
|
|
|
|
Admin bool
|
|
|
|
|
RelayCacheCapacity int
|
2021-11-02 09:54:34 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-07-24 20:51:42 +00:00
|
|
|
|
// RESTServerOptions are settings used to start a rest http server
|
|
|
|
|
type RESTServerOptions struct {
|
|
|
|
|
Enable bool
|
|
|
|
|
Port int
|
|
|
|
|
Address string
|
|
|
|
|
Admin bool
|
|
|
|
|
RelayCacheCapacity int
|
|
|
|
|
}
|
|
|
|
|
|
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
|
2022-08-25 20:36:04 +00:00
|
|
|
|
WSPort int
|
|
|
|
|
WSSPort int
|
2022-03-22 13:12:58 +00:00
|
|
|
|
Address string
|
|
|
|
|
Secure bool
|
|
|
|
|
KeyPath string
|
|
|
|
|
CertPath string
|
|
|
|
|
}
|
|
|
|
|
|
2022-10-23 13:13:43 +00:00
|
|
|
|
// PeerExchangeOptions are settings used with the peer exchange protocol
|
|
|
|
|
type PeerExchangeOptions struct {
|
|
|
|
|
Enable bool
|
|
|
|
|
Node *multiaddr.Multiaddr
|
|
|
|
|
}
|
|
|
|
|
|
2023-07-06 21:40:57 +00:00
|
|
|
|
// RendezvousOptions are settings used with the rendezvous protocol
|
2023-03-09 15:48:25 +00:00
|
|
|
|
type RendezvousOptions struct {
|
|
|
|
|
Enable bool
|
|
|
|
|
Nodes []multiaddr.Multiaddr
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-09 18:14:54 +00:00
|
|
|
|
// NodeOptions contains all the available features and settings that can be
|
2021-10-09 18:18:53 +00:00
|
|
|
|
// configured via flags when executing go-waku as a service.
|
2023-08-09 18:14:54 +00:00
|
|
|
|
type NodeOptions struct {
|
2023-05-24 15:34:35 +00:00
|
|
|
|
Port int
|
|
|
|
|
Address string
|
2023-07-06 21:40:57 +00:00
|
|
|
|
DNS4DomainName string
|
2023-05-24 15:34:35 +00:00
|
|
|
|
NodeKey *ecdsa.PrivateKey
|
|
|
|
|
KeyFile string
|
|
|
|
|
KeyPasswd string
|
|
|
|
|
StaticNodes []multiaddr.Multiaddr
|
|
|
|
|
KeepAlive time.Duration
|
|
|
|
|
AdvertiseAddresses []multiaddr.Multiaddr
|
|
|
|
|
ShowAddresses bool
|
|
|
|
|
CircuitRelay bool
|
|
|
|
|
ResourceScalingMemoryPercent float64
|
|
|
|
|
ResourceScalingFDPercent float64
|
|
|
|
|
LogLevel string
|
|
|
|
|
LogEncoding string
|
|
|
|
|
LogOutput string
|
|
|
|
|
NAT string
|
|
|
|
|
ExtIP string
|
|
|
|
|
PersistPeers bool
|
|
|
|
|
UserAgent string
|
|
|
|
|
PProf bool
|
2023-08-03 16:21:15 +00:00
|
|
|
|
MaxPeerConnections int
|
2022-02-21 15:23:52 +00:00
|
|
|
|
|
2022-10-23 13:13:43 +00:00
|
|
|
|
PeerExchange PeerExchangeOptions
|
2022-10-26 13:43:28 +00:00
|
|
|
|
Websocket WSOptions
|
|
|
|
|
Relay RelayOptions
|
|
|
|
|
Store StoreOptions
|
|
|
|
|
Filter FilterOptions
|
|
|
|
|
LightPush LightpushOptions
|
|
|
|
|
RLNRelay RLNRelayOptions
|
|
|
|
|
DiscV5 DiscV5Options
|
|
|
|
|
DNSDiscovery DNSDiscoveryOptions
|
2023-03-09 15:48:25 +00:00
|
|
|
|
Rendezvous RendezvousOptions
|
2022-10-26 13:43:28 +00:00
|
|
|
|
Metrics MetricsOptions
|
|
|
|
|
RPCServer RPCServerOptions
|
|
|
|
|
RESTServer RESTServerOptions
|
2021-10-03 21:45:07 +00:00
|
|
|
|
}
|