-
Notifications
You must be signed in to change notification settings - Fork 262
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(autoconfig): Refactor DNS query for testing
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
- Loading branch information
1 parent
4a562f0
commit b7e398d
Showing
10 changed files
with
16,587 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors | ||
# SPDX-License-Identifier: MIT | ||
name: Update public suffix list | ||
|
||
on: | ||
workflow_dispatch: | ||
schedule: | ||
- cron: "5 2 * * *" | ||
|
||
jobs: | ||
update-public-suffix-list: | ||
runs-on: ubuntu-latest | ||
|
||
strategy: | ||
fail-fast: false | ||
matrix: | ||
branches: ['main', 'stable3.7'] | ||
|
||
name: update-public-suffix-list-${{ matrix.branches }} | ||
|
||
steps: | ||
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 | ||
with: | ||
ref: ${{ matrix.branches }} | ||
submodules: true | ||
|
||
- name: Download public suffix list | ||
run: curl --output resources/resources/public_suffix_list.dat https://publicsuffix.org/list/public_suffix_list.dat | ||
|
||
- name: Create Pull Request | ||
uses: peter-evans/create-pull-request@c5a7806660adbe173f04e3e038b0ccdcd758773c | ||
with: | ||
token: ${{ secrets.COMMAND_BOT_PAT }} | ||
commit-message: 'fix(dns): Update public suffix list' | ||
committer: GitHub <noreply@github.com> | ||
author: nextcloud-command <nextcloud-command@users.noreply.github.com> | ||
signoff: true | ||
branch: 'fix/dns/update-public-suffix-list-${{ matrix.branches }}' | ||
title: '[${{ matrix.branches }}] fix(dns): Update public suffix list' | ||
body: | | ||
Auto-generated update of https://publicsuffix.org/ | ||
labels: | | ||
dependencies | ||
3. to review | ||
reviewers: ChristophWurst |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors | ||
* SPDX-License-Identifier: AGPL-3.0-or-later | ||
*/ | ||
|
||
namespace OCA\Mail\Dns; | ||
|
||
use Pdp\Domain; | ||
use Pdp\Rules; | ||
use function dns_get_record; | ||
|
||
class Resolver { | ||
/** | ||
* @return array|false | ||
*/ | ||
public function resolve(string $hostname, int $type) { | ||
return dns_get_record($hostname, $type); | ||
} | ||
|
||
public function isSuffix(string $hostname): bool { | ||
$publicSuffixList = Rules::fromPath(__DIR__ . '/../../resources/public_suffix_list.dat'); | ||
$domain = Domain::fromIDNA2008($hostname); | ||
|
||
$result = $publicSuffixList->resolve($domain); | ||
|
||
return $result->secondLevelDomain()->toString() === ''; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.