Skip to content

Commit

Permalink
Fix lint and test errors
Browse files Browse the repository at this point in the history
  • Loading branch information
mengelbart committed Dec 5, 2023
1 parent c9250f4 commit 81c682f
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 16 deletions.
4 changes: 2 additions & 2 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion examples/chat/chatalog.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import (
"bytes"
"errors"
"fmt"
"slices"
"strconv"
"strings"

"golang.org/x/exp/maps"
"golang.org/x/exp/slices"
)

var (
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down
18 changes: 10 additions & 8 deletions peer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
}
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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 {
Expand Down
6 changes: 3 additions & 3 deletions server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit 81c682f

Please sign in to comment.