chore: better quic close error codes

This commit is contained in:
Toby
2022-10-22 12:17:10 -07:00
parent b1d9ab6c6a
commit c98c7eca4e
3 changed files with 24 additions and 11 deletions

View File

@@ -94,18 +94,18 @@ func (c *Client) connect() error {
stream, err := quicConn.OpenStreamSync(ctx)
ctxCancel()
if err != nil {
_ = quicConn.CloseWithError(closeErrorCodeProtocol, "protocol error")
_ = closeErrorProtocol.Send(quicConn)
_ = pktConn.Close()
return err
}
ok, msg, err := c.handleControlStream(quicConn, stream)
if err != nil {
_ = quicConn.CloseWithError(closeErrorCodeProtocol, "protocol error")
_ = closeErrorProtocol.Send(quicConn)
_ = pktConn.Close()
return err
}
if !ok {
_ = quicConn.CloseWithError(closeErrorCodeAuth, "auth error")
_ = closeErrorAuth.Send(quicConn)
_ = pktConn.Close()
return fmt.Errorf("auth error: %s", msg)
}
@@ -296,7 +296,7 @@ func (c *Client) DialUDP() (UDPConn, error) {
func (c *Client) Close() error {
c.reconnectMutex.Lock()
defer c.reconnectMutex.Unlock()
err := c.quicConn.CloseWithError(closeErrorCodeGeneric, "")
err := closeErrorGeneric.Send(c.quicConn)
_ = c.pktConn.Close()
c.closed = true
return err