Skip to content

Commit dcad261

Browse files
committed
fix(http): fixed http networking issue (HTTP Proxy not enabled)
1 parent 02179f6 commit dcad261

File tree

3 files changed

+47
-4
lines changed

3 files changed

+47
-4
lines changed

config/manager.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,13 @@ func (cm *ConfigManager) updateConfig(resp PollResponse) {
145145

146146
// Separate regular DNS records from GeoDNS records
147147
regularRecords := []DNSRecord{}
148+
hasHTTPProxyEnabled := false
148149

149150
for _, record := range domain.DNSRecords {
151+
// Check if any DNS record has HTTPProxyEnabled
152+
if record.HTTPProxyEnabled {
153+
hasHTTPProxyEnabled = true
154+
}
150155
if record.Type == "A" {
151156
recordName := record.Name
152157

@@ -170,6 +175,18 @@ func (cm *ConfigManager) updateConfig(resp PollResponse) {
170175
}
171176
}
172177

178+
// Auto-enable HTTP proxy if type is set (Core doesn't send 'enabled' field)
179+
if domain.HTTPProxy.Type != "" && !domain.HTTPProxy.Enabled {
180+
log.Printf("[Config] Auto-enabling HTTP proxy for %s (type=%s)", domain.Domain, domain.HTTPProxy.Type)
181+
domain.HTTPProxy.Enabled = true
182+
}
183+
184+
// Also auto-enable if any DNS record has HTTPProxyEnabled
185+
if hasHTTPProxyEnabled && !domain.HTTPProxy.Enabled {
186+
log.Printf("[Config] Auto-enabling HTTP proxy for %s (found HTTPProxyEnabled DNS records)", domain.Domain)
187+
domain.HTTPProxy.Enabled = true
188+
}
189+
173190
// Update DNS records (without GeoDNS location records)
174191
domain.DNSRecords = regularRecords
175192
}

proxy/http.go

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,21 @@ func (s *HTTPProxyServer) handleRequest(w http.ResponseWriter, r *http.Request)
5959
return
6060
}
6161

62-
if !domainConfig.HTTPProxy.Enabled {
63-
log.Printf("[HTTP] HTTP proxy not enabled for domain: %s", host)
62+
// Check if HTTP proxy is enabled OR if any DNS record has HTTPProxyEnabled
63+
httpEnabled := domainConfig.HTTPProxy.Enabled
64+
if !httpEnabled {
65+
// Check if any DNS record allows HTTP proxy
66+
for _, record := range domainConfig.DNSRecords {
67+
if record.HTTPProxyEnabled {
68+
httpEnabled = true
69+
break
70+
}
71+
}
72+
}
73+
74+
if !httpEnabled {
75+
log.Printf("[HTTP] HTTP proxy not enabled for domain: %s (HTTPProxy.Enabled=%v)",
76+
host, domainConfig.HTTPProxy.Enabled)
6477
http.Error(w, "HTTP proxy not enabled", http.StatusForbidden)
6578
return
6679
}

proxy/https.go

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,21 @@ func (s *HTTPSProxyServer) handleRequest(w http.ResponseWriter, r *http.Request)
9191
return
9292
}
9393

94-
if !domainConfig.HTTPProxy.Enabled {
95-
log.Printf("[HTTPS] HTTP proxy not enabled for domain: %s", host)
94+
// Check if HTTP proxy is enabled OR if any DNS record has HTTPProxyEnabled
95+
httpEnabled := domainConfig.HTTPProxy.Enabled
96+
if !httpEnabled {
97+
// Check if any DNS record allows HTTP proxy
98+
for _, record := range domainConfig.DNSRecords {
99+
if record.HTTPProxyEnabled {
100+
httpEnabled = true
101+
break
102+
}
103+
}
104+
}
105+
106+
if !httpEnabled {
107+
log.Printf("[HTTPS] HTTP proxy not enabled for domain: %s (HTTPProxy.Enabled=%v)",
108+
host, domainConfig.HTTPProxy.Enabled)
96109
http.Error(w, "HTTP proxy not enabled", http.StatusForbidden)
97110
return
98111
}

0 commit comments

Comments
 (0)