diff --git a/client.go b/client.go index ee165ff..c2215ae 100644 --- a/client.go +++ b/client.go @@ -50,9 +50,9 @@ func DialQUIC(addr string, role uint64) (*Peer, error) { p, err := newClientPeer(qc, nil, role) if err != nil { if errors.Is(err, errUnsupportedVersion) { - conn.CloseWithError(SessionTerminatedErrorCode, errUnsupportedVersion.Error()) + _ = conn.CloseWithError(SessionTerminatedErrorCode, errUnsupportedVersion.Error()) } - conn.CloseWithError(GenericErrorCode, "internal server error") + _ = conn.CloseWithError(GenericErrorCode, "internal server error") return nil, err } return p, nil diff --git a/go.mod b/go.mod index 7409342..91e9db8 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/mengelbart/moqtransport -go 1.21.1 +go 1.21 require ( github.com/quic-go/quic-go v0.40.1-0.20231105142906-f5ce4e34f4d7 @@ -19,7 +19,7 @@ require ( github.com/quic-go/qpack v0.4.0 // indirect github.com/quic-go/qtls-go1-20 v0.4.1 // indirect go.uber.org/goleak v1.2.1 - go.uber.org/mock v0.3.0 // indirect + go.uber.org/mock v0.3.0 golang.org/x/crypto v0.12.0 // indirect golang.org/x/mod v0.12.0 // indirect golang.org/x/net v0.14.0 // indirect diff --git a/peer.go b/peer.go index 5bcbcd3..9d00982 100644 --- a/peer.go +++ b/peer.go @@ -16,10 +16,10 @@ import ( var ( errUnexpectedMessage = errors.New("got unexpected message") errInvalidTrackNamespace = errors.New("got invalid tracknamespace") + errUnknownTrack = errors.New("received object for unknown track") errClosed = errors.New("connection was closed") errUnsupportedVersion = errors.New("unsupported version") errMissingRoleParameter = errors.New("missing role parameter") - errGoAway = errors.New("received go away from peer") ) type SubscriptionHandler func(namespace, trackname string, track *SendTrack) (uint64, time.Duration, error) @@ -244,7 +244,9 @@ func (p *Peer) readMessages(r messageReader) { } switch v := msg.(type) { case *objectMessage: - p.handleObjectMessage(v) + if err := p.handleObjectMessage(v); err != nil { + panic(err) + } default: panic(errUnexpectedMessage) } @@ -337,17 +339,18 @@ func (p *Peer) controlStreamLoop(ctrlStream stream) { } } -func (p *Peer) acceptUnidirectionalStreams() error { +func (p *Peer) acceptUnidirectionalStreams() { defer p.logger.Println("accept uni stream loop exit") for { select { case <-p.ctx.Done(): - return nil + return default: } stream, err := p.conn.AcceptUniStream(context.TODO()) if err != nil { - return err + p.logger.Print(err) + return } p.logger.Println("GOT UNI STREAM") go p.readMessages(quicvarint.NewReader(stream)) @@ -375,10 +378,9 @@ func (p *Peer) handleObjectMessage(msg *objectMessage) error { if !ok { // handle unknown track? p.logger.Printf("got message for unknown track: %v", msg) - return nil + return errUnknownTrack } - t.push(msg) - return nil + return t.push(msg) } func (p *Peer) handleSubscribeRequest(msg *subscribeRequestMessage) message { diff --git a/server.go b/server.go index ee28aad..3c88ead 100644 --- a/server.go +++ b/server.go @@ -141,11 +141,11 @@ func (s *Server) Listen(ctx context.Context, l listener) error { if err != nil { switch { case errors.Is(err, errUnsupportedVersion): - conn.CloseWithError(SessionTerminatedErrorCode, err.Error()) + _ = conn.CloseWithError(SessionTerminatedErrorCode, err.Error()) case errors.Is(err, errMissingRoleParameter): - conn.CloseWithError(SessionTerminatedErrorCode, err.Error()) + _ = conn.CloseWithError(SessionTerminatedErrorCode, err.Error()) default: - conn.CloseWithError(GenericErrorCode, "internal server error") + _ = conn.CloseWithError(GenericErrorCode, "internal server error") } continue }