mirror of
https://github.com/fosrl/olm.git
synced 2026-02-16 01:46:45 +00:00
Merge branch 'dev' of github.com:fosrl/olm into dev
Former-commit-id: 8c5c8d3966
This commit is contained in:
15
olm/olm.go
15
olm/olm.go
@@ -112,6 +112,17 @@ func Init(ctx context.Context, config GlobalConfig) {
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
if config.LogFilePath != "" {
|
||||
logFile, err := os.OpenFile(config.LogFilePath, os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0o644)
|
||||
if err != nil {
|
||||
logger.Fatal("Failed to open log file: %v", err)
|
||||
}
|
||||
|
||||
// TODO: figure out how to close file, if set
|
||||
logger.SetOutput(logFile)
|
||||
return
|
||||
}
|
||||
|
||||
logger.Debug("Checking permissions for native interface")
|
||||
err := permissions.CheckNativeInterfacePermissions()
|
||||
@@ -322,7 +333,7 @@ func StartTunnel(config TunnelConfig) {
|
||||
if config.FileDescriptorTun != 0 {
|
||||
return olmDevice.CreateTUNFromFD(config.FileDescriptorTun, config.MTU)
|
||||
}
|
||||
var ifName = interfaceName
|
||||
ifName := interfaceName
|
||||
if runtime.GOOS == "darwin" { // this is if we dont pass a fd
|
||||
ifName, err = network.FindUnusedUTUN()
|
||||
if err != nil {
|
||||
@@ -331,7 +342,6 @@ func StartTunnel(config TunnelConfig) {
|
||||
}
|
||||
return tun.CreateTUN(ifName, config.MTU)
|
||||
}()
|
||||
|
||||
if err != nil {
|
||||
logger.Error("Failed to create TUN device: %v", err)
|
||||
return
|
||||
@@ -377,7 +387,6 @@ func StartTunnel(config TunnelConfig) {
|
||||
for {
|
||||
conn, err := uapiListener.Accept()
|
||||
if err != nil {
|
||||
|
||||
return
|
||||
}
|
||||
go dev.IpcHandle(conn)
|
||||
|
||||
@@ -14,7 +14,8 @@ type WgData struct {
|
||||
|
||||
type GlobalConfig struct {
|
||||
// Logging
|
||||
LogLevel string
|
||||
LogLevel string
|
||||
LogFilePath string
|
||||
|
||||
// HTTP server
|
||||
EnableAPI bool
|
||||
|
||||
Reference in New Issue
Block a user