master
HimbeerserverDE 2021-05-02 12:20:52 +02:00
parent 81b8b04e01
commit 757de005ae
No known key found for this signature in database
GPG Key ID: 1A651504791E6A8B
2 changed files with 17 additions and 7 deletions

13
conn.go
View File

@ -18,7 +18,8 @@ var connectedConnsMu sync.RWMutex
type Conn struct { type Conn struct {
*rudp.Conn *rudp.Conn
protoVer uint16 protoVer uint16
formspecVer uint16
username string username string
srp_s []byte srp_s []byte
@ -46,18 +47,18 @@ type Conn struct {
noClt bool noClt bool
modChs map[string]bool modChs map[string]bool
huds map[uint32]bool huds map[uint32]bool
sounds map[int32]bool sounds map[int32]bool
blocks [][3]int16 blocks [][3]int16
inv *mt.Inv
inv *mt.Inv
} }
// ProtoVer returns the protocol version of the Conn // ProtoVer returns the protocol version of the Conn
func (c *Conn) ProtoVer() uint16 { return c.protoVer } func (c *Conn) ProtoVer() uint16 { return c.protoVer }
// FormspecVer returns the formspec API version of the Conn
func (c *Conn) FormspecVer() uint16 { return c.formspecVer + 1 }
// Addr returns the remote address of the Conn // Addr returns the remote address of the Conn
func (c *Conn) Addr() net.Addr { func (c *Conn) Addr() net.Addr {
return c.Conn.RemoteAddr() return c.Conn.RemoteAddr()

11
init.go
View File

@ -209,11 +209,14 @@ func Init(c, c2 *Conn, ignMedia, noAccessDenied bool, fin chan *Conn) {
continue continue
} }
v := []byte("5.4.0-dev-dd5a732fa") v := []byte("5.5.0-dev-83a7b48bb")
w := bytes.NewBuffer([]byte{0x00, ToServerClientReady}) w := bytes.NewBuffer([]byte{0x00, ToServerClientReady})
w.Write([]byte{5, 4, 0, 0}) w.Write([]byte{5, 4, 0, 0})
WriteBytes16(w, v) WriteBytes16(w, v)
if c.FormspecVer() != 1 {
WriteUint16(w, c.FormspecVer())
}
_, err := c2.Send(rudp.Pkt{ _, err := c2.Send(rudp.Pkt{
Reader: w, Reader: w,
@ -535,6 +538,12 @@ func Init(c, c2 *Conn, ignMedia, noAccessDenied bool, fin chan *Conn) {
return return
} }
r.Seek(4, io.SeekCurrent)
ReadBytes16(r)
if r.Len() >= 2 {
c2.formspecVer = ReadUint16(r) - 1
}
defaultSrv := ConfKey("default_server").(string) defaultSrv := ConfKey("default_server").(string)
defSrv := func() *Conn { defSrv := func() *Conn {