mirror of https://github.com/v2ray/v2ray-core
45 lines
925 B
Go
45 lines
925 B
Go
|
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{})
|
||
|
}
|