mirror of
https://github.com/logos-messaging/logos-messaging-nim.git
synced 2026-05-11 21:09:27 +00:00
latest libp2p master & disable bootstrapping
This commit is contained in:
parent
8ef769e4fd
commit
648ddd194c
@ -347,7 +347,13 @@ proc processInput(rfd: AsyncFD, rng: ref HmacDrbgContext) {.async.} =
|
||||
continue
|
||||
kadBootstrapPeers.add((peerId, @[ma]))
|
||||
|
||||
node.wakuKademlia = WakuKademlia.new(node.switch, node.peerManager, kadBootstrapPeers)
|
||||
node.wakuKademlia = WakuKademlia.new(
|
||||
switch = node.switch,
|
||||
peerManager = node.peerManager,
|
||||
bootstrapNodes = kadBootstrapPeers,
|
||||
xprPublishing = false,
|
||||
disableBootstrapping = true,
|
||||
)
|
||||
|
||||
let catchRes = catch:
|
||||
node.switch.mount(node.wakuKademlia.protocol)
|
||||
|
||||
@ -11,121 +11,117 @@ import
|
||||
std/strutils
|
||||
import waku/waku_core
|
||||
|
||||
const
|
||||
defaultMetricsAddress* = parseIpAddress("127.0.0.1")
|
||||
const defaultMetricsAddress* = parseIpAddress("127.0.0.1")
|
||||
|
||||
type
|
||||
Chat2DiscoConf* = object ## General node config
|
||||
logLevel* {.
|
||||
desc: "Sets the log level.", defaultValue: LogLevel.INFO, name: "log-level"
|
||||
.}: LogLevel
|
||||
type Chat2DiscoConf* = object ## General node config
|
||||
logLevel* {.
|
||||
desc: "Sets the log level.", defaultValue: LogLevel.INFO, name: "log-level"
|
||||
.}: LogLevel
|
||||
|
||||
nodekey* {.desc: "P2P node private key as 64 char hex string.", name: "nodekey".}:
|
||||
Option[crypto.PrivateKey]
|
||||
nodekey* {.desc: "P2P node private key as 64 char hex string.", name: "nodekey".}:
|
||||
Option[crypto.PrivateKey]
|
||||
|
||||
listenAddress* {.
|
||||
defaultValue: defaultListenAddress(config),
|
||||
desc: "Listening address for the LibP2P traffic.",
|
||||
name: "listen-address"
|
||||
.}: IpAddress
|
||||
listenAddress* {.
|
||||
defaultValue: defaultListenAddress(config),
|
||||
desc: "Listening address for the LibP2P traffic.",
|
||||
name: "listen-address"
|
||||
.}: IpAddress
|
||||
|
||||
tcpPort* {.desc: "TCP listening port.", defaultValue: 60000, name: "tcp-port".}:
|
||||
Port
|
||||
tcpPort* {.desc: "TCP listening port.", defaultValue: 60000, name: "tcp-port".}: Port
|
||||
|
||||
udpPort* {.desc: "UDP listening port.", defaultValue: 60000, name: "udp-port".}:
|
||||
Port
|
||||
udpPort* {.desc: "UDP listening port.", defaultValue: 60000, name: "udp-port".}: Port
|
||||
|
||||
portsShift* {.
|
||||
desc: "Add a shift to all port numbers.", defaultValue: 0, name: "ports-shift"
|
||||
.}: uint16
|
||||
portsShift* {.
|
||||
desc: "Add a shift to all port numbers.", defaultValue: 0, name: "ports-shift"
|
||||
.}: uint16
|
||||
|
||||
nat* {.
|
||||
desc:
|
||||
"Specify method to use for determining public address. " &
|
||||
"Must be one of: any, none, upnp, pmp, extip:<IP>.",
|
||||
defaultValue: "any"
|
||||
.}: string
|
||||
nat* {.
|
||||
desc:
|
||||
"Specify method to use for determining public address. " &
|
||||
"Must be one of: any, none, upnp, pmp, extip:<IP>.",
|
||||
defaultValue: "any"
|
||||
.}: string
|
||||
|
||||
## Relay config
|
||||
relay* {.
|
||||
desc: "Enable relay protocol: true|false", defaultValue: true, name: "relay"
|
||||
.}: bool
|
||||
## Relay config
|
||||
relay* {.
|
||||
desc: "Enable relay protocol: true|false", defaultValue: true, name: "relay"
|
||||
.}: bool
|
||||
|
||||
keepAlive* {.
|
||||
desc: "Enable keep-alive for idle connections: true|false",
|
||||
defaultValue: false,
|
||||
name: "keep-alive"
|
||||
.}: bool
|
||||
keepAlive* {.
|
||||
desc: "Enable keep-alive for idle connections: true|false",
|
||||
defaultValue: false,
|
||||
name: "keep-alive"
|
||||
.}: bool
|
||||
|
||||
clusterId* {.
|
||||
desc:
|
||||
"Cluster id that the node is running in. Node in a different cluster id is disconnected.",
|
||||
defaultValue: 0,
|
||||
name: "cluster-id"
|
||||
.}: uint16
|
||||
clusterId* {.
|
||||
desc:
|
||||
"Cluster id that the node is running in. Node in a different cluster id is disconnected.",
|
||||
defaultValue: 0,
|
||||
name: "cluster-id"
|
||||
.}: uint16
|
||||
|
||||
shards* {.
|
||||
desc:
|
||||
"Shards index to subscribe to [0..NUM_SHARDS_IN_NETWORK-1]. Argument may be repeated.",
|
||||
defaultValue: @[uint16(0)],
|
||||
name: "shard"
|
||||
.}: seq[uint16]
|
||||
shards* {.
|
||||
desc:
|
||||
"Shards index to subscribe to [0..NUM_SHARDS_IN_NETWORK-1]. Argument may be repeated.",
|
||||
defaultValue: @[uint16(0)],
|
||||
name: "shard"
|
||||
.}: seq[uint16]
|
||||
|
||||
## Metrics config
|
||||
metricsServer* {.
|
||||
desc: "Enable the metrics server: true|false",
|
||||
defaultValue: false,
|
||||
name: "metrics-server"
|
||||
.}: bool
|
||||
## Metrics config
|
||||
metricsServer* {.
|
||||
desc: "Enable the metrics server: true|false",
|
||||
defaultValue: false,
|
||||
name: "metrics-server"
|
||||
.}: bool
|
||||
|
||||
metricsServerAddress* {.
|
||||
desc: "Listening address of the metrics server.",
|
||||
defaultValue: defaultMetricsAddress,
|
||||
name: "metrics-server-address"
|
||||
.}: IpAddress
|
||||
metricsServerAddress* {.
|
||||
desc: "Listening address of the metrics server.",
|
||||
defaultValue: defaultMetricsAddress,
|
||||
name: "metrics-server-address"
|
||||
.}: IpAddress
|
||||
|
||||
metricsServerPort* {.
|
||||
desc: "Listening HTTP port of the metrics server.",
|
||||
defaultValue: 8008,
|
||||
name: "metrics-server-port"
|
||||
.}: uint16
|
||||
metricsServerPort* {.
|
||||
desc: "Listening HTTP port of the metrics server.",
|
||||
defaultValue: 8008,
|
||||
name: "metrics-server-port"
|
||||
.}: uint16
|
||||
|
||||
metricsLogging* {.
|
||||
desc: "Enable metrics logging: true|false",
|
||||
defaultValue: true,
|
||||
name: "metrics-logging"
|
||||
.}: bool
|
||||
metricsLogging* {.
|
||||
desc: "Enable metrics logging: true|false",
|
||||
defaultValue: true,
|
||||
name: "metrics-logging"
|
||||
.}: bool
|
||||
|
||||
## Chat2 configuration
|
||||
contentTopic* {.
|
||||
desc: "Content topic for chat messages.",
|
||||
defaultValue: "/chat2disco/1/default/proto",
|
||||
name: "content-topic"
|
||||
.}: string
|
||||
## Chat2 configuration
|
||||
contentTopic* {.
|
||||
desc: "Content topic for chat messages.",
|
||||
defaultValue: "/chat2disco/1/default/proto",
|
||||
name: "content-topic"
|
||||
.}: string
|
||||
|
||||
## Websocket Configuration
|
||||
websocketSupport* {.
|
||||
desc: "Enable websocket: true|false",
|
||||
defaultValue: false,
|
||||
name: "websocket-support"
|
||||
.}: bool
|
||||
## Websocket Configuration
|
||||
websocketSupport* {.
|
||||
desc: "Enable websocket: true|false",
|
||||
defaultValue: false,
|
||||
name: "websocket-support"
|
||||
.}: bool
|
||||
|
||||
websocketPort* {.
|
||||
desc: "WebSocket listening port.", defaultValue: 8000, name: "websocket-port"
|
||||
.}: Port
|
||||
websocketPort* {.
|
||||
desc: "WebSocket listening port.", defaultValue: 8000, name: "websocket-port"
|
||||
.}: Port
|
||||
|
||||
websocketSecureSupport* {.
|
||||
desc: "WebSocket Secure Support.",
|
||||
defaultValue: false,
|
||||
name: "websocket-secure-support"
|
||||
.}: bool
|
||||
websocketSecureSupport* {.
|
||||
desc: "WebSocket Secure Support.",
|
||||
defaultValue: false,
|
||||
name: "websocket-secure-support"
|
||||
.}: bool
|
||||
|
||||
## Kademlia Discovery config
|
||||
kadBootstrapNodes* {.
|
||||
desc:
|
||||
"Peer multiaddr for kademlia discovery bootstrap node (must include /p2p/<peerID>). Argument may be repeated.",
|
||||
name: "kad-bootstrap-node"
|
||||
.}: seq[string]
|
||||
## Kademlia Discovery config
|
||||
kadBootstrapNodes* {.
|
||||
desc:
|
||||
"Peer multiaddr for kademlia discovery bootstrap node (must include /p2p/<peerID>). Argument may be repeated.",
|
||||
name: "kad-bootstrap-node"
|
||||
.}: seq[string]
|
||||
|
||||
# NOTE: Keys are different in nim-libp2p
|
||||
proc parseCmdArg*(T: type crypto.PrivateKey, p: string): T =
|
||||
|
||||
@ -27,7 +27,7 @@ requires "nim >= 2.2.4",
|
||||
"toml_serialization",
|
||||
"faststreams",
|
||||
# Networking & P2P
|
||||
"https://github.com/vacp2p/nim-libp2p.git#9b6fedca059f3c054582407be9268e2999c7d05d",
|
||||
"https://github.com/vacp2p/nim-libp2p.git#df777fc66cc100191dbefd3c222a4472b4d3b924",
|
||||
"eth",
|
||||
"nat_traversal",
|
||||
"dnsdisc",
|
||||
|
||||
@ -166,7 +166,8 @@ proc new*(
|
||||
bootstrapNodes: seq[(PeerId, seq[MultiAddress])] = @[],
|
||||
providedServices: seq[ServiceInfo] = @[],
|
||||
loopInterval: Duration = DefaultKademliaDiscoveryInterval,
|
||||
xprPublishing: bool = false,
|
||||
xprPublishing: bool = true,
|
||||
disableBootstrapping: bool = false,
|
||||
): T =
|
||||
if bootstrapNodes.len == 0:
|
||||
debug "creating kademlia discovery as seed node (no bootstrap nodes)"
|
||||
@ -174,8 +175,11 @@ proc new*(
|
||||
let kademlia = ServiceDiscovery.new(
|
||||
switch,
|
||||
bootstrapNodes = bootstrapNodes,
|
||||
config =
|
||||
KadDHTConfig.new(validator = ExtEntryValidator(), selector = ExtEntrySelector()),
|
||||
config = KadDHTConfig.new(
|
||||
validator = ExtEntryValidator(),
|
||||
selector = ExtEntrySelector(),
|
||||
disableBootstrapping = disableBootstrapping,
|
||||
),
|
||||
services = providedServices,
|
||||
xprPublishing = xprPublishing,
|
||||
)
|
||||
|
||||
@ -23,11 +23,11 @@ import
|
||||
const MaxConnections* = 50
|
||||
const MaxConnectionsPerPeer* = 1
|
||||
|
||||
proc withWsTransport*(b: SwitchBuilder): SwitchBuilder =
|
||||
#[ proc withWsTransport*(b: SwitchBuilder): SwitchBuilder =
|
||||
b.withTransport(
|
||||
proc(upgr: Upgrade, privateKey: crypto.PrivateKey): Transport =
|
||||
WsTransport.new(upgr)
|
||||
)
|
||||
) ]#
|
||||
|
||||
proc getSecureKey(path: string): TLSPrivateKey {.raises: [Defect, IOError].} =
|
||||
trace "Key path is.", path = path
|
||||
@ -47,7 +47,7 @@ proc getSecureCert(path: string): TLSCertificate {.raises: [Defect, IOError].} =
|
||||
except TLSStreamProtocolError as exc:
|
||||
info "exception raised from getSecureCert", err = exc.msg
|
||||
|
||||
proc withWssTransport*(
|
||||
#[ proc withWssTransport*(
|
||||
b: SwitchBuilder, secureKeyPath: string, secureCertPath: string
|
||||
): SwitchBuilder {.raises: [Defect, IOError].} =
|
||||
let key: TLSPrivateKey = getSecureKey(secureKeyPath)
|
||||
@ -56,7 +56,7 @@ proc withWssTransport*(
|
||||
tlsPrivateKey = key,
|
||||
tlsCertificate = cert,
|
||||
{TLSFlags.NoVerifyHost, TLSFlags.NoVerifyServerName}, # THIS IS INSECURE, NO?
|
||||
)
|
||||
) ]#
|
||||
|
||||
proc newWakuSwitch*(
|
||||
privKey = none(crypto.PrivateKey),
|
||||
@ -115,10 +115,10 @@ proc newWakuSwitch*(
|
||||
if wsAddress.isSome():
|
||||
b = b.withAddresses(@[wsAddress.get(), address])
|
||||
|
||||
if wssEnabled:
|
||||
#[ if wssEnabled:
|
||||
b = b.withWssTransport(secureKeyPath, secureCertPath)
|
||||
else:
|
||||
b = b.withWsTransport()
|
||||
b = b.withWsTransport() ]#
|
||||
else:
|
||||
b = b.withAddress(address)
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user