set log level to trace - not enabled by default
This commit is contained in:
parent
f9eed172d4
commit
1df16bdbce
|
@ -55,7 +55,7 @@ proc newChannel*(id: uint,
|
|||
proc writeHandler(data: seq[byte]): Future[void] {.async, gcsafe.} =
|
||||
# writes should happen in sequence
|
||||
await chan.asyncLock.acquire()
|
||||
info "writeHandler: sending data ", data = data.toHex(), id = chan.id
|
||||
trace "writeHandler: sending data ", data = data.toHex(), id = chan.id
|
||||
await conn.writeMsg(chan.id, chan.msgCode, data) # write header
|
||||
chan.asyncLock.release()
|
||||
|
||||
|
|
|
@ -105,7 +105,7 @@ proc handleConn(f: FloodSub,
|
|||
##
|
||||
|
||||
if conn.peerInfo.peerId.isNone:
|
||||
debug "no valid PeerId for peer"
|
||||
trace "no valid PeerId for peer"
|
||||
return
|
||||
|
||||
# create new pubsub peer
|
||||
|
|
|
@ -188,14 +188,14 @@ proc readMessage*(sconn: SecureConnection): Future[seq[byte]] {.async.} =
|
|||
if sconn.macCheckAndDecode(buf):
|
||||
result = buf
|
||||
else:
|
||||
debug "Message MAC verification failed", buf = toHex(buf)
|
||||
trace "Message MAC verification failed", buf = toHex(buf)
|
||||
else:
|
||||
debug "Received message header size is more then allowed",
|
||||
trace "Received message header size is more then allowed",
|
||||
length = length, allowed_length = SecioMaxMessageSize
|
||||
except AsyncStreamIncompleteError:
|
||||
debug "Connection dropped while reading"
|
||||
trace "Connection dropped while reading"
|
||||
except AsyncStreamReadError:
|
||||
debug "Error reading from connection"
|
||||
trace "Error reading from connection"
|
||||
|
||||
proc writeMessage*(sconn: SecureConnection, message: seq[byte]) {.async.} =
|
||||
## Write message ``message`` to secure connection ``sconn``.
|
||||
|
@ -215,7 +215,7 @@ proc writeMessage*(sconn: SecureConnection, message: seq[byte]) {.async.} =
|
|||
try:
|
||||
await sconn.conn.write(msg)
|
||||
except AsyncStreamWriteError:
|
||||
debug "Could not write to connection"
|
||||
trace "Could not write to connection"
|
||||
|
||||
proc newSecureConnection*(conn: Connection, hash: string, cipher: string,
|
||||
secrets: Secret,
|
||||
|
@ -292,7 +292,7 @@ proc handshake*(s: Secio, conn: Connection): Future[SecureConnection] {.async.}
|
|||
|
||||
localPeerId = PeerID.init(s.localPublicKey)
|
||||
|
||||
debug "Local proposal", schemes = SecioExchanges, ciphers = SecioCiphers,
|
||||
trace "Local proposal", schemes = SecioExchanges, ciphers = SecioCiphers,
|
||||
hashes = SecioHashes,
|
||||
pubkey = toHex(localBytesPubkey),
|
||||
peer = localPeerId
|
||||
|
@ -318,7 +318,7 @@ proc handshake*(s: Secio, conn: Connection): Future[SecureConnection] {.async.}
|
|||
|
||||
let order = getOrder(remoteBytesPubkey, localNonce, localBytesPubkey,
|
||||
remoteNonce)
|
||||
debug "Remote proposal", schemes = remoteExchanges, ciphers = remoteCiphers,
|
||||
trace "Remote proposal", schemes = remoteExchanges, ciphers = remoteCiphers,
|
||||
hashes = remoteHashes,
|
||||
pubkey = toHex(remoteBytesPubkey), order = order,
|
||||
peer = remotePeerId
|
||||
|
@ -327,10 +327,10 @@ proc handshake*(s: Secio, conn: Connection): Future[SecureConnection] {.async.}
|
|||
let cipher = selectBest(order, SecioCiphers, remoteCiphers)
|
||||
let hash = selectBest(order, SecioHashes, remoteHashes)
|
||||
if len(scheme) == 0 or len(cipher) == 0 or len(hash) == 0:
|
||||
debug "No algorithms in common", peer = remotePeerId
|
||||
trace "No algorithms in common", peer = remotePeerId
|
||||
return
|
||||
|
||||
debug "Encryption scheme selected", scheme = scheme, cipher = cipher,
|
||||
trace "Encryption scheme selected", scheme = scheme, cipher = cipher,
|
||||
hash = hash
|
||||
|
||||
var ekeypair = ephemeral(scheme)
|
||||
|
@ -357,15 +357,15 @@ proc handshake*(s: Secio, conn: Connection): Future[SecureConnection] {.async.}
|
|||
|
||||
var remoteCorpus = answer & request[4..^1] & remoteEBytesPubkey
|
||||
if not remoteESignature.verify(remoteCorpus, remotePubkey):
|
||||
debug "Signature verification failed", scheme = remotePubkey.scheme,
|
||||
trace "Signature verification failed", scheme = remotePubkey.scheme,
|
||||
signature = remoteESignature, pubkey = remotePubkey,
|
||||
corpus = remoteCorpus
|
||||
return
|
||||
|
||||
debug "Signature verified", scheme = remotePubkey.scheme
|
||||
trace "Signature verified", scheme = remotePubkey.scheme
|
||||
|
||||
if not remoteEPubkey.eckey.initRaw(remoteEBytesPubkey):
|
||||
debug "Remote ephemeral public key incorrect or corrupted",
|
||||
trace "Remote ephemeral public key incorrect or corrupted",
|
||||
pubkey = toHex(remoteEBytesPubkey)
|
||||
return
|
||||
|
||||
|
@ -393,11 +393,11 @@ proc handshake*(s: Secio, conn: Connection): Future[SecureConnection] {.async.}
|
|||
var res = await result.readMessage()
|
||||
|
||||
if res != @localNonce:
|
||||
debug "Nonce verification failed", receivedNonce = toHex(res),
|
||||
trace "Nonce verification failed", receivedNonce = toHex(res),
|
||||
localNonce = toHex(localNonce)
|
||||
raise newException(CatchableError, "Nonce verification failed")
|
||||
else:
|
||||
debug "Secure handshake succeeded"
|
||||
trace "Secure handshake succeeded"
|
||||
|
||||
proc readLoop(sconn: SecureConnection, stream: BufferStream) {.async.} =
|
||||
while not sconn.conn.closed:
|
||||
|
@ -413,7 +413,7 @@ proc readLoop(sconn: SecureConnection, stream: BufferStream) {.async.} =
|
|||
proc handleConn(s: Secio, conn: Connection): Future[Connection] {.async.} =
|
||||
var sconn = await s.handshake(conn)
|
||||
proc writeHandler(data: seq[byte]) {.async, gcsafe.} =
|
||||
debug "sending encrypted bytes", bytes = data.toHex()
|
||||
trace "sending encrypted bytes", bytes = data.toHex()
|
||||
await sconn.writeMessage(data)
|
||||
|
||||
var stream = newBufferStream(writeHandler)
|
||||
|
|
|
@ -288,7 +288,7 @@ proc newSwitch*(peerInfo: PeerInfo,
|
|||
|
||||
let s = result # can't capture result
|
||||
result.streamHandler = proc(stream: Connection) {.async, gcsafe.} =
|
||||
debug "handling connection for", peerInfo = stream.peerInfo
|
||||
trace "handling connection for", peerInfo = stream.peerInfo
|
||||
await s.ms.handle(stream) # handle incoming connection
|
||||
|
||||
result.mount(identity)
|
||||
|
|
|
@ -67,7 +67,7 @@ method listen*(t: TcpTransport,
|
|||
# always get the resolved address in case we're bound to 0.0.0.0:0
|
||||
t.ma = MultiAddress.init(t.server.sock.getLocalAddress())
|
||||
result = t.server.join()
|
||||
debug "started node on", address = t.ma
|
||||
trace "started node on", address = t.ma
|
||||
|
||||
method dial*(t: TcpTransport,
|
||||
address: MultiAddress):
|
||||
|
|
|
@ -47,7 +47,7 @@ method listen*(t: Transport,
|
|||
## listen for incoming connections
|
||||
t.ma = ma
|
||||
t.handler = handler
|
||||
debug "starting node", address = $ma
|
||||
trace "starting node", address = $ma
|
||||
|
||||
method dial*(t: Transport,
|
||||
address: MultiAddress):
|
||||
|
|
|
@ -76,13 +76,13 @@ proc main() {.async.} =
|
|||
await switch.subscribeToPeer(remotePeer)
|
||||
|
||||
proc handler(topic: string, data: seq[byte]): Future[void] {.closure, gcsafe.} =
|
||||
debug "IN HANDLER"
|
||||
trace "IN HANDLER"
|
||||
|
||||
let topic = Base58.encode(cast[seq[byte]]("chat"))
|
||||
await switch.subscribe(topic, handler)
|
||||
let msg = cast[seq[byte]]("hello from nim")
|
||||
await switch.publish(topic, msg)
|
||||
# debug "published message from test"
|
||||
# trace "published message from test"
|
||||
# TODO: for some reason the connection closes unless I do a forever loop
|
||||
await allFutures(libp2pFuts)
|
||||
|
||||
|
|
|
@ -237,7 +237,7 @@ suite "Mplex":
|
|||
mplexListen.streamHandler = handleMplexListen
|
||||
listenFut = mplexListen.handle()
|
||||
listenFut.addCallback(proc(udata: pointer) {.gcsafe.}
|
||||
= debug "completed listener")
|
||||
= trace "completed listener")
|
||||
|
||||
let transport1: TcpTransport = newTransport(TcpTransport)
|
||||
asyncCheck transport1.listen(ma, connHandler)
|
||||
|
@ -248,7 +248,7 @@ suite "Mplex":
|
|||
let mplexDial = newMplex(conn)
|
||||
let dialFut = mplexDial.handle()
|
||||
dialFut.addCallback(proc(udata: pointer = nil) {.gcsafe.}
|
||||
= debug "completed dialer")
|
||||
= trace "completed dialer")
|
||||
for i in 1..10:
|
||||
let stream = await mplexDial.newStream("dialer stream")
|
||||
await stream.writeLp(&"stream {i} from dialer!")
|
||||
|
|
Loading…
Reference in New Issue