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

41 lines
786 B
Go
Raw Normal View History

2016-12-08 15:27:41 +00:00
package noop
import (
2017-01-12 21:47:10 +00:00
"context"
2016-12-08 15:27:41 +00:00
"net"
2017-01-12 21:47:10 +00:00
"v2ray.com/core/common"
2016-12-08 15:27:41 +00:00
)
type NoOpHeader struct{}
2017-04-13 20:17:58 +00:00
func (NoOpHeader) Size() int {
2016-12-08 15:27:41 +00:00
return 0
}
2017-04-13 20:17:58 +00:00
func (NoOpHeader) Write([]byte) (int, error) {
2016-12-09 11:08:25 +00:00
return 0, nil
2016-12-08 15:27:41 +00:00
}
2017-01-12 21:47:10 +00:00
func NewNoOpHeader(context.Context, interface{}) (interface{}, error) {
return NoOpHeader{}, nil
2016-12-08 15:27:41 +00: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 21:47:10 +00:00
func NewNoOpConnectionHeader(context.Context, interface{}) (interface{}, error) {
return NoOpConnectionHeader{}, nil
2016-12-08 15:27:41 +00:00
}
func init() {
2017-01-12 21:47:10 +00:00
common.Must(common.RegisterConfig((*Config)(nil), NewNoOpHeader))
common.Must(common.RegisterConfig((*ConnectionConfig)(nil), NewNoOpConnectionHeader))
2016-12-08 15:27:41 +00:00
}