Files
kubevpn/exe/driver.go
wencaiwulue 7f846f6c0b first commit
2021-07-24 19:10:03 +08:00

38 lines
662 B
Go
Executable File

package exe
import (
"fmt"
log "github.com/sirupsen/logrus"
"os"
"os/exec"
"path/filepath"
)
func InstallTunTapDriver() {
if err := Install(); err != nil {
log.Fatal(err)
}
}
func UninstallTunTapDriver() {
filepath.VolumeName("C")
path := filepath.Join(getDriver()+":\\", "Program Files", "TAP-Windows", "Uninstall.exe")
cmd := exec.Command(path, "/S")
b, e := cmd.CombinedOutput()
if e != nil {
fmt.Println(e)
}
fmt.Println(string(b))
}
func getDriver() string {
for _, drive := range "ABCDEFGHIJKLMNOPQRSTUVWXYZ" {
f, err := os.Open(string(drive) + ":\\")
if err == nil {
_ = f.Close()
return string(drive)
}
}
return ""
}