wechat.go 668 B

123456789101112131415161718192021222324252627282930313233343536
  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. // Write implements io.Writer.
  15. func (vc *VideoChat) Write(b []byte) (int, error) {
  16. vc.sn++
  17. b = append(b[:0], 0xa1, 0x08)
  18. b = serial.IntToBytes(vc.sn, b)
  19. b = append(b, 0x10, 0x11, 0x18, 0x30, 0x22, 0x30)
  20. return 13, nil
  21. }
  22. func NewVideoChat(ctx context.Context, config interface{}) (interface{}, error) {
  23. return &VideoChat{
  24. sn: int(dice.RandomUint16()),
  25. }, nil
  26. }
  27. func init() {
  28. common.Must(common.RegisterConfig((*VideoConfig)(nil), NewVideoChat))
  29. }