mirror of https://github.com/vacp2p/nim-libp2p.git
whip initial secio
This commit is contained in:
parent
435c69633f
commit
d27ea5d228
|
@ -0,0 +1,32 @@
|
|||
## 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 secure,
|
||||
../../connection
|
||||
|
||||
const SecioCodec* = "/plaintext/1.0.0"
|
||||
|
||||
type
|
||||
Secio = ref object of Secure
|
||||
|
||||
proc encodeProposalMsg*() = discard
|
||||
proc decodeProposalMsg*() = discard
|
||||
|
||||
method init(p: Secio) {.gcsafe.} =
|
||||
proc handle(conn: Connection, proto: string) {.async, gcsafe.} =
|
||||
discard
|
||||
|
||||
p.codec = SecioCodec
|
||||
p.handler = handle
|
||||
|
||||
proc newSecio*(): Secio =
|
||||
new result
|
||||
result.init()
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
## 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.
|
||||
|
||||
type
|
||||
Exchanges* {.pure.} = enum
|
||||
P256 = "P-256",
|
||||
P384 = "P-384",
|
||||
P521 = "P-521"
|
||||
|
||||
Ciphers* {.pure.} = enum
|
||||
AES256 = "AES-256",
|
||||
AES128 = "AES-128"
|
||||
|
||||
Hashes* {.pure.} = enum
|
||||
SHA256 = "SHA256"
|
||||
SHA512 = "SHA512"
|
||||
|
||||
Propose* = tuple
|
||||
rand: seq[byte]
|
||||
pubkey: seq[byte]
|
||||
exchanges: string
|
||||
ciphers: string
|
||||
hashes: string
|
||||
|
||||
Exchange = tuple
|
||||
epubkey: seq[byte]
|
||||
signature: seq[byte]
|
||||
|
||||
proc proposal*() = discard
|
||||
proc exchange*() = discard
|
||||
proc selectBest*() = discard
|
||||
proc verify*() = discard
|
||||
proc generateKeys*() = discard
|
||||
proc verifyNonce*() = discard
|
|
@ -8,8 +8,8 @@
|
|||
## those terms.
|
||||
|
||||
import chronos
|
||||
import protocol
|
||||
import ../connection
|
||||
import ../protocol
|
||||
import ../../connection
|
||||
|
||||
const PlainTextCodec* = "/plaintext/1.0.0"
|
||||
|
||||
|
@ -19,12 +19,16 @@ type
|
|||
PlainText* = ref object of Secure
|
||||
|
||||
method init(p: PlainText) {.gcsafe.} =
|
||||
proc handle(conn: Connection, proto: string) {.async, gcsafe.} = discard
|
||||
proc handle(conn: Connection, proto: string)
|
||||
{.async, gcsafe.} = discard
|
||||
## plain text doesn't do anything
|
||||
|
||||
p.codec = PlainTextCodec
|
||||
p.handler = handle
|
||||
|
||||
method secure(p: Secure, conn: Connection): Future[Connection]
|
||||
{.base, async, gcsafe.} = discard
|
||||
|
||||
proc newPlainText*(): PlainText =
|
||||
new result
|
||||
result.init()
|
Loading…
Reference in New Issue