mirror of
https://github.com/fosrl/olm.git
synced 2026-02-08 05:56:41 +00:00
Merge branch 'dev' of github.com:fosrl/olm into dev
Former-commit-id: 8c5c8d3966
This commit is contained in:
@@ -33,17 +33,17 @@ type DNSProxy struct {
|
||||
ep *channel.Endpoint
|
||||
proxyIP netip.Addr
|
||||
upstreamDNS []string
|
||||
tunnelDNS bool // Whether to tunnel DNS queries over WireGuard or to spit them out locally
|
||||
tunnelDNS bool // Whether to tunnel DNS queries over WireGuard or to spit them out locally
|
||||
mtu int
|
||||
middleDevice *device.MiddleDevice // Reference to MiddleDevice for packet filtering and TUN writes
|
||||
recordStore *DNSRecordStore // Local DNS records
|
||||
|
||||
// Tunnel DNS fields - for sending queries over WireGuard
|
||||
tunnelIP netip.Addr // WireGuard interface IP (source for tunneled queries)
|
||||
tunnelStack *stack.Stack // Separate netstack for outbound tunnel queries
|
||||
tunnelEp *channel.Endpoint
|
||||
tunnelIP netip.Addr // WireGuard interface IP (source for tunneled queries)
|
||||
tunnelStack *stack.Stack // Separate netstack for outbound tunnel queries
|
||||
tunnelEp *channel.Endpoint
|
||||
tunnelActivePorts map[uint16]bool
|
||||
tunnelPortsLock sync.Mutex
|
||||
tunnelPortsLock sync.Mutex
|
||||
|
||||
ctx context.Context
|
||||
cancel context.CancelFunc
|
||||
|
||||
15
olm/olm.go
15
olm/olm.go
@@ -113,6 +113,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()
|
||||
if err != nil {
|
||||
@@ -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