-
Notifications
You must be signed in to change notification settings - Fork 0
/
noop.go
44 lines (32 loc) · 939 Bytes
/
noop.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
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, error) {
return 0, nil
}
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{})
}