moving modules to apropriate directories
This commit is contained in:
parent
2f402d68e1
commit
14d9150bbb
|
@ -9,10 +9,10 @@
|
|||
|
||||
import options
|
||||
import chronos
|
||||
import protobuf/minprotobuf, peerinfo,
|
||||
protocol as proto, connection,
|
||||
peer, crypto/crypto, multiaddress,
|
||||
crypto/crypto
|
||||
import ../protobuf/minprotobuf, ../peerinfo,
|
||||
protocol as proto, ../connection,
|
||||
../peer, ../crypto/crypto,
|
||||
../multiaddress
|
||||
|
||||
const IdentifyCodec* = "/ipfs/id/1.0.0"
|
||||
const IdentifyPushCodec* = "/ipfs/id/push/1.0.0"
|
||||
|
@ -23,6 +23,7 @@ const AgentVersion* = "nim-libp2p/0.0.1"
|
|||
|
||||
type
|
||||
IdentityNoMatchError* = object of CatchableError
|
||||
IdentityInvalidMsgError* = object of CatchableError
|
||||
|
||||
IdentifyInfo* = object
|
||||
pubKey*: PublicKey
|
||||
|
@ -90,6 +91,7 @@ method init*(p: Identify) =
|
|||
await conn.writeLp(pb.buffer)
|
||||
|
||||
p.handler = handle
|
||||
p.codec = IdentifyCodec
|
||||
|
||||
proc identify*(p: Identify,
|
||||
conn: Connection,
|
||||
|
@ -97,7 +99,9 @@ proc identify*(p: Identify,
|
|||
Future[IdentifyInfo] {.async.} =
|
||||
var message = await conn.readLp()
|
||||
if len(message) == 0:
|
||||
raise newException(CatchableError, "Incorrect or empty message received!")
|
||||
raise newException(IdentityInvalidMsgError,
|
||||
"Invalid or empty message received!")
|
||||
|
||||
result = decodeMsg(message)
|
||||
if remotePeerInfo.isSome and
|
||||
remotePeerInfo.get().peerId.publicKey != result.pubKey:
|
|
@ -0,0 +1,29 @@
|
|||
## Nim-LibP2P
|
||||
## Copyright (c) 2018 Status Research & Development GmbH
|
||||
## Licensed under either of
|
||||
## * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE))
|
||||
## * MIT license ([LICENSE-MIT](LICENSE-MIT))
|
||||
## at your option.
|
||||
## This file may not be copied, modified, or distributed except according to
|
||||
## those terms.
|
||||
|
||||
import chronos
|
||||
import protocol
|
||||
import ../connection
|
||||
|
||||
const PlainTextCodec* = "/plaintext/1.0.0"
|
||||
|
||||
type
|
||||
PlainText* = ref object of LPProtocol
|
||||
|
||||
method init(p: PlainText) {.gcsafe.} =
|
||||
proc handle(conn: Connection, proto: string) {.async, gcsafe.} =
|
||||
let msg = await conn.readLp()
|
||||
await conn.writeLp(msg)
|
||||
|
||||
p.codec = PlainTextCodec
|
||||
p.handler = handle
|
||||
|
||||
proc newPlainText*(): PlainText =
|
||||
new result
|
||||
result.init()
|
|
@ -8,8 +8,9 @@
|
|||
## those terms.
|
||||
|
||||
import chronos
|
||||
import connection, transport,
|
||||
peerinfo, multiaddress
|
||||
import ../connection,
|
||||
../peerinfo,
|
||||
../multiaddress
|
||||
|
||||
type
|
||||
LPProtoHandler* = proc (conn: Connection,
|
|
@ -8,9 +8,9 @@
|
|||
## those terms.
|
||||
|
||||
import chronos
|
||||
import transport, wire, connection,
|
||||
multiaddress, connection,
|
||||
multicodec, stream/chronosstream
|
||||
import transport, ../wire, ../connection,
|
||||
../multiaddress, ../connection,
|
||||
../multicodec, ../stream/chronosstream
|
||||
|
||||
type TcpTransport* = ref object of Transport
|
||||
server*: StreamServer
|
|
@ -9,7 +9,8 @@
|
|||
|
||||
import sequtils
|
||||
import chronos
|
||||
import peerinfo, connection, multiaddress, multicodec
|
||||
import ../peerinfo, ../connection,
|
||||
../multiaddress, ../multicodec
|
||||
|
||||
type
|
||||
ConnHandler* = proc (conn: Connection): Future[void] {.gcsafe.}
|
Loading…
Reference in New Issue