mirror of
https://github.com/DeBrosOfficial/network.git
synced 2026-01-30 06:53:03 +00:00
fixed cert issue
This commit is contained in:
parent
5ec292a4f2
commit
c3d6500785
@ -379,7 +379,7 @@ func (ci *CaddyInstaller) generateCaddyfile(domain, email, acmeEndpoint string)
|
|||||||
reverse_proxy localhost:6001
|
reverse_proxy localhost:6001
|
||||||
}
|
}
|
||||||
|
|
||||||
:443 {
|
%s {
|
||||||
tls {
|
tls {
|
||||||
dns orama {
|
dns orama {
|
||||||
endpoint %s
|
endpoint %s
|
||||||
@ -391,5 +391,5 @@ func (ci *CaddyInstaller) generateCaddyfile(domain, email, acmeEndpoint string)
|
|||||||
:80 {
|
:80 {
|
||||||
reverse_proxy localhost:6001
|
reverse_proxy localhost:6001
|
||||||
}
|
}
|
||||||
`, email, domain, acmeEndpoint, acmeEndpoint)
|
`, email, domain, acmeEndpoint, domain, acmeEndpoint)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -51,13 +51,11 @@ func (g *Gateway) acmePresentHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
db := g.client.Database()
|
db := g.client.Database()
|
||||||
ctx := client.WithInternalAuth(r.Context())
|
ctx := client.WithInternalAuth(r.Context())
|
||||||
|
|
||||||
// First, delete any existing ACME challenge for this FQDN (in case of retry)
|
// Insert new TXT record (multiple nodes may have concurrent challenges for the same FQDN)
|
||||||
deleteQuery := `DELETE FROM dns_records WHERE fqdn = ? AND record_type = 'TXT' AND namespace = 'acme'`
|
// ON CONFLICT DO NOTHING: the UNIQUE(fqdn, record_type, value) constraint prevents duplicates
|
||||||
_, _ = db.Query(ctx, deleteQuery, fqdn)
|
|
||||||
|
|
||||||
// Insert new TXT record
|
|
||||||
insertQuery := `INSERT INTO dns_records (fqdn, record_type, value, ttl, namespace, is_active, created_at, updated_at, created_by)
|
insertQuery := `INSERT INTO dns_records (fqdn, record_type, value, ttl, namespace, is_active, created_at, updated_at, created_by)
|
||||||
VALUES (?, 'TXT', ?, 60, 'acme', TRUE, datetime('now'), datetime('now'), 'system')`
|
VALUES (?, 'TXT', ?, 60, 'acme', TRUE, datetime('now'), datetime('now'), 'system')
|
||||||
|
ON CONFLICT(fqdn, record_type, value) DO NOTHING`
|
||||||
|
|
||||||
_, err := db.Query(ctx, insertQuery, fqdn, req.Value)
|
_, err := db.Query(ctx, insertQuery, fqdn, req.Value)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -109,8 +107,9 @@ func (g *Gateway) acmeCleanupHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
db := g.client.Database()
|
db := g.client.Database()
|
||||||
ctx := client.WithInternalAuth(r.Context())
|
ctx := client.WithInternalAuth(r.Context())
|
||||||
|
|
||||||
deleteQuery := `DELETE FROM dns_records WHERE fqdn = ? AND record_type = 'TXT' AND namespace = 'acme'`
|
// Only delete this node's specific challenge value, not all ACME TXT records for this FQDN
|
||||||
_, err := db.Query(ctx, deleteQuery, fqdn)
|
deleteQuery := `DELETE FROM dns_records WHERE fqdn = ? AND record_type = 'TXT' AND namespace = 'acme' AND value = ?`
|
||||||
|
_, err := db.Query(ctx, deleteQuery, fqdn, req.Value)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
g.logger.Error("Failed to delete ACME TXT record", zap.Error(err))
|
g.logger.Error("Failed to delete ACME TXT record", zap.Error(err))
|
||||||
http.Error(w, "Failed to delete DNS record", http.StatusInternalServerError)
|
http.Error(w, "Failed to delete DNS record", http.StatusInternalServerError)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user