Add connection webhook notifications (#392)

Also 

* Added decode of LoginStart message
* Add metrics backend constants
* Updated usage section
* Documented MaxFrameLength
This commit is contained in:
Geoff Bourne
2025-04-21 20:28:34 -05:00
committed by GitHub
parent a058d6e21d
commit cc590524c4
13 changed files with 585 additions and 66 deletions
+18 -7
View File
@@ -1,6 +1,9 @@
package mcproto
import "fmt"
import (
"fmt"
"github.com/google/uuid"
)
type Frame struct {
Length int
@@ -9,8 +12,14 @@ type Frame struct {
type State int
/*
Handshaking -> Status
Handshaking -> Login -> ...
*/
const (
StateHandshaking = iota
StateHandshaking State = 0
StateStatus State = 1
StateLogin State = 2
)
var trimLimit = 64
@@ -31,7 +40,7 @@ func (f *Frame) String() string {
type Packet struct {
Length int
PacketID int
// Data is either a byte slice of raw content or a parsed message
// Data is either a byte slice of raw content or a decoded message
Data interface{}
}
@@ -46,6 +55,7 @@ func (p *Packet) String() string {
const (
PacketIdHandshake = 0x00
PacketIdLogin = 0x00 // during StateLogin
PacketIdLegacyServerListPing = 0xFE
)
@@ -53,12 +63,13 @@ type Handshake struct {
ProtocolVersion int
ServerAddress string
ServerPort uint16
NextState int
NextState State
}
const (
StateStatus State = 1
)
type LoginStart struct {
Name string
PlayerUuid uuid.UUID
}
type LegacyServerListPing struct {
ProtocolVersion int