This commit is contained in:
bjdgy 2023-12-26 13:00:55 +08:00
parent 17492d8172
commit 638a99275e
2 changed files with 15 additions and 6 deletions

View File

@ -28,6 +28,10 @@ var (
logName = "anylink.log"
)
func init() {
log.SetFlags(log.LstdFlags | log.Lshortfile)
}
// 实现 os.Writer 接口
type logWriter struct {
UseStdout bool

View File

@ -50,20 +50,25 @@ func CheckModOrLoad(mod string) {
return
}
var err error
if mod == "tun" || mod == "tap" {
_, err := os.Stat(tunPath)
_, err = os.Stat(tunPath)
if err == nil {
// 文件存在
return
}
panic("Linux tunFile is null " + tunPath)
err = fmt.Errorf("Linux tunFile is null %s", tunPath)
log.Println(err)
return
// panic(err)
}
if InContainer {
err := fmt.Errorf("Linux module %s is not loaded, please run `modprobe %s`", mod, mod)
// log.Println(err)
// return
panic(err)
err = fmt.Errorf("Linux module %s is not loaded, please run `modprobe %s`", mod, mod)
log.Println(err)
return
// panic(err)
}
cmdstr := fmt.Sprintln("modprobe", mod)