wechat.go 790 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. package wechat
  2. import (
  3. "context"
  4. "encoding/binary"
  5. "v2ray.com/core/common"
  6. "v2ray.com/core/common/dice"
  7. )
  8. type VideoChat struct {
  9. sn uint32
  10. }
  11. func (vc *VideoChat) Size() int32 {
  12. return 13
  13. }
  14. // Write implements io.Writer.
  15. func (vc *VideoChat) Write(b []byte) (int, error) {
  16. vc.sn++
  17. b[0] = 0xa1
  18. b[1] = 0x08
  19. binary.BigEndian.PutUint32(b[2:], vc.sn) // b[2:6]
  20. b[6] = 0x00
  21. b[7] = 0x10
  22. b[8] = 0x11
  23. b[9] = 0x18
  24. b[10] = 0x30
  25. b[11] = 0x22
  26. b[12] = 0x30
  27. return 13, nil
  28. }
  29. // NewVideoChat returns a new VideoChat instance based on given config.
  30. func NewVideoChat(ctx context.Context, config interface{}) (interface{}, error) {
  31. return &VideoChat{
  32. sn: uint32(dice.RollUint16()),
  33. }, nil
  34. }
  35. func init() {
  36. common.Must(common.RegisterConfig((*VideoConfig)(nil), NewVideoChat))
  37. }