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

45 lines
925 B
Go
Raw Normal View History

2016-12-08 15:27:41 +00:00
package noop
import (
"net"
"v2ray.com/core/common/loader"
"v2ray.com/core/transport/internet"
)
type NoOpHeader struct{}
func (v NoOpHeader) Size() int {
return 0
}
func (v NoOpHeader) Write([]byte) int {
return 0
}
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() {
internet.RegisterPacketHeader(loader.GetType(new(Config)), NoOpHeaderFactory{})
internet.RegisterConnectionAuthenticator(loader.GetType(new(Config)), NoOpConnectionHeaderFactory{})
}