Maint: tun package to handle tun device operations

- Moved from openvpn package to tun package
- TUN check verifies Rdev value
- TUN create
- Inject as interface to main function
- Add integration test
- Clearer log message for end users if tun device does not exist
- Remove unix package (unneeded for tests)
- Remove tun file opening at the end of tun file creation
- Do not mock unix.Mkdev (no OS operation)
- Remove Tun operations from OpenVPN configurator
This commit is contained in:
Quentin McGaw (desktop)
2021-08-18 15:31:08 +00:00
parent 384a4bae3a
commit 6a545aa088
10 changed files with 186 additions and 172 deletions

20
internal/tun/tun.go Normal file
View File

@@ -0,0 +1,20 @@
package tun
import "golang.org/x/sys/unix"
var _ Interface = (*Tun)(nil)
type Interface interface {
Checker
Creator
}
type Tun struct {
mknod func(path string, mode uint32, dev int) (err error)
}
func New() *Tun {
return &Tun{
mknod: unix.Mknod,
}
}