-
Notifications
You must be signed in to change notification settings - Fork 270
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
1 parent
6b8bda2
commit f33d32c
Showing
55 changed files
with
2,291 additions
and
0 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,42 @@ | ||
name: "ddns-aliyun docker build" | ||
|
||
env: | ||
PROJECT: ddns-aliyun | ||
|
||
on: | ||
workflow_dispatch: | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
env: | ||
ACTIONS_ALLOW_UNSECURE_COMMANDS: true | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
- name: Set tag | ||
id: tag | ||
run: | | ||
TAG=$(cat ${{ env.PROJECT }}/Dockerfile | awk 'NR==4 {print $3}') | ||
echo "::set-env name=TAG::$TAG" | ||
- name: Docker Hub login | ||
env: | ||
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} | ||
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} | ||
run: | | ||
echo "${DOCKER_PASSWORD}" | docker login --username ${DOCKER_USERNAME} --password-stdin | ||
- name: Set up Docker Buildx | ||
id: buildx | ||
uses: crazy-max/ghaction-docker-buildx@v1 | ||
with: | ||
buildx-version: latest | ||
- name: Build Dockerfile | ||
env: | ||
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} | ||
run: | | ||
docker buildx build \ | ||
--platform=linux/amd64,linux/arm64 \ | ||
--output "type=image,push=true" \ | ||
--file ${{ env.PROJECT }}/Dockerfile ./${{ env.PROJECT }} \ | ||
--tag $(echo "${DOCKER_USERNAME}" | tr '[:upper:]' '[:lower:]')/${{ env.PROJECT }}:latest \ | ||
--tag $(echo "${DOCKER_USERNAME}" | tr '[:upper:]' '[:lower:]')/${{ env.PROJECT }}:${TAG} |
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,83 @@ | ||
name: Build | ||
|
||
"on": | ||
"push": | ||
"tags": | ||
- "v*" | ||
"branches": | ||
- "*" | ||
"pull_request": | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
env: | ||
GO111MODULE: "on" | ||
steps: | ||
- uses: actions/checkout@master | ||
|
||
- uses: actions/setup-go@v2 | ||
with: | ||
go-version: 1.16.4 | ||
|
||
- name: Prepare environment | ||
run: |- | ||
RELEASE_VERSION="${GITHUB_REF##*/}" | ||
if [[ "${RELEASE_VERSION}" != v* ]]; then RELEASE_VERSION='dev'; fi | ||
echo "RELEASE_VERSION=\"${RELEASE_VERSION}@${GITHUB_SHA:0:10}\"" | tee -a $GITHUB_ENV | ||
go mod vendor | ||
# Test | ||
- name: Unit Testing | ||
run: go test . | ||
|
||
# Win | ||
- run: GOOS=windows GOARCH=386 VERSION=${RELEASE_VERSION} make release | ||
- run: GOOS=windows GOARCH=amd64 VERSION=${RELEASE_VERSION} make release | ||
|
||
# MacOS | ||
- run: GOOS=darwin GOARCH=amd64 VERSION=${RELEASE_VERSION} make release | ||
|
||
# Linux X86/AMD64 | ||
- run: GOOS=linux GOARCH=386 VERSION=${RELEASE_VERSION} make release | ||
- run: GOOS=linux GOARCH=amd64 VERSION=${RELEASE_VERSION} make release | ||
|
||
# Linux ARM | ||
- run: GOOS=linux GOARCH=arm GOARM=6 VERSION=${RELEASE_VERSION} make release | ||
- run: GOOS=linux GOARCH=arm64 VERSION=${RELEASE_VERSION} make release | ||
|
||
# Linux MIPS/MIPSLE | ||
- run: GOOS=linux GOARCH=mips GOMIPS=softfloat VERSION=${RELEASE_VERSION} make release | ||
- run: GOOS=linux GOARCH=mipsle GOMIPS=softfloat VERSION=${RELEASE_VERSION} make release | ||
|
||
# FreeBSD X86 | ||
- run: GOOS=freebsd GOARCH=386 VERSION=${RELEASE_VERSION} make release | ||
- run: GOOS=freebsd GOARCH=amd64 VERSION=${RELEASE_VERSION} make release | ||
|
||
# FreeBSD ARM/ARM64 | ||
- run: GOOS=freebsd GOARCH=arm GOARM=6 VERSION=${RELEASE_VERSION} make release | ||
- run: GOOS=freebsd GOARCH=arm64 VERSION=${RELEASE_VERSION} make release | ||
|
||
- run: ls -l build/aliddns-* | ||
|
||
- name: Create release | ||
if: startsWith(github.ref, 'refs/tags/v') | ||
id: create_release | ||
uses: actions/create-release@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
tag_name: ${{ github.ref }} | ||
release_name: Release ${{ github.ref }} | ||
draft: false | ||
prerelease: false | ||
|
||
- name: Upload | ||
if: startsWith(github.ref, 'refs/tags/v') | ||
uses: xresloader/upload-to-github-release@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
file: "build/aliddns-*.tar.gz;build/aliddns-*.zip" | ||
tags: true | ||
draft: false |
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,33 @@ | ||
# Compiled Object files, Static and Dynamic libs (Shared Objects) | ||
*.o | ||
*.a | ||
*.so | ||
|
||
# Folders | ||
_obj | ||
_test | ||
.vscode/ | ||
release/ | ||
vendor/ | ||
|
||
# Architecture specific extensions/prefixes | ||
*.[568vq] | ||
[568vq].out | ||
|
||
*.cgo1.go | ||
*.cgo2.c | ||
_cgo_defun.c | ||
_cgo_gotypes.go | ||
_cgo_export.* | ||
|
||
_testmain.go | ||
|
||
*.exe | ||
*.test | ||
*.prof | ||
*.upx | ||
|
||
build/ | ||
debug | ||
aliyun-ddns-cli | ||
aliddns* |
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 @@ | ||
FROM golang:alpine as builder | ||
ENV CGO_ENABLED=0 \ | ||
GO111MODULE=on | ||
ENV VERSION 2021-06-11 | ||
|
||
RUN apk add --update git curl | ||
ADD . $GOPATH/src/github.com/honwen/aliyun-ddns-cli | ||
RUN set -ex \ | ||
&& cd $GOPATH/src/github.com/honwen/aliyun-ddns-cli \ | ||
&& go build -ldflags "-X main.VersionString=$(curl -sSL https://api.github.com/repos/honwen/aliyun-ddns-cli/commits/master | \ | ||
sed -n '{/sha/p; /date/p;}' | sed 's/.* \"//g' | cut -c1-10 | tr '[:lower:]' '[:upper:]' | sed 'N;s/\n/@/g' | head -1)" . \ | ||
&& mv aliyun-ddns-cli $GOPATH/bin/ | ||
|
||
|
||
FROM alpine | ||
LABEL MAINTAINER honwen <https://github.com/honwen> | ||
|
||
# /usr/bin/aliyun-ddns-cli | ||
COPY --from=builder /go/bin /usr/bin | ||
|
||
ENV AKID=1234567890 \ | ||
AKSCT=abcdefghijklmn \ | ||
DOMAIN=ddns.example.win \ | ||
IPAPI=[IPAPI-GROUP] \ | ||
REDO=0 | ||
|
||
CMD aliyun-ddns-cli \ | ||
--ipapi ${IPAPI} \ | ||
${IPV6:+-6} \ | ||
auto-update \ | ||
--domain ${DOMAIN} \ | ||
--redo ${REDO} |
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,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2016-2020 honwen | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
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,43 @@ | ||
NAME=aliddns | ||
BASE_BUILDDIR=build | ||
BUILDNAME=$(GOOS)-$(GOARCH)$(GOARM) | ||
BUILDDIR=$(BASE_BUILDDIR)/$(BUILDNAME) | ||
VERSION?=dev | ||
|
||
ifeq ($(GOOS),windows) | ||
ext=.exe | ||
archiveCmd=zip -9 -r $(NAME)-$(BUILDNAME)-$(VERSION).zip $(BUILDNAME) | ||
else | ||
ext= | ||
archiveCmd=tar czpvf $(NAME)-$(BUILDNAME)-$(VERSION).tar.gz $(BUILDNAME) | ||
endif | ||
|
||
.PHONY: default | ||
default: build | ||
|
||
build: clean test | ||
go build -mod=vendor | ||
|
||
release: check-env-release | ||
mkdir -p $(BUILDDIR) | ||
cp LICENSE $(BUILDDIR)/ | ||
cp README.md $(BUILDDIR)/ | ||
CGO_ENABLED=0 GOOS=$(GOOS) GOARCH=$(GOARCH) go build -mod=vendor -ldflags "-s -w -X main.VersionString=$(VERSION)" -o $(BUILDDIR)/$(NAME)$(ext) | ||
cd $(BASE_BUILDDIR) ; $(archiveCmd) | ||
|
||
test: | ||
go test -race -v -bench=. ./... | ||
|
||
clean: | ||
go clean | ||
rm -rf $(BASE_BUILDDIR) | ||
|
||
check-env-release: | ||
@ if [ "$(GOOS)" = "" ]; then \ | ||
echo "Environment variable GOOS not set"; \ | ||
exit 1; \ | ||
fi | ||
@ if [ "$(GOARCH)" = "" ]; then \ | ||
echo "Environment variable GOOS not set"; \ | ||
exit 1; \ | ||
fi |
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,36 @@ | ||
# ddns-aliyun | ||
|
||
GitHub [stilleshan/dockerfiles](https://github.com/stilleshan/dockerfiles) | ||
Docker [stilleshan/ddns-aliyun](https://hub.docker.com/r/stilleshan/ddns-aliyun) | ||
> *docker image support for X86 and ARM* | ||
## 使用 | ||
### docker 启动 | ||
```shell | ||
docker run -d \ | ||
-e "AKID=[ALIYUN's AccessKey-ID]" \ | ||
-e "AKSCT=[ALIYUN's AccessKey-Secret]" \ | ||
-e "DOMAIN=ddns.yourdomain.com" \ | ||
-e "REDO=600" \ | ||
stilleshan/ddns-aliyun | ||
``` | ||
|
||
- AKID: 填写`AccessKeyID` | ||
- AKSCT: 填写`AccessKeySecret` | ||
- DOMAIN: 填写`ddns 域名` | ||
|
||
### 示例 | ||
> 使用二级域名来作为 ddns 域名,例如以下示例使用 ddns.ioiox.com ,需要使用的正式域名添加 CNAME 指向 ddns.ioiox.com 即可. | ||
```shell | ||
docker run -d \ | ||
-e "AKID=kzazFUTW0uRIWWtk" \ | ||
-e "AKSCT=kcbGxOVmc9PUpJWTBWNFNWWnNSbFJW" \ | ||
-e "DOMAIN=ddns.ioiox.com" \ | ||
-e "REDO=600" \ | ||
stilleshan/ddns-aliyun | ||
``` | ||
|
||
## 参考 | ||
[群晖NAS网络服务 - docker 部署配置阿里云 DDNS 动态域名解析](https://www.ioiox.com/archives/29.html) | ||
更多请参考原始仓库 [honwen/aliyun-ddns-cli](https://github.com/honwen/aliyun-ddns-cli) | ||
|
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,41 @@ | ||
package dns | ||
|
||
import ( | ||
"log" | ||
|
||
"github.com/denverdino/aliyungo/common" | ||
) | ||
|
||
type AddDomainArgs struct { | ||
DomainName string | ||
|
||
//optional | ||
GroupId string | ||
} | ||
|
||
type AddDomainResponse struct { | ||
common.Response | ||
DomainId string | ||
DomainName string | ||
GroupId string | ||
GroupName string | ||
PunyCode string | ||
DnsServers struct { | ||
DnsServer []string | ||
} | ||
} | ||
|
||
// AddDomain | ||
// | ||
// You can read doc at https://help.aliyun.com/document_detail/29749.html?spm=5176.doc29805.6.592.6LMqlG | ||
func (client *Client) AddDomain(args *AddDomainArgs) (response *AddDomainResponse, err error) { | ||
action := "AddDomain" | ||
response = &AddDomainResponse{} | ||
err = client.Invoke(action, args, response) | ||
if err == nil { | ||
return response, nil | ||
} else { | ||
log.Printf("%s error, %v", action, err) | ||
return response, err | ||
} | ||
} |
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 @@ | ||
package dns | ||
|
||
import ( | ||
"log" | ||
|
||
"github.com/denverdino/aliyungo/common" | ||
) | ||
|
||
type AddDomainGroupArgs struct { | ||
GroupName string | ||
} | ||
|
||
type AddDomainGroupResponse struct { | ||
common.Response | ||
GroupId string | ||
GroupName string | ||
} | ||
|
||
// AddDomainGroup | ||
// | ||
// You can read doc at https://help.aliyun.com/document_detail/29762.html?spm=5176.doc29749.6.604.PJtwG1 | ||
func (client *Client) AddDomainGroup(args *AddDomainGroupArgs) (response *AddDomainGroupResponse, err error) { | ||
action := "AddDomainGroup" | ||
response = &AddDomainGroupResponse{} | ||
err = client.Invoke(action, args, response) | ||
if err == nil { | ||
return response, nil | ||
} else { | ||
log.Printf("%s error, %v", action, err) | ||
return response, err | ||
} | ||
} |
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,25 @@ | ||
package dns | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
func TestAddDomainGroup(t *testing.T) { | ||
client := NewTestClientNew() | ||
args := AddDomainGroupArgs{ | ||
GroupName: TestDomainGroupName, | ||
} | ||
|
||
response, err := client.AddDomainGroup(&args) | ||
if err == nil { | ||
t.Logf("AddDomainGroup %s success, %v", TestDomainGroupName, response) | ||
|
||
deleteDomainGroupArgs := DeleteDomainGroupArgs{ | ||
GroupId: response.GroupId, | ||
} | ||
client.DeleteDomainGroup(&deleteDomainGroupArgs) | ||
|
||
} else { | ||
t.Errorf("Failed to AddDomainGroup, %v", err) | ||
} | ||
} |
Oops, something went wrong.