Socket
Socket
Sign inDemoInstall

rainy-dtls

Package Overview
Dependencies
21
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    rainy-dtls

DTLS protocol implementation for Node.js written in TypeScript.


Version published
Maintainers
1
Install size
10.5 MB
Created

Readme

Source

Example

  import { DtlsServer, DtlsClient, createUdpTransport } from "../../src";
  import { readFileSync } from "fs";
  import { createSocket } from "dgram";

  const port = 55557;

  const socket = createSocket("udp4");
  socket.bind(port);

  const server = new DtlsServer({
    cert: readFileSync("assets/cert.pem").toString(),
    key: readFileSync("assets/key.pem").toString(),
    transport: createUdpTransport(socket),
  });

  const client = new DtlsClient({
    transport: createUdpTransport(createSocket("udp4"), {
      address: "127.0.0.1",
      port,
    }),
  });
  
  server.onData = (data) => {
    console.log(data.toString())
  };

  client.onConnect = () => {
    client.send(Buffer.from("ping"));
  };
  client.onData = (data) => {
    console.log(data.toString())
  };

  client.connect();

reference

  • RFC5246
  • RFC6347
  • pion/dtls https://github.com/pion/dtls
  • nodertc/dtls https://github.com/nodertc/dtls
  • node-dtls https://github.com/Rantanen/node-dtls
  • node-dtls-client https://github.com/AlCalzone/node-dtls-client
  • OpenSSL

create key & cert

openssl genrsa 2048 > rsa.key
openssl pkcs8 -in rsa.key -topk8 -out key.pem -nocrypt
openssl req -new -key key.pem > cert.csr
openssl x509 -req -days 3650 -signkey key.pem -in cert.csr -out  cert.pem

FAQs

Last updated on 15 Jul 2020

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc