File tree Expand file tree Collapse file tree 4 files changed +53
-39
lines changed
Expand file tree Collapse file tree 4 files changed +53
-39
lines changed Original file line number Diff line number Diff line change 11package fd
22
3- import (
4- "fmt"
5- "strconv"
6-
7- "github.com/xjasonlyu/tun2socks/core/device"
8- "golang.org/x/sys/unix"
9- "gvisor.dev/gvisor/pkg/tcpip/stack"
10- )
11-
123const Driver = "fd"
13-
14- type FD struct {
15- stack.LinkEndpoint
16-
17- fd int
18- mtu uint32
19- }
20-
21- func Open (name string , mtu uint32 ) (device.Device , error ) {
22- fd , err := strconv .Atoi (name )
23- if err != nil {
24- return nil , fmt .Errorf ("cannot open fd: %s" , name )
25- }
26- return open (fd , mtu )
27- }
28-
29- func (f * FD ) Type () string {
30- return Driver
31- }
32-
33- func (f * FD ) Name () string {
34- return strconv .Itoa (f .fd )
35- }
36-
37- func (f * FD ) Close () error {
38- return unix .Close (f .fd )
39- }
40-
41- var _ device.Device = (* FD )(nil )
Original file line number Diff line number Diff line change 1+ //go:build !windows
2+
3+ package fd
4+
5+ import (
6+ "fmt"
7+ "strconv"
8+
9+ "github.com/xjasonlyu/tun2socks/core/device"
10+ "golang.org/x/sys/unix"
11+ "gvisor.dev/gvisor/pkg/tcpip/stack"
12+ )
13+
14+ type FD struct {
15+ stack.LinkEndpoint
16+
17+ fd int
18+ mtu uint32
19+ }
20+
21+ func Open (name string , mtu uint32 ) (device.Device , error ) {
22+ fd , err := strconv .Atoi (name )
23+ if err != nil {
24+ return nil , fmt .Errorf ("cannot open fd: %s" , name )
25+ }
26+ return open (fd , mtu )
27+ }
28+
29+ func (f * FD ) Type () string {
30+ return Driver
31+ }
32+
33+ func (f * FD ) Name () string {
34+ return strconv .Itoa (f .fd )
35+ }
36+
37+ func (f * FD ) Close () error {
38+ return unix .Close (f .fd )
39+ }
40+
41+ var _ device.Device = (* FD )(nil )
Original file line number Diff line number Diff line change 1+ package fd
2+
3+ import (
4+ "errors"
5+
6+ "github.com/xjasonlyu/tun2socks/core/device"
7+ )
8+
9+ func Open (name string , mtu uint32 ) (device.Device , error ) {
10+ return nil , errors .New ("not supported" )
11+ }
Original file line number Diff line number Diff line change 1- //go:build !linux
1+ //go:build !linux && !windows
22
33package fd
44
You can’t perform that action at this time.
0 commit comments