mirror of
https://github.com/refraction-networking/uquic.git
synced 2025-04-04 20:57:36 +03:00
49 lines
1.1 KiB
Go
49 lines
1.1 KiB
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
"flag"
|
|
"fmt"
|
|
"net"
|
|
|
|
"github.com/pion/dtls/v3/examples/util"
|
|
quic "github.com/refraction-networking/uquic"
|
|
tls "github.com/refraction-networking/utls"
|
|
)
|
|
|
|
func main() {
|
|
var remoteAddr = flag.String("raddr", "127.0.0.1:6666", "remote address")
|
|
// var pubkey = flag.String("secret", "0b63baad7f2f4bb5b547c53adc0fbb179852910607935e6f4b5639fd989b1156", "shared secret")
|
|
// var covert = flag.String("covert", "1.2.3.4:5678", "covert address")
|
|
flag.Parse()
|
|
|
|
addr, err := net.ResolveUDPAddr("udp", *remoteAddr)
|
|
util.Check(err)
|
|
|
|
pconn, err := net.ListenUDP("udp", nil)
|
|
util.Check(err)
|
|
quicSpec, err := quic.QUICID2Spec(quic.QUICFirefox_116)
|
|
util.Check(err)
|
|
|
|
tp := quic.UTransport{
|
|
Transport: &quic.Transport{
|
|
Conn: pconn,
|
|
},
|
|
QUICSpec: &quicSpec,
|
|
}
|
|
|
|
econn, err := tp.DialEarly(context.Background(), addr, &tls.Config{
|
|
InsecureSkipVerify: true,
|
|
NextProtos: []string{"h3"},
|
|
}, &quic.Config{})
|
|
util.Check(err)
|
|
|
|
stream, err := econn.OpenStream()
|
|
util.Check(err)
|
|
|
|
fmt.Println("Connected; type 'exit' to shutdown gracefully")
|
|
|
|
// Simulate a chat session
|
|
util.Chat(stream)
|
|
|
|
}
|