1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-09-15 16:38:16 -04:00
v2fly/transport/internet/headers/noop/noop.go

41 lines
802 B
Go
Raw Normal View History

2016-12-08 10:27:41 -05:00
package noop
import (
2017-01-12 16:47:10 -05:00
"context"
2016-12-08 10:27:41 -05:00
"net"
2017-01-12 16:47:10 -05:00
"v2ray.com/core/common"
2016-12-08 10:27:41 -05:00
)
type NoOpHeader struct{}
2018-04-02 14:00:50 -04:00
func (NoOpHeader) Size() int32 {
2016-12-08 10:27:41 -05:00
return 0
}
2017-04-21 09:36:05 -04:00
2018-11-02 16:34:04 -04:00
// Serialize implements PacketHeader.
func (NoOpHeader) Serialize([]byte) {}
2016-12-08 10:27:41 -05:00
2017-01-12 16:47:10 -05:00
func NewNoOpHeader(context.Context, interface{}) (interface{}, error) {
return NoOpHeader{}, nil
2016-12-08 10:27:41 -05: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 16:47:10 -05:00
func NewNoOpConnectionHeader(context.Context, interface{}) (interface{}, error) {
return NoOpConnectionHeader{}, nil
2016-12-08 10:27:41 -05:00
}
func init() {
2017-01-12 16:47:10 -05:00
common.Must(common.RegisterConfig((*Config)(nil), NewNoOpHeader))
common.Must(common.RegisterConfig((*ConnectionConfig)(nil), NewNoOpConnectionHeader))
2016-12-08 10:27:41 -05:00
}