Skip to content

Commit

Permalink
session/handler.go: add multi-version support for decoding client pac…
Browse files Browse the repository at this point in the history
…kets
  • Loading branch information
cooldogedev committed Aug 19, 2024
1 parent aaa1753 commit 14b27e9
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ require (
github.com/go-gl/mathgl v1.1.0
github.com/golang/snappy v0.0.4
github.com/quic-go/quic-go v0.46.0
github.com/sandertv/gophertunnel v1.39.3
github.com/sandertv/gophertunnel v1.40.2-0.20240819155723-46502d4cb6ce
github.com/scylladb/go-set v1.0.2
)

Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ github.com/quic-go/quic-go v0.46.0/go.mod h1:1dLehS7TIR64+vxGR70GDcatWTOtMX2PUtn
github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g=
github.com/sandertv/go-raknet v1.14.1 h1:V2Gslo+0x4jfj+p0PM48mWxmMbYkxSlgeKy//y3ZrzI=
github.com/sandertv/go-raknet v1.14.1/go.mod h1:/yysjwfCXm2+2OY8mBazLzcxJ3irnylKCyG3FLgUPVU=
github.com/sandertv/gophertunnel v1.39.3 h1:oc0PPOhrB9utScy8SEYJTWQIFexzf8CVizmB5MLsb6A=
github.com/sandertv/gophertunnel v1.39.3/go.mod h1:uSaX7RbVaCcxsGAx2vyZnkT0M6kZFGCdAqLn0+wuKyY=
github.com/sandertv/gophertunnel v1.40.2-0.20240819155723-46502d4cb6ce h1:4iKcIz/FF4lAc1J8qdGVPTbyelfaH4vabmZDpkfefsU=
github.com/sandertv/gophertunnel v1.40.2-0.20240819155723-46502d4cb6ce/go.mod h1:uSaX7RbVaCcxsGAx2vyZnkT0M6kZFGCdAqLn0+wuKyY=
github.com/scylladb/go-set v1.0.2 h1:SkvlMCKhP0wyyct6j+0IHJkBkSZL+TDzZ4E7f7BCcRE=
github.com/scylladb/go-set v1.0.2/go.mod h1:DkpGd78rljTxKAnTDPFqXSGxvETQnJyuSOQwsHycqfs=
github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo=
Expand Down
5 changes: 2 additions & 3 deletions session/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (

"github.com/cooldogedev/spectrum/internal"
packet2 "github.com/cooldogedev/spectrum/server/packet"
"github.com/sandertv/gophertunnel/minecraft/protocol"
"github.com/sandertv/gophertunnel/minecraft/protocol/packet"
)

Expand Down Expand Up @@ -96,7 +95,7 @@ func handleClient(s *Session) {
defer s.Close()

header := &packet.Header{}
pool := packet.NewClientPool()
pool := s.clientConn.Proto().Packets(true)
var deferredPackets [][]byte
for {
select {
Expand Down Expand Up @@ -193,7 +192,7 @@ func handleClientPacket(s *Session, header *packet.Header, pool packet.Pool, pay
}

pk := factory()
pk.Marshal(protocol.NewReader(buf, s.shieldID, true))
pk.Marshal(s.clientConn.Proto().NewReader(buf, s.shieldID, true))
s.processor.ProcessClient(ctx, pk)
if !ctx.Cancelled() {
return s.Server().WritePacket(pk)
Expand Down

0 comments on commit 14b27e9

Please sign in to comment.