Xray-core/transport/internet/headers/noop/noop.go

41 lines
813 B
Go
Raw Normal View History

2020-11-25 11:01:53 +00:00
package noop
import (
"context"
"net"
2020-12-04 01:36:16 +00:00
"github.com/xtls/xray-core/common"
2020-11-25 11:01:53 +00:00
)
type NoOpHeader struct{}
func (NoOpHeader) Size() int32 {
return 0
}
// Serialize implements PacketHeader.
func (NoOpHeader) Serialize([]byte) {}
func NewNoOpHeader(context.Context, interface{}) (interface{}, error) {
return NoOpHeader{}, nil
}
type NoOpConnectionHeader struct{}
func (NoOpConnectionHeader) Client(conn net.Conn) net.Conn {
return conn
}
func (NoOpConnectionHeader) Server(conn net.Conn) net.Conn {
return conn
}
func NewNoOpConnectionHeader(context.Context, interface{}) (interface{}, error) {
return NoOpConnectionHeader{}, nil
}
func init() {
common.Must(common.RegisterConfig((*Config)(nil), NewNoOpHeader))
common.Must(common.RegisterConfig((*ConnectionConfig)(nil), NewNoOpConnectionHeader))
}