-
Notifications
You must be signed in to change notification settings - Fork 3
/
connectionlessk.go
50 lines (42 loc) · 1.31 KB
/
connectionlessk.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package message
import "github.com/galaco/bitbuf"
// MsgConnectionlessK is the authentication challenge response
type MsgConnectionlessK struct {
buf *bitbuf.Writer
}
// Connectionless is this message a connectionless message?
func (msg *MsgConnectionlessK) Connectionless() bool {
return true
}
// Data Get packet data
func (msg *MsgConnectionlessK) Data() []byte {
return msg.buf.Data()
}
// ConnectionlessK provides the initial authentication packet
func ConnectionlessK(clientChallenge int32, serverChallenge int32, playerName string, password string, gameVersion string, steamId uint64, steamKey []byte) *MsgConnectionlessK {
senddata := bitbuf.NewWriter(1000)
senddata.WriteByte(255)
senddata.WriteByte(255)
senddata.WriteByte(255)
senddata.WriteByte(255)
senddata.WriteByte('k')
senddata.WriteInt32(0x18)
senddata.WriteInt32(0x03)
senddata.WriteInt32(serverChallenge)
senddata.WriteInt32(clientChallenge)
//senddata.WriteUint32(2729496039)
senddata.WriteString(playerName) //player name
senddata.WriteByte(0)
senddata.WriteString(password) //password
senddata.WriteByte(0)
senddata.WriteString(gameVersion) //game version
senddata.WriteByte(0)
senddata.WriteInt16(242)
senddata.WriteUint64(steamId)
if len(steamKey) > 0 {
senddata.WriteBytes(steamKey)
}
return &MsgConnectionlessK{
buf: senddata,
}
}