Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
bjdgy committed Dec 26, 2023
1 parent 17492d8 commit 638a992
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
4 changes: 4 additions & 0 deletions server/base/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ var (
logName = "anylink.log"
)

func init() {
log.SetFlags(log.LstdFlags | log.Lshortfile)
}

// 实现 os.Writer 接口
type logWriter struct {
UseStdout bool
Expand Down
17 changes: 11 additions & 6 deletions server/base/mod.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 638a992

Please sign in to comment.