noop.go 770 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. package noop
  2. import (
  3. "context"
  4. "net"
  5. "github.com/v2fly/v2ray-core/v5/common"
  6. )
  7. type Header struct{}
  8. func (Header) Size() int32 {
  9. return 0
  10. }
  11. // Serialize implements PacketHeader.
  12. func (Header) Serialize([]byte) {}
  13. func NewHeader(context.Context, interface{}) (interface{}, error) {
  14. return Header{}, nil
  15. }
  16. type ConnectionHeader struct{}
  17. func (ConnectionHeader) Client(conn net.Conn) net.Conn {
  18. return conn
  19. }
  20. func (ConnectionHeader) Server(conn net.Conn) net.Conn {
  21. return conn
  22. }
  23. func NewConnectionHeader(context.Context, interface{}) (interface{}, error) {
  24. return ConnectionHeader{}, nil
  25. }
  26. func init() {
  27. common.Must(common.RegisterConfig((*Config)(nil), NewHeader))
  28. common.Must(common.RegisterConfig((*ConnectionConfig)(nil), NewConnectionHeader))
  29. }