vmess.go 861 B

12345678910111213141516171819202122232425262728293031323334353637
  1. // Package vmess contains protocol definition, io lib for VMess.
  2. package vmess
  3. import (
  4. "net"
  5. )
  6. // VMessInput implements the input message of VMess protocol. It only contains
  7. // the header of a input message. The data part will be handled by conection
  8. // handler directly, in favor of data streaming.
  9. type VMessInput struct {
  10. version byte
  11. userHash [16]byte
  12. randHash [256]byte
  13. respKey [32]byte
  14. iv [16]byte
  15. command byte
  16. port uint16
  17. target [256]byte
  18. }
  19. type VMessReader struct {
  20. conn *net.Conn
  21. }
  22. // NewVMessReader creates a new VMessReader
  23. func NewVMessReader(conn *net.Conn) (VMessReader, error) {
  24. var reader VMessReader
  25. reader.conn = conn
  26. return reader, nil
  27. }
  28. // Read reads data from current connection and form a VMessInput if possible.
  29. func (*VMessReader) Read() (VMessInput, error) {
  30. var input VMessInput
  31. return input, nil
  32. }