This commit is contained in:
Jakob Borg 2023-04-28 09:21:13 +02:00
parent 134df290a3
commit 187516558a
2 changed files with 17 additions and 10 deletions

View File

@ -97,16 +97,21 @@ func (t *quicListener) serve(ctx context.Context) error {
}
defer func() { _ = udpConn.Close() }()
// XXX: HAX TO BE REVERTED
// svc, conn := stun.New(t.cfg, t, udpConn)
// defer conn.Close()
// Wrap the UDP connection in a STUN service if STUN is enabled.
var pktConn net.PacketConn
if t.cfg.Options().IsStunDisabled() {
pktConn = udpConn
} else {
svc, stunConn := stun.New(t.cfg, t, udpConn)
defer stunConn.Close()
go svc.Serve(ctx)
pktConn = stunConn
}
// go svc.Serve(ctx)
t.registry.Register(t.uri.Scheme, pktConn)
defer t.registry.Unregister(t.uri.Scheme, pktConn)
t.registry.Register(t.uri.Scheme, udpConn)
defer t.registry.Unregister(t.uri.Scheme, udpConn)
listener, err := quic.Listen(udpConn, t.tlsCfg, quicConfig)
listener, err := quic.Listen(pktConn, t.tlsCfg, quicConfig)
if err != nil {
l.Infoln("Listen (BEP/quic):", err)
return err

View File

@ -21,8 +21,10 @@ import (
const stunRetryInterval = 5 * time.Minute
type Host = stun.Host
type NATType = stun.NATType
type (
Host = stun.Host
NATType = stun.NATType
)
// NAT types.