mirror of
https://github.com/Mezeporta/Erupe.git
synced 2025-12-16 17:05:03 +01:00
Initial chat prototype
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
package entranceserver
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
"io"
|
||||
@@ -10,6 +9,7 @@ import (
|
||||
|
||||
"github.com/Andoryuuta/Erupe/config"
|
||||
"github.com/Andoryuuta/Erupe/network"
|
||||
"github.com/jmoiron/sqlx"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
@@ -18,7 +18,7 @@ type Server struct {
|
||||
sync.Mutex
|
||||
logger *zap.Logger
|
||||
erupeConfig *config.Config
|
||||
db *sql.DB
|
||||
db *sqlx.DB
|
||||
listener net.Listener
|
||||
isShuttingDown bool
|
||||
}
|
||||
@@ -26,7 +26,7 @@ type Server struct {
|
||||
// Config struct allows configuring the server.
|
||||
type Config struct {
|
||||
Logger *zap.Logger
|
||||
DB *sql.DB
|
||||
DB *sqlx.DB
|
||||
ErupeConfig *config.Config
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,9 @@ package entranceserver
|
||||
|
||||
import (
|
||||
"encoding/binary"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"net"
|
||||
|
||||
"github.com/Andoryuuta/Erupe/config"
|
||||
@@ -32,6 +35,7 @@ func encodeServerInfo(serverInfos []config.EntranceServerInfo) []byte {
|
||||
bf.WriteUint32(si.AllowedClientFlags)
|
||||
|
||||
for channelIdx, ci := range si.Channels {
|
||||
fmt.Println("Channel idx", channelIdx)
|
||||
bf.WriteUint16(ci.Port)
|
||||
bf.WriteUint16(16 + uint16(channelIdx))
|
||||
bf.WriteUint16(ci.MaxPlayers)
|
||||
@@ -71,6 +75,7 @@ func makeHeader(data []byte, respType string, entryCount uint16, key byte) []byt
|
||||
}
|
||||
|
||||
func makeResp(servers []config.EntranceServerInfo) []byte {
|
||||
fmt.Printf("%+v\n", servers)
|
||||
rawServerData := encodeServerInfo(servers)
|
||||
|
||||
bf := byteframe.NewByteFrame()
|
||||
@@ -81,6 +86,11 @@ func makeResp(servers []config.EntranceServerInfo) []byte {
|
||||
// If so, how does it work without the entrance server connection being authenticated?
|
||||
bf.WriteBytes(makeHeader([]byte{}, "USR", 0, 0x00))
|
||||
|
||||
err := ioutil.WriteFile("go_entrance_resp.bin", bf.Data(), 0644)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
return bf.Data()
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user