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

45 lines
953 B
Go
Raw Normal View History

2016-12-08 15:27:41 +00:00
package noop
import (
"net"
2016-12-15 10:51:09 +00:00
"v2ray.com/core/common/serial"
2016-12-08 15:27:41 +00:00
"v2ray.com/core/transport/internet"
)
type NoOpHeader struct{}
func (v NoOpHeader) Size() int {
return 0
}
2016-12-09 11:08:25 +00:00
func (v NoOpHeader) Write([]byte) (int, error) {
return 0, nil
2016-12-08 15:27:41 +00:00
}
type NoOpHeaderFactory struct{}
func (v NoOpHeaderFactory) Create(config interface{}) internet.PacketHeader {
return NoOpHeader{}
}
type NoOpConnectionHeader struct{}
func (NoOpConnectionHeader) Client(conn net.Conn) net.Conn {
return conn
}
func (NoOpConnectionHeader) Server(conn net.Conn) net.Conn {
return conn
}
type NoOpConnectionHeaderFactory struct{}
func (NoOpConnectionHeaderFactory) Create(config interface{}) internet.ConnectionAuthenticator {
return NoOpConnectionHeader{}
}
func init() {
2016-12-15 10:51:09 +00:00
internet.RegisterPacketHeader(serial.GetMessageType(new(Config)), NoOpHeaderFactory{})
internet.RegisterConnectionAuthenticator(serial.GetMessageType(new(Config)), NoOpConnectionHeaderFactory{})
2016-12-08 15:27:41 +00:00
}