1
0
mirror of https://github.com/cmur2/dyndnsd.git synced 2025-12-14 13:48:10 +01:00

Compare commits

...

39 Commits

Author SHA1 Message Date
cn
627b1c4dc5 release: 3.12.0 2025-12-04 01:05:11 +01:00
cn
da79ef902d dyndnsd: add tests for regular expressions 2025-12-04 01:03:16 +01:00
cn
8589cf801f project: update changelog 2025-12-04 00:28:32 +01:00
Jesús Daniel Colmenares Oviedo
c743c778bc dyndnsd: add support for regular expressions 2025-12-04 00:26:34 +01:00
renovate[bot]
415635f373 ci: update actions/checkout action to v6 2025-11-27 09:57:52 +01:00
dependabot[bot]
694a3e4c21 gems: update rubocop-rspec requirement from ~> 3.7.0 to ~> 3.8.0
Updates the requirements on [rubocop-rspec](https://github.com/rubocop/rubocop-rspec) to permit the latest version.
- [Release notes](https://github.com/rubocop/rubocop-rspec/releases)
- [Changelog](https://github.com/rubocop/rubocop-rspec/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rubocop/rubocop-rspec/compare/v3.7.0...v3.8.0)

---
updated-dependencies:
- dependency-name: rubocop-rspec
  dependency-version: 3.8.0
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-11-24 12:51:52 +01:00
renovate[bot]
74aec5f873 docker: update alpine Docker tag to v3.22.2 2025-10-09 16:37:24 +02:00
cn
34f2c01543 ci: run vulnscan less often 2025-10-02 20:37:01 +02:00
cn
62e2067e5b release: 3.11.0 2025-10-02 20:27:15 +02:00
renovate[bot]
62df373c77 project: update aquasecurity/trivy to v0.67.0 2025-10-02 20:23:25 +02:00
7a1302082b Merge branch 'master' into update-3.3 2025-10-02 20:20:44 +02:00
dependabot[bot]
ea3591564d gems: update rubocop requirement from ~> 1.80.0 to ~> 1.81.1
Updates the requirements on [rubocop](https://github.com/rubocop/rubocop) to permit the latest version.
- [Release notes](https://github.com/rubocop/rubocop/releases)
- [Changelog](https://github.com/rubocop/rubocop/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rubocop/rubocop/compare/v1.80.0...v1.81.1)

---
updated-dependencies:
- dependency-name: rubocop
  dependency-version: 1.81.1
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-09-29 19:08:22 +02:00
renovate[bot]
bc2262e2bb project: update hadolint/hadolint to v2.14.0 2025-09-25 11:06:33 +02:00
renovate[bot]
5871ef4c18 project: update hadolint/hadolint to v2.13.1 2025-09-04 10:02:45 +02:00
dependabot[bot]
62e1843365 gems: update rubocop-rspec requirement from ~> 3.6.0 to ~> 3.7.0
Updates the requirements on [rubocop-rspec](https://github.com/rubocop/rubocop-rspec) to permit the latest version.
- [Release notes](https://github.com/rubocop/rubocop-rspec/releases)
- [Changelog](https://github.com/rubocop/rubocop-rspec/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rubocop/rubocop-rspec/compare/v3.6.0...v3.7.0)

---
updated-dependencies:
- dependency-name: rubocop-rspec
  dependency-version: 3.7.0
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-09-01 23:22:22 +02:00
dependabot[bot]
7def8ea8a6 gems: update rubocop requirement from ~> 1.79.1 to ~> 1.80.0
Updates the requirements on [rubocop](https://github.com/rubocop/rubocop) to permit the latest version.
- [Release notes](https://github.com/rubocop/rubocop/releases)
- [Changelog](https://github.com/rubocop/rubocop/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rubocop/rubocop/compare/v1.79.1...v1.80.0)

---
updated-dependencies:
- dependency-name: rubocop
  dependency-version: 1.80.0
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-08-26 00:17:58 +02:00
renovate[bot]
9b553eb117 ci: update actions/checkout action to v5 2025-08-14 10:24:52 +02:00
dependabot[bot]
5e6f0e1e33 gems: update rubocop requirement from ~> 1.78.0 to ~> 1.79.1
Updates the requirements on [rubocop](https://github.com/rubocop/rubocop) to permit the latest version.
- [Release notes](https://github.com/rubocop/rubocop/releases)
- [Changelog](https://github.com/rubocop/rubocop/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rubocop/rubocop/compare/v1.78.0...v1.79.1)

---
updated-dependencies:
- dependency-name: rubocop
  dependency-version: 1.79.1
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-08-04 19:50:27 +02:00
renovate[bot]
01175ec8f9 docker: update alpine Docker tag to v3.22.1 2025-07-17 10:18:27 +02:00
dependabot[bot]
8d2c2f9c90 gems: update rubocop requirement from ~> 1.77.0 to ~> 1.78.0
Updates the requirements on [rubocop](https://github.com/rubocop/rubocop) to permit the latest version.
- [Release notes](https://github.com/rubocop/rubocop/releases)
- [Changelog](https://github.com/rubocop/rubocop/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rubocop/rubocop/compare/v1.77.0...v1.78.0)

---
updated-dependencies:
- dependency-name: rubocop
  dependency-version: 1.78.0
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-07-14 19:02:43 +02:00
dependabot[bot]
d3522e2c92 gems: update rubocop requirement from ~> 1.76.1 to ~> 1.77.0
Updates the requirements on [rubocop](https://github.com/rubocop/rubocop) to permit the latest version.
- [Release notes](https://github.com/rubocop/rubocop/releases)
- [Changelog](https://github.com/rubocop/rubocop/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rubocop/rubocop/compare/v1.76.1...v1.77.0)

---
updated-dependencies:
- dependency-name: rubocop
  dependency-version: 1.77.0
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-06-23 15:26:28 +02:00
dependabot[bot]
d92ee500c9 gems: update rubocop requirement from ~> 1.75.1 to ~> 1.76.1
Updates the requirements on [rubocop](https://github.com/rubocop/rubocop) to permit the latest version.
- [Release notes](https://github.com/rubocop/rubocop/releases)
- [Changelog](https://github.com/rubocop/rubocop/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rubocop/rubocop/compare/v1.75.1...v1.76.1)

---
updated-dependencies:
- dependency-name: rubocop
  dependency-version: 1.76.1
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-06-09 20:39:22 +02:00
cn
0ddb87cc57 gems: update solargraph 2025-06-05 23:56:42 +02:00
cn
685854aad3 project: update Renovate config migration 2025-06-05 23:03:03 +02:00
renovate[bot]
3825f57521 docker: update alpine Docker tag to v3.22.0 2025-06-05 23:02:12 +02:00
dependabot[bot]
bf8d1d5bbe gems: update rubocop-rspec requirement from ~> 3.5.0 to ~> 3.6.0
Updates the requirements on [rubocop-rspec](https://github.com/rubocop/rubocop-rspec) to permit the latest version.
- [Release notes](https://github.com/rubocop/rubocop-rspec/releases)
- [Changelog](https://github.com/rubocop/rubocop-rspec/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rubocop/rubocop-rspec/compare/v3.5.0...v3.6.0)

---
updated-dependencies:
- dependency-name: rubocop-rspec
  dependency-version: 3.6.0
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-04-21 17:11:56 +02:00
renovate[bot]
4becd05aa9 project: update aquasecurity/trivy to v0.61.0 2025-04-01 12:51:44 +02:00
dependabot[bot]
60fdaf9a94 gems: update logger requirement from ~> 1.6.0 to >= 1.6, < 1.8
Updates the requirements on [logger](https://github.com/ruby/logger) to permit the latest version.
- [Release notes](https://github.com/ruby/logger/releases)
- [Commits](https://github.com/ruby/logger/compare/v1.6.0...v1.7.0)

---
updated-dependencies:
- dependency-name: logger
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-03-31 23:17:59 +02:00
dependabot[bot]
8ad610ceb3 gems: update rubocop requirement from ~> 1.74.0 to ~> 1.75.1
Updates the requirements on [rubocop](https://github.com/rubocop/rubocop) to permit the latest version.
- [Release notes](https://github.com/rubocop/rubocop/releases)
- [Changelog](https://github.com/rubocop/rubocop/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rubocop/rubocop/compare/v1.74.0...v1.75.1)

---
updated-dependencies:
- dependency-name: rubocop
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-03-31 23:17:26 +02:00
cn
0de309112b ci: ignore vulns on old rubies 2025-03-31 23:14:42 +02:00
dependabot[bot]
066afeb866 gems: update rubocop requirement from ~> 1.73.1 to ~> 1.74.0
Updates the requirements on [rubocop](https://github.com/rubocop/rubocop) to permit the latest version.
- [Release notes](https://github.com/rubocop/rubocop/releases)
- [Changelog](https://github.com/rubocop/rubocop/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rubocop/rubocop/compare/v1.73.1...v1.74.0)

---
updated-dependencies:
- dependency-name: rubocop
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-03-17 12:39:37 +01:00
841c6f8b79 project: less frequent trivy updates 2025-03-11 17:08:09 +01:00
renovate[bot]
12c7e8996c project: update aquasecurity/trivy to v0.60.0 2025-03-11 17:06:22 +01:00
dependabot[bot]
1055197b08 gems: update rubocop-rspec requirement from ~> 3.4.0 to ~> 3.5.0
Updates the requirements on [rubocop-rspec](https://github.com/rubocop/rubocop-rspec) to permit the latest version.
- [Release notes](https://github.com/rubocop/rubocop-rspec/releases)
- [Changelog](https://github.com/rubocop/rubocop-rspec/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rubocop/rubocop-rspec/compare/v3.4.0...v3.5.0)

---
updated-dependencies:
- dependency-name: rubocop-rspec
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-03-03 19:52:02 +01:00
dependabot[bot]
08a705ed9a gems: update rubocop-rake requirement from ~> 0.6.0 to ~> 0.7.1
Updates the requirements on [rubocop-rake](https://github.com/rubocop/rubocop-rake) to permit the latest version.
- [Release notes](https://github.com/rubocop/rubocop-rake/releases)
- [Changelog](https://github.com/rubocop/rubocop-rake/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rubocop/rubocop-rake/compare/v0.6.0...v0.7.1)

---
updated-dependencies:
- dependency-name: rubocop-rake
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-03-03 19:49:37 +01:00
renovate[bot]
927fec98f2 docker: update alpine Docker tag to v3.21.3 2025-02-27 23:09:29 +01:00
dependabot[bot]
1e36454711 gems: update rubocop requirement from ~> 1.71.0 to ~> 1.73.1
Updates the requirements on [rubocop](https://github.com/rubocop/rubocop) to permit the latest version.
- [Release notes](https://github.com/rubocop/rubocop/releases)
- [Changelog](https://github.com/rubocop/rubocop/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rubocop/rubocop/compare/v1.71.0...v1.73.1)

---
updated-dependencies:
- dependency-name: rubocop
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-02-27 23:08:36 +01:00
cn
8f7a796e9d release: 3.10.0 2024-01-18 23:19:49 +01:00
cn
81dc2aba4c gem: support Ruby 3.3 2024-01-18 23:12:23 +01:00
15 changed files with 110 additions and 30 deletions

View File

@@ -20,6 +20,13 @@
matchManagers: ["bundler"], matchManagers: ["bundler"],
enabled: false, enabled: false,
}, },
// Only quarter update since noisy/stable tools
{
matchPackageNames: [
"aquasecurity/trivy",
],
schedule: ["* 0-8 1 */3 *"],
},
// Commit message formats // Commit message formats
{ {
matchDatasources: ["docker"], matchDatasources: ["docker"],
@@ -33,7 +40,7 @@
customManagers: [ customManagers: [
{ {
customType: "regex", customType: "regex",
fileMatch: ["\.rb$", "^Rakefile$"], managerFilePatterns: ["/.rb$/", "/^Rakefile$/"],
matchStrings: [ matchStrings: [
"renovate: datasource=(?<datasource>.*?) depName=(?<depName>.*?)\\s.*_version = '(?<currentValue>.*)'\\s" "renovate: datasource=(?<datasource>.*?) depName=(?<depName>.*?)\\s.*_version = '(?<currentValue>.*)'\\s"
] ]

View File

@@ -11,7 +11,7 @@ jobs:
release-dockerimage: release-dockerimage:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v6
- name: Extract dyndnsd version from tag name - name: Extract dyndnsd version from tag name
run: | run: |

View File

@@ -18,13 +18,12 @@ jobs:
fail-fast: false fail-fast: false
matrix: matrix:
ruby-version: ruby-version:
- '3.0'
- '3.1' - '3.1'
- '3.2' - '3.2'
- '3.3' - '3.3'
- '3.4' - '3.4'
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v6
- name: Set up Ruby ${{ matrix.ruby-version }} - name: Set up Ruby ${{ matrix.ruby-version }}
uses: ruby/setup-ruby@v1 uses: ruby/setup-ruby@v1
with: with:
@@ -38,7 +37,7 @@ jobs:
actionlint: actionlint:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v6
- name: Check workflow files - name: Check workflow files
run: | run: |
echo "::add-matcher::.github/actionlint-matcher.json" echo "::add-matcher::.github/actionlint-matcher.json"
@@ -51,6 +50,6 @@ jobs:
image: ghcr.io/renovatebot/renovate image: ghcr.io/renovatebot/renovate
options: --user root options: --user root
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v6
- name: Check Renovate config - name: Check Renovate config
run: renovate-config-validator --strict run: renovate-config-validator --strict

View File

@@ -1,10 +1,9 @@
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
--- ---
name: vulnscan name: vulnscan
on: on:
schedule: schedule:
- cron: '7 4 * * 4' # weekly on thursday morning - cron: '7 4 1 * *' # monthly on first day's morning
workflow_dispatch: workflow_dispatch:
jobs: jobs:

View File

@@ -1,4 +1,4 @@
require: plugins:
- rubocop-rake - rubocop-rake
- rubocop-rspec - rubocop-rspec

View File

@@ -1,12 +1,19 @@
# Changelog # Changelog
## 3.11.0 ## 3.12.0 (December 4th, 2025)
IMPROVEMENTS:
- regex instead of hosts list can be used for hostname ownership
## 3.11.0 (October 2nd, 2025)
IMPROVEMENTS: IMPROVEMENTS:
- add Ruby 3.4 support - add Ruby 3.4 support
- update base of Docker image to Alpine 3.22.1 (from 3.19.0 before)
## 3.10.0 ## 3.10.0 (January 18th, 2024)
IMPROVEMENTS: IMPROVEMENTS:

View File

@@ -307,6 +307,37 @@ users:
``` ```
### Matching with a regular expression
Instead of relying on `hosts`, you can use `regex` to employ a regular expression, which is very useful for avoiding having to repeatedly edit the configuration file to register a new host name.
```yaml
host: "0.0.0.0"
port: 5354
username: "dyndnsd"
group: "dyndnsd"
db: "/dyndnsd/db.json"
debug: false
domain: "dyn.dc-air.home.arpa"
updater:
name: "command_with_bind_zone"
params:
zone_file: "/nsd/zones/static/dyn.dc-air.home.arpa.zone"
command: "doas service nsd reload"
ttl: "5m"
dns: "ns.dc-air.home.arpa."
email_addr: "admin.example.org"
users:
myuser:
password: "superhypermegas3kurepassword1234"
regex: '^[a-z][0-9]\.dyn\.dc\-air\.home\.arpa$'
```
However, when using `regex`, `hosts` is simply ignored if defined, so you must choose one or the other. Recommendation: use `regex` for scripts or programs and `hosts` for regular users.
**Note**: Please note that when dyndnsd evaluates the regular expression, the `Regexp::EXTENDED` and `Regexp::IGNORECASE` options are used.
## License ## License
dyndnsd.rb is licensed under the Apache License, Version 2.0. See LICENSE for more information. dyndnsd.rb is licensed under the Apache License, Version 2.0. See LICENSE for more information.

View File

@@ -13,10 +13,10 @@ task :solargraph do
end end
# renovate: datasource=github-tags depName=hadolint/hadolint # renovate: datasource=github-tags depName=hadolint/hadolint
hadolint_version = 'v2.12.0' hadolint_version = 'v2.14.0'
# renovate: datasource=github-tags depName=aquasecurity/trivy # renovate: datasource=github-tags depName=aquasecurity/trivy
trivy_version = 'v0.59.1' trivy_version = 'v0.67.0'
namespace :docker do namespace :docker do
ci_image = 'cmur2/dyndnsd:ci' ci_image = 'cmur2/dyndnsd:ci'
@@ -69,7 +69,7 @@ end
namespace :bundle do namespace :bundle do
desc 'Check for vulnerabilities with bundler-audit' desc 'Check for vulnerabilities with bundler-audit'
task :audit do task :audit do
sh 'bundler-audit check --ignore GHSA-vvfq-8hwr-qm4m' sh 'bundler-audit check --ignore GHSA-vvfq-8hwr-qm4m' if !RUBY_VERSION.start_with?('3.0')
end end
end end

View File

@@ -1,11 +1,11 @@
FROM alpine:3.21.2 FROM alpine:3.22.2
EXPOSE 5353 8080 EXPOSE 5353 8080
ARG DYNDNSD_VERSION ARG DYNDNSD_VERSION
RUN apk --no-cache add openssl ca-certificates && \ RUN apk --no-cache add openssl ca-certificates && \
apk --no-cache add ruby ruby-etc ruby-io-console ruby-json ruby-webrick && \ apk --no-cache add ruby ruby-webrick && \
apk --no-cache add --virtual .build-deps linux-headers ruby-dev build-base tzdata && \ apk --no-cache add --virtual .build-deps linux-headers ruby-dev build-base tzdata && \
gem install --no-document dyndnsd -v ${DYNDNSD_VERSION} && \ gem install --no-document dyndnsd -v ${DYNDNSD_VERSION} && \
rm -rf /usr/lib/ruby/gems/*/cache/ && \ rm -rf /usr/lib/ruby/gems/*/cache/ && \

View File

@@ -1,11 +1,11 @@
FROM alpine:3.21.2 FROM alpine:3.22.2
EXPOSE 5353 8080 EXPOSE 5353 8080
COPY pkg/dyndnsd-*.gem /tmp/dyndnsd.gem COPY pkg/dyndnsd-*.gem /tmp/dyndnsd.gem
RUN apk --no-cache add openssl ca-certificates && \ RUN apk --no-cache add openssl ca-certificates && \
apk --no-cache add ruby ruby-etc ruby-io-console ruby-json ruby-webrick && \ apk --no-cache add ruby ruby-webrick && \
apk --no-cache add --virtual .build-deps linux-headers ruby-dev build-base tzdata && \ apk --no-cache add --virtual .build-deps linux-headers ruby-dev build-base tzdata && \
gem install --no-document /tmp/dyndnsd.gem && \ gem install --no-document /tmp/dyndnsd.gem && \
rm -rf /usr/lib/ruby/gems/*/cache/ && \ rm -rf /usr/lib/ruby/gems/*/cache/ && \

View File

@@ -30,7 +30,7 @@ Gem::Specification.new do |s|
s.add_dependency 'async', '~> 1.31.0' s.add_dependency 'async', '~> 1.31.0'
s.add_dependency 'async-dns', '~> 1.3.0' s.add_dependency 'async-dns', '~> 1.3.0'
s.add_dependency 'base64', '~> 0.2.0' # needed for async s.add_dependency 'base64', '~> 0.2.0' # needed for async
s.add_dependency 'logger', '~> 1.6.0' s.add_dependency 'logger', '>= 1.6', '< 1.8'
s.add_dependency 'metriks' s.add_dependency 'metriks'
s.add_dependency 'opentelemetry-exporter-jaeger', '~> 0.22.0' s.add_dependency 'opentelemetry-exporter-jaeger', '~> 0.22.0'
s.add_dependency 'opentelemetry-instrumentation-rack', '~> 0.22.0' s.add_dependency 'opentelemetry-instrumentation-rack', '~> 0.22.0'
@@ -44,8 +44,8 @@ Gem::Specification.new do |s|
s.add_development_dependency 'rack-test' s.add_development_dependency 'rack-test'
s.add_development_dependency 'rake' s.add_development_dependency 'rake'
s.add_development_dependency 'rspec' s.add_development_dependency 'rspec'
s.add_development_dependency 'rubocop', '~> 1.71.0' s.add_development_dependency 'rubocop', '~> 1.81.1'
s.add_development_dependency 'rubocop-rake', '~> 0.6.0' s.add_development_dependency 'rubocop-rake', '~> 0.7.1'
s.add_development_dependency 'rubocop-rspec', '~> 3.4.0' s.add_development_dependency 'rubocop-rspec', '~> 3.8.0'
s.add_development_dependency 'solargraph', '~> 0.49.0' s.add_development_dependency 'solargraph', '~> 0.55.0'
end end

View File

@@ -138,7 +138,7 @@ module Dyndnsd
# @param params [Hash{String => String}] # @param params [Hash{String => String}]
# @return [Array<String>] # @return [Array<String>]
def extract_v4_and_v6_address(params) def extract_v4_and_v6_address(params)
return [] if !(params['myip']) return [] if !params['myip']
begin begin
IPAddr.new(params['myip'], Socket::AF_INET) IPAddr.new(params['myip'], Socket::AF_INET)
IPAddr.new(params['myip6'], Socket::AF_INET6) IPAddr.new(params['myip6'], Socket::AF_INET6)
@@ -207,7 +207,7 @@ module Dyndnsd
params = Rack::Utils.parse_query(env['QUERY_STRING']) params = Rack::Utils.parse_query(env['QUERY_STRING'])
# require hostname parameter # require hostname parameter
return [422, {'X-DynDNS-Response' => 'hostname_missing'}, []] if !(params['hostname']) return [422, {'X-DynDNS-Response' => 'hostname_missing'}, []] if !params['hostname']
hostnames = params['hostname'].split(',') hostnames = params['hostname'].split(',')
@@ -218,9 +218,22 @@ module Dyndnsd
# we can trust this information since user was authorized by middleware # we can trust this information since user was authorized by middleware
user = env['REMOTE_USER'] user = env['REMOTE_USER']
# check for hostnames that the user does not own if @users[user].key?('regex')
forbidden_hostnames = hostnames - @users[user].fetch('hosts', []) pattern = @users[user].fetch('regex')
return [422, {'X-DynDNS-Response' => 'host_forbidden'}, []] if forbidden_hostnames.any? begin
regex = Regexp.new(pattern, Regexp::IGNORECASE | Regexp::EXTENDED)
rescue RegexpError => e
Dyndnsd.logger.warn "Invalid regex pattern '#{pattern}': #{e.message}"
return [422, {'X-DynDNS-Response' => 'host_forbidden'}, []]
end
# check for hostnames that match the regex
matches = hostnames.any? { |str| regex.match?(str) }
return [422, {'X-DynDNS-Response' => 'host_forbidden'}, []] if !matches
else
# check for hostnames that the user does not own
forbidden_hostnames = hostnames - @users[user].fetch('hosts', [])
return [422, {'X-DynDNS-Response' => 'host_forbidden'}, []] if forbidden_hostnames.any?
end
if params['offline'] == 'YES' if params['offline'] == 'YES'
myips = [] myips = []

View File

@@ -89,7 +89,7 @@ module Dyndnsd
# @return [Array{Array{Object}}] # @return [Array{Array{Object}}]
def self.parse_endpoints(endpoint_list) def self.parse_endpoints(endpoint_list)
endpoint_list.map { |addr_string| addr_string.split('@') } endpoint_list.map { |addr_string| addr_string.split('@') }
.map { |addr_parts| [addr_parts[0], addr_parts[1].to_i || 53] } .map { |addr_parts| [addr_parts[0], addr_parts[1]&.to_i || 53] }
.map { |addr| [:tcp, :udp].map { |type| [type] + addr } } .map { |addr| [:tcp, :udp].map { |type| [type] + addr } }
.flatten(1) .flatten(1)
end end

View File

@@ -1,5 +1,5 @@
# frozen_string_literal: true # frozen_string_literal: true
module Dyndnsd module Dyndnsd
VERSION = '3.9.2' VERSION = '3.12.0'
end end

View File

@@ -18,6 +18,10 @@ describe Dyndnsd::Daemon do
}, },
'test2' => { 'test2' => {
'password' => 'ihavenohosts' 'password' => 'ihavenohosts'
},
'test3' => {
'password' => 'superhypermegas3kurepassword1234',
'regex' => '^[a-z0-9]+-test3\.example\.org$'
} }
} }
} }
@@ -74,6 +78,22 @@ describe Dyndnsd::Daemon do
expect(last_response.body).to eq("good 2001:db8::1\ngood 2001:db8::1") expect(last_response.body).to eq("good 2001:db8::1\ngood 2001:db8::1")
end end
it 'supports regex matches for hostnames' do
authorize 'test3', 'superhypermegas3kurepassword1234'
get '/nic/update?hostname=abc123-test3.example.org&myip=1.2.3.4'
expect(last_response).to be_ok
expect(last_response.body).to eq('good 1.2.3.4')
get '/nic/update?hostname=foo-test3.example.org,bar-test3.example.org&myip=2001:db8::1'
expect(last_response).to be_ok
expect(last_response.body).to eq("good 2001:db8::1\ngood 2001:db8::1")
get '/nic/update?hostname=abc123.example.org'
expect(last_response).to be_ok
expect(last_response.body).to eq('nohost')
end
it 'rejects request if one hostname is invalid' do it 'rejects request if one hostname is invalid' do
authorize 'test', 'secret' authorize 'test', 'secret'
@@ -120,6 +140,10 @@ describe Dyndnsd::Daemon do
get '/nic/update?hostname=foo.example.org,notmyhost.example.org' get '/nic/update?hostname=foo.example.org,notmyhost.example.org'
expect(last_response).to be_ok expect(last_response).to be_ok
expect(last_response.body).to eq('nohost') expect(last_response.body).to eq('nohost')
get '/nic/update?hostname=abc123-test3.example.org'
expect(last_response).to be_ok
expect(last_response.body).to eq('nohost')
end end
it 'updates a host on IP change' do it 'updates a host on IP change' do