4 Commits

Author SHA1 Message Date
5a1ec0ecdc feat: codeql
Some checks failed
CI / test (pull_request) Waiting to run
CodeQL Analysis / codeql-analysis (pull_request) Failing after 8m54s
2025-01-01 12:49:23 +01:00
ad0932f4aa docs: log level (#23)
All checks were successful
CD / test (push) Successful in 29s
CD / Build and push (push) Successful in 4m16s
Reviewed-on: #23
Co-authored-by: Timo Behrendt <t.behrendt@t00n.de>
Co-committed-by: Timo Behrendt <t.behrendt@t00n.de>
2025-01-01 12:25:14 +01:00
fff36bf807 feat: concurrently check and update all domains (#24)
All checks were successful
CD / test (push) Successful in 2m32s
CD / Build and push (push) Successful in 2m53s
Reviewed-on: #24
Co-authored-by: Timo Behrendt <t.behrendt@t00n.de>
Co-committed-by: Timo Behrendt <t.behrendt@t00n.de>
2024-12-30 17:37:49 +01:00
1c725993f5 fix: increase resilliency (#22)
All checks were successful
CD / test (push) Successful in 47s
CD / Build and push (push) Successful in 3m2s
Reviewed-on: #22
Co-authored-by: Timo Behrendt <t.behrendt@t00n.de>
Co-committed-by: Timo Behrendt <t.behrendt@t00n.de>
2024-12-27 20:44:19 +01:00
4 changed files with 87 additions and 42 deletions

View File

@@ -0,0 +1,23 @@
name: CodeQL Analysis
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
codeql-analysis:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: "go"
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3

View File

@@ -38,6 +38,7 @@ domains:
- www
check_interval: 0 0 0/6 * * * *
mode: Scheduled
log_level: info
```
The config file is expected to be in the same directory as the binary and called `config.yaml`. For the OCR image, the root directory is `/app`.

View File

@@ -21,3 +21,4 @@ domains:
- www
check_interval: 0 0 0/6 * * * *
mode: Scheduled
log_level: info

View File

@@ -3,6 +3,7 @@ package realDynDns
import (
"fmt"
"log/slog"
"sync"
"time"
"realdnydns/pkg/config"
@@ -70,10 +71,17 @@ func (c *ChangeDetector) detectAndApplyChanges() (int, error) {
return 0, err
}
var numberUpdated int
var wg sync.WaitGroup
numberUpdatedChannel := make(chan int)
for _, domain := range c.domains {
for _, subdomain := range domain.Subdomains {
wg.Add(1)
go func(domain config.DomainConfig, subdomain string) {
defer wg.Done()
c.logger.Info("Checking record",
slog.String("tld", domain.TLD),
slog.String("subdomain", subdomain),
@@ -85,7 +93,7 @@ func (c *ChangeDetector) detectAndApplyChanges() (int, error) {
slog.String("tld", domain.TLD),
slog.String("subdomain", subdomain),
)
return numberUpdated, err
return
}
if currentRecord.IP != externalIp.String() {
@@ -104,7 +112,7 @@ func (c *ChangeDetector) detectAndApplyChanges() (int, error) {
c.logger.Warn("Failed to send notification",
slog.String("error", err.Error()),
)
return numberUpdated, err
return
}
c.logger.Info("Updating record",
@@ -120,11 +128,23 @@ func (c *ChangeDetector) detectAndApplyChanges() (int, error) {
slog.String("tld", domain.TLD),
slog.String("subdomain", subdomain),
)
return numberUpdated, err
return
}
numberUpdated++
numberUpdatedChannel <- 1
}
}(domain, subdomain)
}
}
go func() {
wg.Wait()
close(numberUpdatedChannel)
}()
numberUpdated := 0
for v := range numberUpdatedChannel {
numberUpdated += v
}
c.logger.Info("Run completed", slog.Int("number_of_changes", numberUpdated))