Skip to content

pixelbender/go-dtls

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Golang: DTLS Protocol

Build Status Coverage Status Go Report Card GoDoc

Work in progress, stay tuned...

Features

  • Client handshake
  • Server handshake
  • Retransmission
  • ...
  • Session Tickets

Installation

go get github.com/pixelbender/go-dtls

DTLS Client

package main

import (
    "github.com/pixelbender/go-dtls/dtls"
    "log"
)

func main() {
    conn, err := dtls.Dial("udp", "example.com:5000", nil)
    if err != nil {
        log.Fatal(err)
    }
    defer conn.Close()
    // Use conn as net.Conn...
}

DTLS Server

package main

import (
    "github.com/pixelbender/go-dtls/dtls"
    "crypto/tls"
    "log"
)

func main() {
    cert, err := tls.LoadX509KeyPair("cert.pem", "key.pem")
    if err != nil {
        log.Fatal(err)
    }
    config := &dtls.Config{Certificates: []tls.Certificate{cert}}
    
    l, err := dtls.Listen("udp", ":5000", config)
    if err != nil {
        log.Fatal(err)
    }
    defer l.Close()
    for {
        // Use l as net.Listener since DTLS is connection-oriented protocol.
        conn, err := l.Accept()
        if err != nil {
            log.Fatal(err)
        }
        go func() {
            defer conn.Close()
            // Serve conn as net.Conn...
        }()
    }
}

Specifications

About

Golang: DTLS protocol

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages