Compare commits
5 Commits
Author | SHA1 | Date |
---|---|---|
Ambrose Chua | bf1b867dd4 | |
Ambrose Chua | 4439e925cd | |
Ambrose Chua | 47ebb3f376 | |
Ambrose Chua | f0707f5bfd | |
Ambrose Chua | 1313508713 |
38
.drone.yml
38
.drone.yml
|
@ -1,38 +0,0 @@
|
|||
kind: pipeline
|
||||
type: docker
|
||||
name: default
|
||||
|
||||
steps:
|
||||
- name: test
|
||||
image: golang:1.14-alpine
|
||||
pull: true
|
||||
environment:
|
||||
CGO_ENABLED: 0
|
||||
GOOS: linux
|
||||
GOARCH: amd64
|
||||
commands:
|
||||
- cd coredns && go test
|
||||
- name: build
|
||||
image: golang:1.14-alpine
|
||||
pull: true
|
||||
environment:
|
||||
CGO_ENABLED: 0
|
||||
GOOS: linux
|
||||
GOARCH: amd64
|
||||
commands:
|
||||
- cd coredns && go build
|
||||
when:
|
||||
event:
|
||||
- tag
|
||||
- name: release
|
||||
image: plugins/gitea-release
|
||||
settings:
|
||||
base_url: https://git.makerforce.io
|
||||
api_key:
|
||||
from_secret: gitea_token
|
||||
files: coredns/coredns
|
||||
when:
|
||||
event:
|
||||
- tag
|
||||
|
||||
# vim: ts=2:sw=2
|
|
@ -1,2 +1,2 @@
|
|||
coredns/build/
|
||||
coredns/coredns
|
||||
coredns/gitea_token
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
|
||||
# alias [![Build Status](https://ci.makerforce.io/api/badges/ambrose/alias/status.svg)](https://ci.makerforce.io/ambrose/alias)
|
||||
# alias
|
||||
|
||||
The *alias* plugin eliminates CNAME records from zone apex by making the subsequent resolved records look like they belong to the zone apex. This behaves similarily to [CloudFlare's Zone Flattening](https://support.cloudflare.com/hc/en-us/articles/200169056-CNAME-Flattening-RFC-compliant-support-for-CNAME-at-the-root).
|
||||
|
||||
|
@ -7,7 +7,7 @@ This plugin works only with plugins that produce A or AAAA records alongside the
|
|||
|
||||
> Preferrably, this should not be used in favour of the RFC drafts for the new [ANAME](https://tools.ietf.org/html/draft-ietf-dnsop-aname-00) records, but the DNS library used by CoreDNS does not support ANAME records yet.
|
||||
|
||||
Release builds can be found [here](https://git.makerforce.io/ambrose/alias/releases)
|
||||
Release builds can be found [here](https://github.com/serverwentdown/alias/releases)
|
||||
|
||||
## Syntax
|
||||
|
||||
|
|
6
alias.go
6
alias.go
|
@ -1,12 +1,12 @@
|
|||
package alias
|
||||
|
||||
import (
|
||||
"context"
|
||||
"math"
|
||||
|
||||
"github.com/coredns/coredns/plugin"
|
||||
|
||||
"github.com/miekg/dns"
|
||||
"math"
|
||||
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
// Rewrite is plugin to rewrite requests internally before being handled.
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
GO:=go
|
||||
NAME:=coredns
|
||||
|
||||
.PHONY: build
|
||||
build:
|
||||
$(RM) -rf build && mkdir build
|
||||
GOOS=darwin GOARCH=amd64 $(GO) build -o build/coredns_darwin_amd64
|
||||
GOOS=windows GOARCH=amd64 $(GO) build -o build/coredns_windows_amd64.exe
|
||||
GOOS=linux GOARCH=amd64 $(GO) build -o build/coredns_linux_amd64
|
||||
GOOS=linux GOARCH=arm64 $(GO) build -o build/coredns_linux_arm64
|
|
@ -5,7 +5,7 @@ go 1.13
|
|||
replace github.com/serverwentdown/alias => ../
|
||||
|
||||
require (
|
||||
github.com/coredns/coredns v1.6.9
|
||||
github.com/miekg/dns v1.1.29
|
||||
github.com/coredns/coredns v1.11.1
|
||||
github.com/miekg/dns v1.1.55
|
||||
github.com/serverwentdown/alias v0.0.0-00010101000000-000000000000
|
||||
)
|
||||
|
|
3433
coredns/go.sum
3433
coredns/go.sum
File diff suppressed because it is too large
Load Diff
|
@ -1,85 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
source gitea_token
|
||||
|
||||
set -e
|
||||
|
||||
GITEA_SERVER=${GITEA_SERVER:="https://git.makerforce.io"}
|
||||
GITEA_TOKEN=${GITEA_TOKEN:=""}
|
||||
|
||||
path_to_httpie=$(which http)
|
||||
if [ ! -x "$path_to_httpie" ] ; then
|
||||
echo "HTTPie not installed. Please install it at (https://httpie.org/doc#installation)"
|
||||
fi
|
||||
|
||||
path_to_jq=$(which jq)
|
||||
if [ ! -x "$path_to_jq" ] ; then
|
||||
echo "JQ not installed. Please install it at (https://stedolan.github.io/jq/download/)"
|
||||
fi
|
||||
|
||||
if [ -z $GITEA_TOKEN ]; then
|
||||
echo "Enter Gitea token ($GITEA_SERVER/account/token)"
|
||||
echo -n "> "
|
||||
read GITEA_TOKEN
|
||||
echo
|
||||
fi
|
||||
|
||||
GIT_COMMIT="$(git rev-parse HEAD)"
|
||||
GIT_LAST_TAG="$(git tag -l | tail -n 1)"
|
||||
# Increment version
|
||||
ver=( ${GIT_LAST_TAG//./ } )
|
||||
((ver[2]++))
|
||||
GIT_TAG="${ver[0]}.${ver[1]}.${ver[2]}"
|
||||
|
||||
echo "Tagging $GIT_TAG..."
|
||||
|
||||
git tag "$GIT_TAG" "$GIT_COMMIT"
|
||||
git push
|
||||
git push --tags
|
||||
|
||||
echo "Building coredns..."
|
||||
|
||||
matrix=(
|
||||
"GOOS=linux GOARCH=amd64"
|
||||
"GOOS=linux GOARCH=arm64"
|
||||
"GOOS=linux GOARCH=arm"
|
||||
"GOOS=darwin GOARCH=amd64"
|
||||
"GOOS=windows GOARCH=amd64 EXT=.exe"
|
||||
)
|
||||
|
||||
export CGO_ENABLED=0
|
||||
for m in "${matrix[@]}"; do
|
||||
export GOOS= GOARCH= EXT=
|
||||
export $m
|
||||
go build -o coredns_${GOOS}_${GOARCH}${EXT}
|
||||
done
|
||||
|
||||
echo "Uploading release..."
|
||||
|
||||
RELEASE="$GIT_TAG"
|
||||
BODY="$(cat go.mod | grep coredns/coredns | tr -d '\t')"
|
||||
|
||||
RESPONSE="$(http --check-status -b POST \
|
||||
"$GITEA_SERVER/api/v1/repos/ambrose/alias/releases" \
|
||||
Authorization:"Bearer $GITEA_TOKEN" \
|
||||
body="$BODY" \
|
||||
draft:=false \
|
||||
name="$RELEASE" \
|
||||
prerelease:=false \
|
||||
tag_name="$GIT_TAG" \
|
||||
target_commitish="$GIT_COMMIT")"
|
||||
|
||||
echo "Uploading attachments..."
|
||||
|
||||
RELEASE_ID="$(echo "$RESPONSE" | jq .id)"
|
||||
|
||||
for m in "${matrix[@]}"; do
|
||||
export GOOS= GOARCH= EXT=
|
||||
export $m
|
||||
filename=coredns_${GOOS}_${GOARCH}${EXT}
|
||||
http --check-status --form -b POST \
|
||||
"$GITEA_SERVER/api/v1/repos/ambrose/alias/releases/$RELEASE_ID/assets" \
|
||||
Authorization:"Bearer $GITEA_TOKEN" \
|
||||
name="$filename" \
|
||||
attachment@"$filename"
|
||||
done
|
11
go.mod
11
go.mod
|
@ -1,10 +1,9 @@
|
|||
module github.com/serverwentdown/alias
|
||||
|
||||
go 1.13
|
||||
go 1.15
|
||||
|
||||
require (
|
||||
github.com/caddyserver/caddy v1.0.5
|
||||
github.com/coredns/coredns v1.6.9
|
||||
github.com/miekg/dns v1.1.29
|
||||
golang.org/x/net v0.0.0-20200301022130-244492dfa37a
|
||||
)
|
||||
github.com/coredns/caddy v1.1.1
|
||||
github.com/coredns/coredns v1.11.1
|
||||
github.com/miekg/dns v1.1.55
|
||||
)
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
package alias
|
||||
|
||||
func (al Alias) Ready() bool { return true }
|
10
setup.go
10
setup.go
|
@ -1,18 +1,12 @@
|
|||
package alias
|
||||
|
||||
import (
|
||||
"github.com/coredns/caddy"
|
||||
"github.com/coredns/coredns/core/dnsserver"
|
||||
"github.com/coredns/coredns/plugin"
|
||||
|
||||
"github.com/caddyserver/caddy"
|
||||
)
|
||||
|
||||
func init() {
|
||||
caddy.RegisterPlugin("alias", caddy.Plugin{
|
||||
ServerType: "dns",
|
||||
Action: setup,
|
||||
})
|
||||
}
|
||||
func init() { plugin.Register("alias", setup) }
|
||||
|
||||
func setup(c *caddy.Controller) error {
|
||||
c.Next()
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
package alias
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/coredns/caddy"
|
||||
)
|
||||
|
||||
func TestSetup(t *testing.T) {
|
||||
c := caddy.NewTestController("dns", `alias`)
|
||||
if err := setup(c); err != nil {
|
||||
t.Fatalf("Expected no errors, but got: %v", err)
|
||||
}
|
||||
|
||||
c = caddy.NewTestController("dns", `alias more`)
|
||||
if err := setup(c); err == nil {
|
||||
t.Fatalf("Expected errors, but got: %v", err)
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue