41 lines
802 B
Go
Raw Normal View History

2016-12-08 16:27:41 +01:00
package noop
import (
2017-01-12 22:47:10 +01:00
"context"
2016-12-08 16:27:41 +01:00
"net"
2017-01-12 22:47:10 +01:00
"v2ray.com/core/common"
2016-12-08 16:27:41 +01:00
)
type NoOpHeader struct{}
2018-04-02 20:00:50 +02:00
func (NoOpHeader) Size() int32 {
2016-12-08 16:27:41 +01:00
return 0
}
2017-04-21 15:36:05 +02:00
2018-11-02 21:34:04 +01:00
// Serialize implements PacketHeader.
func (NoOpHeader) Serialize([]byte) {}
2016-12-08 16:27:41 +01:00
2017-01-12 22:47:10 +01:00
func NewNoOpHeader(context.Context, interface{}) (interface{}, error) {
return NoOpHeader{}, nil
2016-12-08 16:27:41 +01:00
}
type NoOpConnectionHeader struct{}
func (NoOpConnectionHeader) Client(conn net.Conn) net.Conn {
return conn
}
func (NoOpConnectionHeader) Server(conn net.Conn) net.Conn {
return conn
}
2017-01-12 22:47:10 +01:00
func NewNoOpConnectionHeader(context.Context, interface{}) (interface{}, error) {
return NoOpConnectionHeader{}, nil
2016-12-08 16:27:41 +01:00
}
func init() {
2017-01-12 22:47:10 +01:00
common.Must(common.RegisterConfig((*Config)(nil), NewNoOpHeader))
common.Must(common.RegisterConfig((*ConnectionConfig)(nil), NewNoOpConnectionHeader))
2016-12-08 16:27:41 +01:00
}