POC: the user has full control over outgoing traffic

This commit is contained in:
ChillerDragon 2024-06-20 12:10:22 +08:00
parent 79d6308a4a
commit a112473d0f
2 changed files with 12 additions and 1 deletions

View file

@ -26,4 +26,3 @@ func (msg CtrlKeepAlive) Vital() bool {
func (msg CtrlKeepAlive) Pack() []byte { func (msg CtrlKeepAlive) Pack() []byte {
return []byte{network7.MsgCtrlKeepAlive} return []byte{network7.MsgCtrlKeepAlive}
} }

View file

@ -7,6 +7,7 @@ import (
"os" "os"
"time" "time"
"github.com/teeworlds-go/teeworlds/messages7"
"github.com/teeworlds-go/teeworlds/network7" "github.com/teeworlds-go/teeworlds/network7"
"github.com/teeworlds-go/teeworlds/protocol7" "github.com/teeworlds-go/teeworlds/protocol7"
) )
@ -71,6 +72,17 @@ func main() {
panic(err) panic(err)
} }
if packet != nil { if packet != nil {
// example of modifying outgoing traffic
for i, msg := range packet.Messages {
if msg.MsgId() == network7.MsgCtrlConnect {
if connect, ok := packet.Messages[0].(messages7.CtrlConnect); ok {
connect.Token = [4]byte{0xaa, 0xaa, 0xaa, 0xaa}
packet.Messages[i] = connect
}
}
}
conn.Write(packet.Pack(client)) conn.Write(packet.Pack(client))
} }
default: default: