expose local address
This commit is contained in:
parent
0504d86340
commit
afce5cad17
|
@ -139,9 +139,9 @@ proc start*(self: Dtls, conn: StunConn, laddr: TransportAddress) =
|
||||||
mb_entropy_init(self.entropy)
|
mb_entropy_init(self.entropy)
|
||||||
mb_ctr_drbg_seed(self.ctr_drbg, mbedtls_entropy_func, self.entropy, nil, 0)
|
mb_ctr_drbg_seed(self.ctr_drbg, mbedtls_entropy_func, self.entropy, nil, 0)
|
||||||
|
|
||||||
var pkey = self.ctr_drbg.generateKey()
|
self.serverPrivKey = self.ctr_drbg.generateKey()
|
||||||
var srvcert = self.ctr_drbg.generateCertificate(pkey)
|
self.serverCert = self.ctr_drbg.generateCertificate(self.serverPrivKey)
|
||||||
self.localCert = newSeq[byte](srvcert.raw.len)
|
self.localCert = newSeq[byte](self.serverCert.raw.len)
|
||||||
|
|
||||||
proc stop*(self: Dtls) =
|
proc stop*(self: Dtls) =
|
||||||
if not self.started:
|
if not self.started:
|
||||||
|
@ -205,10 +205,10 @@ proc accept*(self: Dtls): Future[DtlsConn] {.async.} =
|
||||||
res.ctr_drbg = self.ctr_drbg
|
res.ctr_drbg = self.ctr_drbg
|
||||||
res.entropy = self.entropy
|
res.entropy = self.entropy
|
||||||
|
|
||||||
var pkey = res.ctr_drbg.generateKey()
|
var pkey = self.serverPrivKey
|
||||||
var srvcert = res.ctr_drbg.generateCertificate(pkey)
|
var srvcert = self.serverCert
|
||||||
res.localCert = newSeq[byte](srvcert.raw.len)
|
res.localCert = newSeq[byte](srvcert.raw.len)
|
||||||
copyMem(addr res.localCert[0], srvcert.raw.p, srvcert.raw.len)
|
res.localCert = self.localCert
|
||||||
|
|
||||||
mb_ssl_config_defaults(res.config,
|
mb_ssl_config_defaults(res.config,
|
||||||
MBEDTLS_SSL_IS_SERVER,
|
MBEDTLS_SSL_IS_SERVER,
|
||||||
|
|
|
@ -15,7 +15,7 @@ logScope:
|
||||||
|
|
||||||
type
|
type
|
||||||
UdpConn* = ref object
|
UdpConn* = ref object
|
||||||
laddr: TransportAddress
|
laddr*: TransportAddress
|
||||||
udp: DatagramTransport
|
udp: DatagramTransport
|
||||||
dataRecv: AsyncQueue[(seq[byte], TransportAddress)]
|
dataRecv: AsyncQueue[(seq[byte], TransportAddress)]
|
||||||
|
|
||||||
|
|
|
@ -25,9 +25,6 @@ type
|
||||||
sctp*: Sctp
|
sctp*: Sctp
|
||||||
port: int
|
port: int
|
||||||
|
|
||||||
proc dtlsLocalCertificate(w: WebRTC): seq[byte] =
|
|
||||||
w.dtls.localCertificate()
|
|
||||||
|
|
||||||
proc new*(T: typedesc[WebRTC], address: TransportAddress): T =
|
proc new*(T: typedesc[WebRTC], address: TransportAddress): T =
|
||||||
var webrtc = T(udp: UdpConn(), stun: StunConn(), dtls: Dtls())
|
var webrtc = T(udp: UdpConn(), stun: StunConn(), dtls: Dtls())
|
||||||
webrtc.udp.init(address)
|
webrtc.udp.init(address)
|
||||||
|
|
Loading…
Reference in New Issue