MCPcopy Create free account
hub / github.com/encodeous/nylon / CreateUnmonitoredTUNFromFD

Function CreateUnmonitoredTUNFromFD

polyamide/tun/tun_linux.go:637–660  ·  view source on GitHub ↗

CreateUnmonitoredTUNFromFD creates a Device from the provided file descriptor.

(fd int)

Source from the content-addressed store, hash-verified

635// CreateUnmonitoredTUNFromFD creates a Device from the provided file
636// descriptor.
637func CreateUnmonitoredTUNFromFD(fd int) (Device, string, error) {
638 err := unix.SetNonblock(fd, true)
639 if err != nil {
640 return nil, "", err
641 }
642 file := os.NewFile(uintptr(fd), "/dev/tun")
643 tun := &NativeTun{
644 tunFile: file,
645 events: make(chan Event, 5),
646 errors: make(chan error, 5),
647 tcpGROTable: newTCPGROTable(),
648 udpGROTable: newUDPGROTable(),
649 toWrite: make([]int, 0, conn.IdealBatchSize),
650 }
651 name, err := tun.Name()
652 if err != nil {
653 return nil, "", err
654 }
655 err = tun.initFromFlags(name)
656 if err != nil {
657 return nil, "", err
658 }
659 return tun, name, err
660}

Callers

nothing calls this directly

Calls 4

NameMethod · 0.95
initFromFlagsMethod · 0.95
newTCPGROTableFunction · 0.85
newUDPGROTableFunction · 0.85

Tested by

no test coverage detected