mirror of
https://github.com/fosrl/olm.git
synced 2026-02-23 21:36:40 +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
|
ep *channel.Endpoint
|
||||||
proxyIP netip.Addr
|
proxyIP netip.Addr
|
||||||
upstreamDNS []string
|
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
|
mtu int
|
||||||
middleDevice *device.MiddleDevice // Reference to MiddleDevice for packet filtering and TUN writes
|
middleDevice *device.MiddleDevice // Reference to MiddleDevice for packet filtering and TUN writes
|
||||||
recordStore *DNSRecordStore // Local DNS records
|
recordStore *DNSRecordStore // Local DNS records
|
||||||
|
|
||||||
// Tunnel DNS fields - for sending queries over WireGuard
|
// Tunnel DNS fields - for sending queries over WireGuard
|
||||||
tunnelIP netip.Addr // WireGuard interface IP (source for tunneled queries)
|
tunnelIP netip.Addr // WireGuard interface IP (source for tunneled queries)
|
||||||
tunnelStack *stack.Stack // Separate netstack for outbound tunnel queries
|
tunnelStack *stack.Stack // Separate netstack for outbound tunnel queries
|
||||||
tunnelEp *channel.Endpoint
|
tunnelEp *channel.Endpoint
|
||||||
tunnelActivePorts map[uint16]bool
|
tunnelActivePorts map[uint16]bool
|
||||||
tunnelPortsLock sync.Mutex
|
tunnelPortsLock sync.Mutex
|
||||||
|
|
||||||
ctx context.Context
|
ctx context.Context
|
||||||
cancel context.CancelFunc
|
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")
|
logger.Debug("Checking permissions for native interface")
|
||||||
err := permissions.CheckNativeInterfacePermissions()
|
err := permissions.CheckNativeInterfacePermissions()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -322,7 +333,7 @@ func StartTunnel(config TunnelConfig) {
|
|||||||
if config.FileDescriptorTun != 0 {
|
if config.FileDescriptorTun != 0 {
|
||||||
return olmDevice.CreateTUNFromFD(config.FileDescriptorTun, config.MTU)
|
return olmDevice.CreateTUNFromFD(config.FileDescriptorTun, config.MTU)
|
||||||
}
|
}
|
||||||
var ifName = interfaceName
|
ifName := interfaceName
|
||||||
if runtime.GOOS == "darwin" { // this is if we dont pass a fd
|
if runtime.GOOS == "darwin" { // this is if we dont pass a fd
|
||||||
ifName, err = network.FindUnusedUTUN()
|
ifName, err = network.FindUnusedUTUN()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -331,7 +342,6 @@ func StartTunnel(config TunnelConfig) {
|
|||||||
}
|
}
|
||||||
return tun.CreateTUN(ifName, config.MTU)
|
return tun.CreateTUN(ifName, config.MTU)
|
||||||
}()
|
}()
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Error("Failed to create TUN device: %v", err)
|
logger.Error("Failed to create TUN device: %v", err)
|
||||||
return
|
return
|
||||||
@@ -377,7 +387,6 @@ func StartTunnel(config TunnelConfig) {
|
|||||||
for {
|
for {
|
||||||
conn, err := uapiListener.Accept()
|
conn, err := uapiListener.Accept()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
go dev.IpcHandle(conn)
|
go dev.IpcHandle(conn)
|
||||||
|
|||||||
@@ -14,7 +14,8 @@ type WgData struct {
|
|||||||
|
|
||||||
type GlobalConfig struct {
|
type GlobalConfig struct {
|
||||||
// Logging
|
// Logging
|
||||||
LogLevel string
|
LogLevel string
|
||||||
|
LogFilePath string
|
||||||
|
|
||||||
// HTTP server
|
// HTTP server
|
||||||
EnableAPI bool
|
EnableAPI bool
|
||||||
|
|||||||
Reference in New Issue
Block a user