wechat.go 713 B

123456789101112131415161718192021222324252627282930313233343536
  1. package wechat
  2. import (
  3. "v2ray.com/core/common"
  4. "v2ray.com/core/common/dice"
  5. "v2ray.com/core/common/serial"
  6. "v2ray.com/core/transport/internet"
  7. )
  8. type VideoChat struct {
  9. sn int
  10. }
  11. func (vc *VideoChat) Size() int {
  12. return 13
  13. }
  14. func (vc *VideoChat) Write(b []byte) (int, error) {
  15. vc.sn++
  16. b = append(b[:0], 0xa1, 0x08)
  17. b = serial.IntToBytes(vc.sn, b)
  18. b = append(b, 0x10, 0x11, 0x18, 0x30, 0x22, 0x30)
  19. return 13, nil
  20. }
  21. type VideoChatFactory struct{}
  22. func (VideoChatFactory) Create(rawSettings interface{}) internet.PacketHeader {
  23. return &VideoChat{
  24. sn: dice.Roll(65535),
  25. }
  26. }
  27. func init() {
  28. common.Must(internet.RegisterPacketHeader(serial.GetMessageType(new(VideoConfig)), VideoChatFactory{}))
  29. }