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
|
|
|
|
|
|
|
// Write implements io.Writer.
|
2017-04-13 16:17:58 -04:00
|
|
|
func (NoOpHeader) Write([]byte) (int, error) {
|
2016-12-09 06:08:25 -05:00
|
|
|
return 0, nil
|
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
|
|
|
}
|