Fix channel join flooding and enhance TUI features
- Implemented separate PacketID counters for Ping, Pong, and Ack (protocol compliance).
- Encrypted outgoing Pong packets after handshake.
- Fixed 'clientmove' command by omitting empty 'cpw' parameter.
- Added fullscreen log view toggle ('f' key).
- Improved logging with multi-writer and timestamps.
- Updated .gitignore to exclude binaries and logs.
This commit is contained in:
5
.gitignore
vendored
5
.gitignore
vendored
@@ -1 +1,6 @@
|
|||||||
|
*.exe
|
||||||
|
*.log
|
||||||
ts3j/
|
ts3j/
|
||||||
|
bin/
|
||||||
|
vendor/
|
||||||
|
.gemini/
|
||||||
|
|||||||
BIN
client.exe
BIN
client.exe
Binary file not shown.
@@ -6,6 +6,7 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
|
"time"
|
||||||
|
|
||||||
tea "github.com/charmbracelet/bubbletea"
|
tea "github.com/charmbracelet/bubbletea"
|
||||||
)
|
)
|
||||||
@@ -23,7 +24,7 @@ func debugLog(format string, args ...any) {
|
|||||||
func main() {
|
func main() {
|
||||||
serverAddr := flag.String("server", "127.0.0.1:9987", "TeamSpeak 3 Server Address")
|
serverAddr := flag.String("server", "127.0.0.1:9987", "TeamSpeak 3 Server Address")
|
||||||
nickname := flag.String("nickname", "TUI-User", "Your nickname")
|
nickname := flag.String("nickname", "TUI-User", "Your nickname")
|
||||||
debug := flag.Bool("debug", false, "Enable debug logging to tui-debug.log")
|
debug := flag.Bool("debug", true, "Enable debug logging to file (default true)")
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
// Disable log output completely to prevent TUI corruption
|
// Disable log output completely to prevent TUI corruption
|
||||||
@@ -32,10 +33,12 @@ func main() {
|
|||||||
// Enable debug file logging if requested
|
// Enable debug file logging if requested
|
||||||
if *debug {
|
if *debug {
|
||||||
var err error
|
var err error
|
||||||
debugFile, err = os.Create("tui-debug.log")
|
timestamp := time.Now().Format("20060102-150405")
|
||||||
|
filename := fmt.Sprintf("tui-%s.log", timestamp)
|
||||||
|
debugFile, err = os.Create(filename)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
defer debugFile.Close()
|
defer debugFile.Close()
|
||||||
debugLog("TUI Debug started")
|
debugLog("TUI Debug started at %s", timestamp)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -45,6 +48,32 @@ func main() {
|
|||||||
// Create Bubble Tea program
|
// Create Bubble Tea program
|
||||||
p := tea.NewProgram(m, tea.WithAltScreen())
|
p := tea.NewProgram(m, tea.WithAltScreen())
|
||||||
|
|
||||||
|
// Set up log capture
|
||||||
|
r, w, _ := os.Pipe()
|
||||||
|
if debugFile != nil {
|
||||||
|
log.SetOutput(io.MultiWriter(w, debugFile))
|
||||||
|
} else {
|
||||||
|
log.SetOutput(w)
|
||||||
|
}
|
||||||
|
// Make sure logs have timestamp removed (TUI adds it if needed, or we keep it)
|
||||||
|
log.SetFlags(log.Ltime) // Just time
|
||||||
|
|
||||||
|
go func() {
|
||||||
|
buf := make([]byte, 1024)
|
||||||
|
for {
|
||||||
|
n, err := r.Read(buf)
|
||||||
|
if err != nil {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
if n > 0 {
|
||||||
|
lines := string(buf[:n])
|
||||||
|
// Split by newline and send each line
|
||||||
|
// Simple split, might need better buffering for partial lines but OK for debug
|
||||||
|
p.Send(logMsg(lines))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
// Run
|
// Run
|
||||||
if _, err := p.Run(); err != nil {
|
if _, err := p.Run(); err != nil {
|
||||||
fmt.Fprintf(os.Stderr, "Error: %v\n", err)
|
fmt.Fprintf(os.Stderr, "Error: %v\n", err)
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package main
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"sort"
|
"sort"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"go-ts/pkg/ts3client"
|
"go-ts/pkg/ts3client"
|
||||||
@@ -64,6 +65,7 @@ type Model struct {
|
|||||||
selectedIdx int
|
selectedIdx int
|
||||||
chatMessages []ChatMessage
|
chatMessages []ChatMessage
|
||||||
logMessages []string // Debug logs shown in chat panel
|
logMessages []string // Debug logs shown in chat panel
|
||||||
|
logFullscreen bool // Toggle fullscreen log view
|
||||||
inputText string
|
inputText string
|
||||||
inputActive bool
|
inputActive bool
|
||||||
|
|
||||||
@@ -226,11 +228,18 @@ func (m *Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
|||||||
case errorMsg:
|
case errorMsg:
|
||||||
m.lastError = msg.err
|
m.lastError = msg.err
|
||||||
return m, nil
|
return m, nil
|
||||||
|
|
||||||
|
case logMsg:
|
||||||
|
// External log message
|
||||||
|
m.addLog("%s", string(msg))
|
||||||
|
return m, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
return m, nil
|
return m, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type logMsg string
|
||||||
|
|
||||||
func (m *Model) updateChannelList(channels []*ts3client.Channel) {
|
func (m *Model) updateChannelList(channels []*ts3client.Channel) {
|
||||||
// Sort channels by ID for stable ordering
|
// Sort channels by ID for stable ordering
|
||||||
sortedChannels := make([]*ts3client.Channel, len(channels))
|
sortedChannels := make([]*ts3client.Channel, len(channels))
|
||||||
@@ -259,6 +268,11 @@ func (m *Model) updateChannelList(channels []*ts3client.Channel) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Sort users by ID for stable ordering
|
||||||
|
sort.Slice(node.Users, func(i, j int) bool {
|
||||||
|
return node.Users[i].ID < node.Users[j].ID
|
||||||
|
})
|
||||||
|
|
||||||
m.channels = append(m.channels, node)
|
m.channels = append(m.channels, node)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -288,8 +302,17 @@ func (m *Model) handleKeyPress(msg tea.KeyMsg) (tea.Model, tea.Cmd) {
|
|||||||
return m.handleChannelKeys(msg)
|
return m.handleChannelKeys(msg)
|
||||||
case FocusInput:
|
case FocusInput:
|
||||||
return m.handleInputKeys(msg)
|
return m.handleInputKeys(msg)
|
||||||
|
case FocusChat:
|
||||||
|
return m.handleChatKeys(msg)
|
||||||
|
}
|
||||||
|
return m, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (m *Model) handleChatKeys(msg tea.KeyMsg) (tea.Model, tea.Cmd) {
|
||||||
|
switch msg.String() {
|
||||||
|
case "f":
|
||||||
|
m.logFullscreen = !m.logFullscreen
|
||||||
|
}
|
||||||
return m, nil
|
return m, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -307,7 +330,11 @@ func (m *Model) handleChannelKeys(msg tea.KeyMsg) (tea.Model, tea.Cmd) {
|
|||||||
// Join selected channel
|
// Join selected channel
|
||||||
if m.selectedIdx < len(m.channels) && m.client != nil {
|
if m.selectedIdx < len(m.channels) && m.client != nil {
|
||||||
ch := m.channels[m.selectedIdx]
|
ch := m.channels[m.selectedIdx]
|
||||||
m.client.JoinChannel(ch.ID)
|
m.addLog("Attempting to join channel: %s (ID=%d)", ch.Name, ch.ID)
|
||||||
|
err := m.client.JoinChannel(ch.ID)
|
||||||
|
if err != nil {
|
||||||
|
m.addLog("Error joining channel: %v", err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return m, nil
|
return m, nil
|
||||||
@@ -342,6 +369,18 @@ func (m *Model) View() string {
|
|||||||
return "Loading..."
|
return "Loading..."
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Fullscreen Log Mode
|
||||||
|
if m.logFullscreen {
|
||||||
|
style := lipgloss.NewStyle().
|
||||||
|
Border(lipgloss.RoundedBorder()).
|
||||||
|
BorderForeground(lipgloss.Color("212")). // Active color
|
||||||
|
Padding(0, 1).
|
||||||
|
Width(m.width - 2).
|
||||||
|
Height(m.height - 2)
|
||||||
|
|
||||||
|
return style.Render(m.renderChat())
|
||||||
|
}
|
||||||
|
|
||||||
// Styles
|
// Styles
|
||||||
headerStyle := lipgloss.NewStyle().
|
headerStyle := lipgloss.NewStyle().
|
||||||
Bold(true).
|
Bold(true).
|
||||||
@@ -463,12 +502,30 @@ func (m *Model) renderChat() string {
|
|||||||
if maxLines < 5 {
|
if maxLines < 5 {
|
||||||
maxLines = 5
|
maxLines = 5
|
||||||
}
|
}
|
||||||
|
|
||||||
start := 0
|
start := 0
|
||||||
if len(m.logMessages) > maxLines {
|
if len(m.logMessages) > maxLines {
|
||||||
start = len(m.logMessages) - maxLines
|
start = len(m.logMessages) - maxLines
|
||||||
}
|
}
|
||||||
|
|
||||||
|
panelWidth := (m.width / 2) - 4
|
||||||
|
if m.logFullscreen {
|
||||||
|
panelWidth = m.width - 6
|
||||||
|
}
|
||||||
|
if panelWidth < 10 {
|
||||||
|
panelWidth = 10
|
||||||
|
}
|
||||||
|
|
||||||
for _, msg := range m.logMessages[start:] {
|
for _, msg := range m.logMessages[start:] {
|
||||||
lines = append(lines, lipgloss.NewStyle().Faint(true).Render(msg))
|
// Truncate if too long to prevent wrapping breaking the layout
|
||||||
|
displayMsg := msg
|
||||||
|
if len(displayMsg) > panelWidth {
|
||||||
|
displayMsg = displayMsg[:panelWidth-3] + "..."
|
||||||
|
}
|
||||||
|
// Replace newlines just in case
|
||||||
|
displayMsg = strings.ReplaceAll(displayMsg, "\n", " ")
|
||||||
|
|
||||||
|
lines = append(lines, lipgloss.NewStyle().Faint(true).Render(displayMsg))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
BIN
example.exe
BIN
example.exe
Binary file not shown.
@@ -1,6 +1,8 @@
|
|||||||
package client
|
package client
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/binary"
|
||||||
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
@@ -29,8 +31,11 @@ type Client struct {
|
|||||||
ClientID uint16
|
ClientID uint16
|
||||||
|
|
||||||
// Counters
|
// Counters
|
||||||
PacketIDCounterC2S uint16
|
PacketIDCounterC2S uint16 // Commands (Type 0x02)
|
||||||
VoicePacketID uint16
|
VoicePacketID uint16 // Voice (Type 0x00)
|
||||||
|
PingPacketID uint16 // Type 0x04
|
||||||
|
PongPacketID uint16 // Type 0x05
|
||||||
|
AckPacketID uint16 // Type 0x06
|
||||||
|
|
||||||
// State
|
// State
|
||||||
Connected bool
|
Connected bool
|
||||||
@@ -136,25 +141,52 @@ func (c *Client) Connect(address string) error {
|
|||||||
if !c.Connected {
|
if !c.Connected {
|
||||||
continue // Don't send pings if not connected yet
|
continue // Don't send pings if not connected yet
|
||||||
}
|
}
|
||||||
ping := protocol.NewPacket(protocol.PacketTypePing, nil)
|
// Send KeepAlive Ping (Encrypted, No NewProtocol)
|
||||||
c.PacketIDCounterC2S++
|
if err := c.sendPing(); err != nil {
|
||||||
ping.Header.PacketID = c.PacketIDCounterC2S
|
log.Printf("Error sending Ping: %v", err)
|
||||||
ping.Header.ClientID = c.ClientID
|
}
|
||||||
// Must NOT have NewProtocol (0x20) flag for Pings/Pongs
|
}
|
||||||
ping.Header.Type = uint8(protocol.PacketTypePing) | protocol.PacketFlagUnencrypted
|
|
||||||
|
|
||||||
// Use SharedMac if available, otherwise zeros (as per ts3j InitPacketTransformation)
|
|
||||||
if c.Handshake != nil && len(c.Handshake.SharedMac) > 0 {
|
|
||||||
copy(ping.Header.MAC[:], c.Handshake.SharedMac)
|
|
||||||
} else {
|
|
||||||
// Initialize Header.MAC with zeros
|
|
||||||
for i := 0; i < 8; i++ {
|
|
||||||
ping.Header.MAC[i] = 0
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Printf("Sending KeepAlive Ping (PID=%d)", ping.Header.PacketID)
|
// sendPing sends an encrypted Ping packet WITHOUT the NewProtocol flag
|
||||||
c.Conn.SendPacket(ping)
|
func (c *Client) sendPing() error {
|
||||||
|
pType := protocol.PacketTypePing
|
||||||
|
pkt := protocol.NewPacket(pType, nil)
|
||||||
|
c.PingPacketID++
|
||||||
|
pkt.Header.PacketID = c.PingPacketID
|
||||||
|
pkt.Header.ClientID = c.ClientID
|
||||||
|
// Note: We do NOT set PacketFlagNewProtocol for Pings
|
||||||
|
|
||||||
|
// Encryption
|
||||||
|
key := protocol.HandshakeKey[:]
|
||||||
|
nonce := protocol.HandshakeNonce[:]
|
||||||
|
|
||||||
|
if c.Handshake != nil && c.Handshake.Step >= 6 && len(c.Handshake.SharedIV) > 0 {
|
||||||
|
crypto := &protocol.CryptoState{
|
||||||
|
SharedIV: c.Handshake.SharedIV,
|
||||||
|
SharedMac: c.Handshake.SharedMac,
|
||||||
|
GenerationID: 0,
|
||||||
}
|
}
|
||||||
|
keyArr, nonceArr := crypto.GenerateKeyNonce(&pkt.Header, true) // Client->Server=true
|
||||||
|
key = keyArr
|
||||||
|
nonce = nonceArr
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Meta for Client->Server: PID(2) + CID(2) + PT(1) = 5 bytes
|
||||||
|
meta := make([]byte, 5)
|
||||||
|
binary.BigEndian.PutUint16(meta[0:2], pkt.Header.PacketID)
|
||||||
|
binary.BigEndian.PutUint16(meta[2:4], pkt.Header.ClientID)
|
||||||
|
meta[4] = pkt.Header.Type
|
||||||
|
|
||||||
|
encData, mac, err := protocol.EncryptEAX(key, nonce, meta, pkt.Data)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("encryption failed: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
pkt.Data = encData
|
||||||
|
copy(pkt.Header.MAC[:], mac)
|
||||||
|
|
||||||
|
log.Printf("Sending proper Encrypted Ping (PID=%d)", pkt.Header.PacketID)
|
||||||
|
return c.Conn.SendPacket(pkt)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -331,6 +331,32 @@ func (c *Client) processCommand(data []byte, pkt *protocol.Packet) error {
|
|||||||
|
|
||||||
return c.SendCommand(moveCmd)
|
return c.SendCommand(moveCmd)
|
||||||
}
|
}
|
||||||
|
case "clientlist":
|
||||||
|
// Parse client info (usually received after connection for all clients)
|
||||||
|
nick := ""
|
||||||
|
clientID := uint16(0)
|
||||||
|
channelID := uint64(0)
|
||||||
|
if n, ok := args["client_nickname"]; ok {
|
||||||
|
nick = protocol.Unescape(n)
|
||||||
|
}
|
||||||
|
if cid, ok := args["clid"]; ok {
|
||||||
|
var id uint64
|
||||||
|
fmt.Sscanf(cid, "%d", &id)
|
||||||
|
clientID = uint16(id)
|
||||||
|
}
|
||||||
|
if ctid, ok := args["cid"]; ok {
|
||||||
|
fmt.Sscanf(ctid, "%d", &channelID)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Don't emit for ourselves if we already handle it in initserver
|
||||||
|
if clientID != c.ClientID && clientID != 0 {
|
||||||
|
log.Printf("Existing client: %s (ID=%d) in Channel %d", nick, clientID, channelID)
|
||||||
|
c.emitEvent("client_enter", map[string]any{
|
||||||
|
"clientID": clientID,
|
||||||
|
"nickname": nick,
|
||||||
|
"channelID": channelID,
|
||||||
|
})
|
||||||
|
}
|
||||||
case "notifycliententerview":
|
case "notifycliententerview":
|
||||||
// A client entered the server
|
// A client entered the server
|
||||||
nick := ""
|
nick := ""
|
||||||
|
|||||||
@@ -20,8 +20,9 @@ func (c *Client) handlePacket(pkt *protocol.Packet) error {
|
|||||||
binary.BigEndian.PutUint16(ackData, pkt.Header.PacketID)
|
binary.BigEndian.PutUint16(ackData, pkt.Header.PacketID)
|
||||||
|
|
||||||
ack := protocol.NewPacket(protocol.PacketTypeAck, ackData)
|
ack := protocol.NewPacket(protocol.PacketTypeAck, ackData)
|
||||||
// Spec/ts3j: Header PID for ACK matches the packet being acknowledged
|
// Spec/ts3j: Ack has its own counter
|
||||||
ack.Header.PacketID = pkt.Header.PacketID
|
c.AckPacketID++
|
||||||
|
ack.Header.PacketID = c.AckPacketID
|
||||||
ack.Header.ClientID = c.ClientID
|
ack.Header.ClientID = c.ClientID
|
||||||
// ACKs usually don't have NewProtocol flag set in Header byte
|
// ACKs usually don't have NewProtocol flag set in Header byte
|
||||||
ack.Header.Type &= ^uint8(protocol.PacketFlagNewProtocol)
|
ack.Header.Type &= ^uint8(protocol.PacketFlagNewProtocol)
|
||||||
@@ -56,28 +57,61 @@ func (c *Client) handlePacket(pkt *protocol.Packet) error {
|
|||||||
case protocol.PacketTypeVoice:
|
case protocol.PacketTypeVoice:
|
||||||
c.handleVoice(pkt)
|
c.handleVoice(pkt)
|
||||||
case protocol.PacketTypePing:
|
case protocol.PacketTypePing:
|
||||||
|
// Respond with Pong
|
||||||
// Respond with Pong
|
// Respond with Pong
|
||||||
pong := protocol.NewPacket(protocol.PacketTypePong, nil)
|
pong := protocol.NewPacket(protocol.PacketTypePong, nil)
|
||||||
// Spec/ts3j: Header PID for Pong matches the Ping ID
|
// Spec/ts3j: Pong has its own counter
|
||||||
pong.Header.PacketID = pkt.Header.PacketID
|
c.PongPacketID++
|
||||||
|
pong.Header.PacketID = c.PongPacketID
|
||||||
pong.Header.ClientID = c.ClientID
|
pong.Header.ClientID = c.ClientID
|
||||||
// Must NOT have NewProtocol (0x20) flag for Pings/Pongs
|
|
||||||
pong.Header.Type = uint8(protocol.PacketTypePong) | protocol.PacketFlagUnencrypted
|
|
||||||
|
|
||||||
// Use SharedMac if available, otherwise zeros
|
// Determine valid keys for encryption
|
||||||
if c.Handshake != nil && len(c.Handshake.SharedMac) > 0 {
|
key := protocol.HandshakeKey
|
||||||
|
nonce := protocol.HandshakeNonce
|
||||||
|
shouldEncrypt := false
|
||||||
|
|
||||||
|
if c.Handshake != nil && c.Handshake.Step >= 6 && len(c.Handshake.SharedMac) > 0 {
|
||||||
|
shouldEncrypt = true
|
||||||
copy(pong.Header.MAC[:], c.Handshake.SharedMac)
|
copy(pong.Header.MAC[:], c.Handshake.SharedMac)
|
||||||
|
|
||||||
|
// Generate EAX keys
|
||||||
|
if len(c.Handshake.SharedIV) > 0 {
|
||||||
|
crypto := &protocol.CryptoState{
|
||||||
|
SharedIV: c.Handshake.SharedIV,
|
||||||
|
SharedMac: c.Handshake.SharedMac,
|
||||||
|
GenerationID: 0,
|
||||||
|
}
|
||||||
|
key, nonce = crypto.GenerateKeyNonce(&pong.Header, true) // Client->Server
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
|
// Pre-handshake or fallback
|
||||||
|
pong.Header.Type = uint8(protocol.PacketTypePong) | protocol.PacketFlagUnencrypted
|
||||||
for i := 0; i < 8; i++ {
|
for i := 0; i < 8; i++ {
|
||||||
pong.Header.MAC[i] = 0
|
pong.Header.MAC[i] = 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// The body of the Pong must contain the PID of the Ping it's acknowledging
|
// The body of the Pong must contain the PID of the Ping it's acknowledging
|
||||||
pong.Data = make([]byte, 2)
|
pongData := make([]byte, 2)
|
||||||
binary.BigEndian.PutUint16(pong.Data, pkt.Header.PacketID)
|
binary.BigEndian.PutUint16(pongData, pkt.Header.PacketID)
|
||||||
|
|
||||||
|
if shouldEncrypt {
|
||||||
|
// Encrypt the Pong data
|
||||||
|
// Meta for Client->Server: PID(2) + CID(2) + PT(1) = 5 bytes
|
||||||
|
meta := make([]byte, 5)
|
||||||
|
binary.BigEndian.PutUint16(meta[0:2], pong.Header.PacketID)
|
||||||
|
binary.BigEndian.PutUint16(meta[2:4], pong.Header.ClientID)
|
||||||
|
meta[4] = pong.Header.Type // ensure NewProtocol is NOT set (0x05)
|
||||||
|
|
||||||
|
encData, mac, _ := protocol.EncryptEAX(key, nonce, meta, pongData)
|
||||||
|
pong.Data = encData
|
||||||
|
copy(pong.Header.MAC[:], mac)
|
||||||
|
log.Printf("Sending Encrypted Pong (HeaderPID=%d) for Ping", pong.Header.PacketID)
|
||||||
|
} else {
|
||||||
|
pong.Data = pongData
|
||||||
|
log.Printf("Sending Unencrypted Pong (HeaderPID=%d) for Ping", pong.Header.PacketID)
|
||||||
|
}
|
||||||
|
|
||||||
log.Printf("Sending Pong (HeaderPID=%d) for Ping", pong.Header.PacketID)
|
|
||||||
c.Conn.SendPacket(pong)
|
c.Conn.SendPacket(pong)
|
||||||
case protocol.PacketTypePong:
|
case protocol.PacketTypePong:
|
||||||
// Server acknowledged our Ping
|
// Server acknowledged our Ping
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ func (c *Client) SendCommand(cmd *protocol.Command) error {
|
|||||||
|
|
||||||
// SendCommandString sends a raw command string with fragmentation.
|
// SendCommandString sends a raw command string with fragmentation.
|
||||||
func (c *Client) SendCommandString(cmdStr string) error {
|
func (c *Client) SendCommandString(cmdStr string) error {
|
||||||
|
log.Printf("Sending Command: %s", cmdStr)
|
||||||
data := []byte(cmdStr)
|
data := []byte(cmdStr)
|
||||||
maxPacketSize := 500
|
maxPacketSize := 500
|
||||||
maxBody := maxPacketSize - 13 // Header is 13 bytes for C->S (MAC 8, PID 2, TYPE 1, CID 2)
|
maxBody := maxPacketSize - 13 // Header is 13 bytes for C->S (MAC 8, PID 2, TYPE 1, CID 2)
|
||||||
|
|||||||
@@ -283,9 +283,23 @@ func (c *Client) handleInternalEvent(eventType string, data map[string]any) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
case "client_moved":
|
case "client_moved":
|
||||||
|
clientID := getUint16(data, "clientID")
|
||||||
|
channelID := getUint64(data, "channelID")
|
||||||
|
|
||||||
|
c.clientsMu.Lock()
|
||||||
|
if client, ok := c.clients[clientID]; ok {
|
||||||
|
client.ChannelID = channelID
|
||||||
|
}
|
||||||
|
c.clientsMu.Unlock()
|
||||||
|
|
||||||
|
// Update selfInfo if it's us
|
||||||
|
if c.selfInfo != nil && c.selfInfo.ClientID == clientID {
|
||||||
|
c.selfInfo.ChannelID = channelID
|
||||||
|
}
|
||||||
|
|
||||||
c.emit(EventClientMoved, &ClientMovedEvent{
|
c.emit(EventClientMoved, &ClientMovedEvent{
|
||||||
ClientID: getUint16(data, "clientID"),
|
ClientID: clientID,
|
||||||
ChannelID: getUint64(data, "channelID"),
|
ChannelID: channelID,
|
||||||
})
|
})
|
||||||
|
|
||||||
case "channel_list":
|
case "channel_list":
|
||||||
|
|||||||
@@ -81,7 +81,9 @@ func (c *Client) JoinChannelWithPassword(channelID uint64, password string) erro
|
|||||||
cmd := protocol.NewCommand("clientmove")
|
cmd := protocol.NewCommand("clientmove")
|
||||||
cmd.AddParam("clid", fmt.Sprintf("%d", c.selfInfo.ClientID))
|
cmd.AddParam("clid", fmt.Sprintf("%d", c.selfInfo.ClientID))
|
||||||
cmd.AddParam("cid", fmt.Sprintf("%d", channelID))
|
cmd.AddParam("cid", fmt.Sprintf("%d", channelID))
|
||||||
|
if password != "" {
|
||||||
cmd.AddParam("cpw", password)
|
cmd.AddParam("cpw", password)
|
||||||
|
}
|
||||||
|
|
||||||
err := c.internal.SendCommand(cmd)
|
err := c.internal.SendCommand(cmd)
|
||||||
if err == nil && c.selfInfo != nil {
|
if err == nil && c.selfInfo != nil {
|
||||||
|
|||||||
Binary file not shown.
BIN
ts-client.exe
BIN
ts-client.exe
Binary file not shown.
BIN
voicebot.exe
BIN
voicebot.exe
Binary file not shown.
Reference in New Issue
Block a user