Work in progress, stay tuned...
- Client handshake
- Server handshake
- Retransmission
- ...
- Session Tickets
go get github.com/pixelbender/go-dtls
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...
}
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...
}()
}
}