-
Notifications
You must be signed in to change notification settings - Fork 0
/
noop.go
42 lines (31 loc) · 818 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
package noop
import (
"context"
"net"
"v2ray.com/core/common"
)
type NoOpHeader struct{}
func (NoOpHeader) Size() int {
return 0
}
// Write implements io.Writer.
func (NoOpHeader) Write([]byte) (int, error) {
return 0, nil
}
func NewNoOpHeader(context.Context, interface{}) (interface{}, error) {
return NoOpHeader{}, nil
}
type NoOpConnectionHeader struct{}
func (NoOpConnectionHeader) Client(conn net.Conn) net.Conn {
return conn
}
func (NoOpConnectionHeader) Server(conn net.Conn) net.Conn {
return conn
}
func NewNoOpConnectionHeader(context.Context, interface{}) (interface{}, error) {
return NoOpConnectionHeader{}, nil
}
func init() {
common.Must(common.RegisterConfig((*Config)(nil), NewNoOpHeader))
common.Must(common.RegisterConfig((*ConnectionConfig)(nil), NewNoOpConnectionHeader))
}