mirror of
https://github.com/fosrl/olm.git
synced 2026-03-27 04:56:43 +00:00
Merge branch 'main' into dev
This commit is contained in:
@@ -168,6 +168,7 @@ func (o *Olm) handleConnect(msg websocket.WSMessage) {
|
||||
SharedBind: o.sharedBind,
|
||||
WSClient: o.websocket,
|
||||
APIServer: o.apiServer,
|
||||
PublicDNS: o.tunnelConfig.PublicDNS,
|
||||
})
|
||||
|
||||
for i := range wgData.Sites {
|
||||
|
||||
21
olm/olm.go
21
olm/olm.go
@@ -31,7 +31,7 @@ type Olm struct {
|
||||
privateKey wgtypes.Key
|
||||
logFile *os.File
|
||||
|
||||
registered bool
|
||||
registered bool
|
||||
tunnelRunning bool
|
||||
|
||||
uapiListener net.Listener
|
||||
@@ -111,7 +111,7 @@ func (o *Olm) initTunnelInfo(clientID string) error {
|
||||
logger.Info("Created shared UDP socket on port %d (refcount: %d)", sourcePort, sharedBind.GetRefCount())
|
||||
|
||||
// Create the holepunch manager
|
||||
o.holePunchManager = holepunch.NewManager(sharedBind, clientID, "olm", privateKey.PublicKey().String())
|
||||
o.holePunchManager = holepunch.NewManager(sharedBind, clientID, "olm", privateKey.PublicKey().String(), o.tunnelConfig.PublicDNS)
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -222,7 +222,7 @@ func (o *Olm) registerAPICallbacks() {
|
||||
tunnelConfig.MTU = 1420
|
||||
}
|
||||
if req.DNS == "" {
|
||||
tunnelConfig.DNS = "9.9.9.9"
|
||||
tunnelConfig.DNS = "8.8.8.8"
|
||||
}
|
||||
// DNSProxyIP has no default - it must be provided if DNS proxy is desired
|
||||
// UpstreamDNS defaults to 8.8.8.8 if not provided
|
||||
@@ -292,16 +292,23 @@ func (o *Olm) StartTunnel(config TunnelConfig) {
|
||||
logger.Info("Tunnel already running")
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
// debug print out the whole config
|
||||
logger.Debug("Starting tunnel with config: %+v", config)
|
||||
|
||||
o.tunnelRunning = true // Also set it here in case it is called externally
|
||||
o.tunnelConfig = config
|
||||
|
||||
// TODO: we are hardcoding this for now but we should really pull it from the current config of the system
|
||||
if o.tunnelConfig.DNS != "" {
|
||||
o.tunnelConfig.PublicDNS = []string{o.tunnelConfig.DNS + ":53"}
|
||||
} else {
|
||||
o.tunnelConfig.PublicDNS = []string{"8.8.8.8:53"}
|
||||
}
|
||||
|
||||
// Reset terminated status when tunnel starts
|
||||
o.apiServer.SetTerminated(false)
|
||||
|
||||
|
||||
fingerprint := config.InitialFingerprint
|
||||
if fingerprint == nil {
|
||||
fingerprint = make(map[string]any)
|
||||
@@ -313,7 +320,7 @@ func (o *Olm) StartTunnel(config TunnelConfig) {
|
||||
}
|
||||
|
||||
o.SetFingerprint(fingerprint)
|
||||
o.SetPostures(postures)
|
||||
o.SetPostures(postures)
|
||||
|
||||
// Create a cancellable context for this tunnel process
|
||||
tunnelCtx, cancel := context.WithCancel(o.olmCtx)
|
||||
@@ -387,7 +394,7 @@ func (o *Olm) StartTunnel(config TunnelConfig) {
|
||||
|
||||
if o.registered {
|
||||
o.websocket.StartPingMonitor()
|
||||
|
||||
|
||||
logger.Debug("Already registered, skipping registration")
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -175,7 +175,7 @@ func (o *Olm) handleWgPeerRelay(msg websocket.WSMessage) {
|
||||
return
|
||||
}
|
||||
|
||||
primaryRelay, err := util.ResolveDomain(relayData.RelayEndpoint)
|
||||
primaryRelay, err := util.ResolveDomainUpstream(relayData.RelayEndpoint, o.tunnelConfig.PublicDNS)
|
||||
if err != nil {
|
||||
logger.Error("Failed to resolve primary relay endpoint: %v", err)
|
||||
return
|
||||
@@ -208,7 +208,7 @@ func (o *Olm) handleWgPeerUnrelay(msg websocket.WSMessage) {
|
||||
return
|
||||
}
|
||||
|
||||
primaryRelay, err := util.ResolveDomain(relayData.Endpoint)
|
||||
primaryRelay, err := util.ResolveDomainUpstream(relayData.Endpoint, o.tunnelConfig.PublicDNS)
|
||||
if err != nil {
|
||||
logger.Warn("Failed to resolve primary relay endpoint: %v", err)
|
||||
}
|
||||
|
||||
@@ -61,6 +61,7 @@ type TunnelConfig struct {
|
||||
MTU int
|
||||
DNS string
|
||||
UpstreamDNS []string
|
||||
PublicDNS []string
|
||||
InterfaceName string
|
||||
|
||||
// Advanced
|
||||
|
||||
Reference in New Issue
Block a user