wechat.go 637 B

1234567891011121314151617181920212223242526272829303132333435
  1. package wechat
  2. import (
  3. "context"
  4. "v2ray.com/core/common"
  5. "v2ray.com/core/common/dice"
  6. "v2ray.com/core/common/serial"
  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. func NewVideoChat(ctx context.Context, config interface{}) (interface{}, error) {
  22. return &VideoChat{
  23. sn: int(dice.RandomUint16()),
  24. }, nil
  25. }
  26. func init() {
  27. common.Must(common.RegisterConfig((*VideoConfig)(nil), NewVideoChat))
  28. }