-
Notifications
You must be signed in to change notification settings - Fork 390
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
87 changed files
with
1,411 additions
and
555 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
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
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,68 @@ | ||
package main | ||
|
||
import ( | ||
"github.com/StackExchange/dnscontrol/v4/providers" | ||
"os" | ||
"sort" | ||
"strings" | ||
) | ||
|
||
func generateOwnersFile() error { | ||
maintainers := providers.ProviderMaintainers | ||
sortedProviderNames := getSortedProviderNames(maintainers) | ||
|
||
var ownersData strings.Builder | ||
for _, providerName := range sortedProviderNames { | ||
providerMaintainer := maintainers[providerName] | ||
if providerMaintainer == "NEEDS VOLUNTEER" { | ||
ownersData.WriteString("# ") | ||
} | ||
ownersData.WriteString("providers/") | ||
ownersData.WriteString(getProviderDirectory(providerName)) | ||
ownersData.WriteString(" ") | ||
ownersData.WriteString(providerMaintainer) | ||
ownersData.WriteString("\n") | ||
} | ||
|
||
file, err := os.Create("OWNERS") | ||
if err != nil { | ||
return err | ||
} | ||
defer file.Close() | ||
|
||
_, err = file.WriteString(ownersData.String()) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
return nil | ||
} | ||
|
||
func getProviderDirectory(providerName string) string { | ||
// Strip the underscores from the providerName constants | ||
providerDirectory := strings.ToLower( | ||
strings.ReplaceAll( | ||
providerName, "_", "", | ||
), | ||
) | ||
|
||
// These providers use a different directory name | ||
if providerDirectory == "cloudflareapi" { | ||
providerDirectory = "cloudflare" | ||
} | ||
if providerDirectory == "dnsoverhttps" { | ||
providerDirectory = "doh" | ||
} | ||
|
||
return providerDirectory | ||
} | ||
|
||
func getSortedProviderNames(maintainers map[string]string) []string { | ||
providerNameSorted := make([]string, 0, len(maintainers)) | ||
for providerNameKey := range maintainers { | ||
providerNameSorted = append(providerNameSorted, providerNameKey) | ||
} | ||
sort.Strings(providerNameSorted) | ||
|
||
return providerNameSorted | ||
} |
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
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
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
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
45 changes: 45 additions & 0 deletions
45
documentation/language-reference/domain-modifiers/CF_SINGLE_REDIRECT.md
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 @@ | ||
--- | ||
name: CF_SINGLE_REDIRECT | ||
parameters: | ||
- name | ||
- code | ||
- when | ||
- then | ||
- modifiers... | ||
provider: CLOUDFLAREAPI | ||
parameter_types: | ||
name: string | ||
code: number | ||
when: string | ||
then: string | ||
"modifiers...": RecordModifier[] | ||
--- | ||
|
||
`CF_SINGLE_REDIRECT` is a Cloudflare-specific feature for creating HTTP 301 | ||
(permanent) or 302 (temporary) redirects. | ||
|
||
This feature manages dynamic "Single Redirects". (Single Redirects can be | ||
static or dynamic but DNSControl only maintains dynamic redirects). | ||
|
||
Cloudflare documentation: <https://developers.cloudflare.com/rules/url-forwarding/single-redirects/> | ||
|
||
{% code title="dnsconfig.js" %} | ||
```javascript | ||
D("example.com", REG_MY_PROVIDER, DnsProvider(DSP_MY_PROVIDER), | ||
CF_SINGLE_REDIRECT("name", 301, "when", "then"), | ||
CF_SINGLE_REDIRECT('redirect www.example.com', 301, 'http.host eq "www.example.com"', 'concat("https://otherplace.com", http.request.uri.path)'), | ||
CF_SINGLE_REDIRECT('redirect yyy.example.com', 301, 'http.host eq "yyy.example.com"', 'concat("https://survey.stackoverflow.co", "")'), | ||
END); | ||
``` | ||
{% endcode %} | ||
|
||
The fields are: | ||
|
||
* name: The name (basically a comment, but it must be unique) | ||
* code: Either 301 (permanent) or 302 (temporary) redirects. May be a number or string. | ||
* when: What Cloudflare sometimes calls the "rule expression". | ||
* then: The replacement expression. | ||
|
||
{% hint style="info" %} | ||
**NOTE**: The features [`CF_REDIRECT`](CF_REDIRECT.md) and [`CF_TEMP_REDIRECT`](CF_TEMP_REDIRECT.md) generate `CF_SINGLE_REDIRECT` if enabled in [`CLOUDFLAREAPI`](../../provider/cloudflareapi.md). | ||
{% endhint %} |
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
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
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.