mirror of
https://github.com/jeessy2/ddns-go.git
synced 2024-11-25 16:46:24 +08:00
增加 Makefile 优化编译脚本,并添加相应的说明 (#19)
* 增加 Makefile 优化编译脚本,并添加相应的说明 * 清除不需要的文件 * 将 binddata 加入编译脚本中 * 将第三方文件纳入本地 * update documents and some tiny modify * 增加 配置文件,统一格式 * use bootstrap.min.css * fix: indent Co-authored-by: 明城 <mingcheng@users.noreply.github.com> Co-authored-by: jeessy2 <454207171@qq.com>
This commit is contained in:
parent
7598dd9182
commit
a4bcbc80b9
29
.editorconfig
Normal file
29
.editorconfig
Normal file
@ -0,0 +1,29 @@
|
||||
# http://editorconfig.org
|
||||
|
||||
root = true
|
||||
|
||||
[*]
|
||||
charset = utf-8
|
||||
end_of_line = lf
|
||||
insert_final_newline = true
|
||||
trim_trailing_whitespace = true
|
||||
|
||||
[*.go]
|
||||
indent_style = tab
|
||||
indent_size = 2
|
||||
|
||||
[Dockerfile]
|
||||
indent_style = tab
|
||||
indent_size = 4
|
||||
|
||||
[Makefile]
|
||||
indent_style = tab
|
||||
indent_size = 4
|
||||
|
||||
[.travis.yml]
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
|
||||
[*.json]
|
||||
indent_style = space
|
||||
indent_size = 2
|
35
.gitignore
vendored
35
.gitignore
vendored
@ -1,2 +1,33 @@
|
||||
__debug_bin
|
||||
.DS_Store
|
||||
# Compiled Object files, Static and Dynamic libs (Shared Objects)
|
||||
*.o
|
||||
*.a
|
||||
*.so
|
||||
/ddns-go
|
||||
__*
|
||||
|
||||
# Folders
|
||||
_obj
|
||||
_test
|
||||
.vagrant
|
||||
releases
|
||||
tmp
|
||||
/.idea/
|
||||
vendor/
|
||||
/dist
|
||||
|
||||
# Architecture specific extensions/prefixes
|
||||
trace.out
|
||||
*.out
|
||||
.DS_Store
|
||||
_testmain.go
|
||||
|
||||
*.exe
|
||||
*.test
|
||||
*.prof
|
||||
profile.cov
|
||||
coverage.html
|
||||
/go.sum
|
||||
|
||||
# Emacs backup files
|
||||
*~
|
||||
.*~
|
||||
|
14
Dockerfile
14
Dockerfile
@ -1,19 +1,21 @@
|
||||
# build stage
|
||||
FROM golang:alpine AS builder
|
||||
FROM golang:1.15 AS builder
|
||||
|
||||
WORKDIR /app
|
||||
COPY . .
|
||||
RUN go env -w GO111MODULE=on \
|
||||
&& go env -w GOPROXY=https://goproxy.cn,direct \
|
||||
&& go get -d -v . \
|
||||
&& go install -v . \
|
||||
&& go build -v .
|
||||
&& make clean build
|
||||
|
||||
# final stage
|
||||
FROM alpine
|
||||
LABEL name=ddns-go
|
||||
LABEL url=https://github.com/jeessy2/ddns-go
|
||||
|
||||
WORKDIR /app
|
||||
RUN apk add --no-cache tzdata
|
||||
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.tuna.tsinghua.edu.cn/g' /etc/apk/repositories \
|
||||
&& apk add --no-cache tzdata
|
||||
ENV TZ=Asia/Shanghai
|
||||
COPY --from=builder /app/ddns-go /app/ddns-go
|
||||
EXPOSE 9876
|
||||
ENTRYPOINT /app/ddns-go
|
||||
LABEL Name=ddns-go Version=0.0.1
|
||||
|
41
Makefile
Normal file
41
Makefile
Normal file
@ -0,0 +1,41 @@
|
||||
.PHONY: build clean test test-race
|
||||
|
||||
VERSION=0.0.1
|
||||
BIN=ddns-go
|
||||
DIR_SRC=.
|
||||
DOCKER_CMD=docker
|
||||
|
||||
GO_ENV=CGO_ENABLED=0
|
||||
GO_FLAGS=-ldflags="-X main.version=$(VERSION) -X 'main.buildTime=`date`' -extldflags -static"
|
||||
GO=$(GO_ENV) $(shell which go)
|
||||
GOROOT=$(shell `which go` env GOROOT)
|
||||
GOPATH=$(shell `which go` env GOPATH)
|
||||
|
||||
build: bindata $(DIR_SRC)/main.go
|
||||
@$(GO) build $(GO_FLAGS) -o $(BIN) $(DIR_SRC)
|
||||
|
||||
build_docker_image: clean
|
||||
@$(DOCKER_CMD) build -f ./Dockerfile -t ddns-go:$(VERSION) .
|
||||
|
||||
init:
|
||||
@go get -u github.com/go-bindata/go-bindata/...
|
||||
|
||||
test:
|
||||
@$(GO) test ./...
|
||||
|
||||
test-race:
|
||||
@$(GO) test -race ./...
|
||||
|
||||
bindata:
|
||||
@go-bindata -pkg util -o util/staticPages.go static/pages/...
|
||||
@go-bindata -pkg static -o asserts/html.go -fs -prefix "static/" static/
|
||||
|
||||
dev:
|
||||
@go-bindata -debug -pkg util -o util/staticPages.go static/pages/...
|
||||
|
||||
# clean all build result
|
||||
clean:
|
||||
@rm -f util/staticPages.go asserts/html.go
|
||||
@$(GO) clean ./...
|
||||
@rm -f $(BIN)
|
||||
@rm -rf ./dist/*
|
65
README.md
65
README.md
@ -1,8 +1,25 @@
|
||||
<a href="https://github.com/jeessy2/ddns-go/releases/latest"><img alt="GitHub release" src="https://img.shields.io/github/release/jeessy2/ddns-go.svg?logo=github&style=flat-square"></a>
|
||||
|
||||
# ddns-go
|
||||
|
||||
- 自动获得你的公网IPV4或IPV6并解析到域名中
|
||||
<a href="https://github.com/jeessy2/ddns-go/releases/latest"><img alt="GitHub release" src="https://img.shields.io/github/release/jeessy2/ddns-go.svg?logo=github&style=flat-square"></a>
|
||||
|
||||
自动获得你的公网 IPV4 或 IPV6 地址,并解析到对应的域名服务。
|
||||
|
||||
<!-- TOC -->
|
||||
|
||||
- [ddns-go](#ddns-go)
|
||||
- [特性](#特性)
|
||||
- [界面](#界面)
|
||||
- [使用](#使用)
|
||||
- [直接执行](#直接执行)
|
||||
- [Docker](#docker)
|
||||
- [自行编译](#自行编译)
|
||||
- [使用IPV6](#使用ipv6)
|
||||
- [Webhook](#webhook)
|
||||
|
||||
<!-- /TOC -->
|
||||
|
||||
## 特性
|
||||
|
||||
- 支持Mac、Windows、Linux系统,支持ARM、x86架构
|
||||
- 支持的域名服务商 `Alidns(阿里云)` `Dnspod(腾讯云)` `Cloudflare` `华为云`
|
||||
- 支持接口/网卡获取IP
|
||||
@ -13,14 +30,20 @@
|
||||
- 网页中方便快速查看最近50条日志,不需要跑docker中查看
|
||||
- 支持webhook
|
||||
|
||||
## 系统中使用
|
||||
## 界面
|
||||
|
||||
![screenshots](https://raw.githubusercontent.com/jeessy2/ddns-go/master/ddns-web.png)
|
||||
|
||||
## 使用
|
||||
|
||||
### 直接执行
|
||||
|
||||
- 下载并解压[https://github.com/jeessy2/ddns-go/releases](https://github.com/jeessy2/ddns-go/releases)
|
||||
- 双击运行,程序自动打开[http://127.0.0.1:9876](http://127.0.0.1:9876),修改你的配置,成功
|
||||
- [可选] 加入到开机启动中,需自行搜索
|
||||
- [可选] 支持启动带参数 `-l`监听地址 `-f`间隔时间(秒)。如:`./ddns-go -l 127.0.0.1:9876 -f 300`
|
||||
|
||||
## Docker中使用
|
||||
### Docker
|
||||
|
||||
```
|
||||
docker run -d \
|
||||
@ -33,6 +56,16 @@ docker run -d \
|
||||
- 在网页中打开`http://主机IP:9876`,修改你的配置,成功
|
||||
- [可选] docker中默认不支持ipv6,需自行探索如何开启
|
||||
|
||||
### 自行编译
|
||||
|
||||
如果喜欢从源代码编译自己的版本,可以使用本项目提供的 Makefile 构建。首先安装 bindata(或者简单使用 `make init`):
|
||||
|
||||
```go
|
||||
go get -u github.com/go-bindata/go-bindata/...
|
||||
```
|
||||
|
||||
然后,简单的使用 `make build` 即可生成本地编译版本的 `ddns-go` 可执行文件。你还可以自行编译 Docker 镜像,使用 `make build_docker_image` 即可在本地自动化编译、打包 Docker 镜像。
|
||||
|
||||
## 使用IPV6
|
||||
|
||||
- 前提:你的电脑或终端能正常获取IPV6,并能正常访问IPV6
|
||||
@ -74,25 +107,3 @@ docker run -d \
|
||||
- 只勾选 `自定义关键词`, 输入的关键字必须包含在RequestBody的content中, 如:`你的公网IP变了`
|
||||
- URL中输入钉钉给你的 `Webhook地址`
|
||||
- RequestBody中输入 `{"msgtype": "text","text": {"content": "你的公网IP变了:#{ipv4Addr},域名更新结果:#{ipv4Result}"}}`
|
||||
|
||||
|
||||
![avatar](https://raw.githubusercontent.com/jeessy2/ddns-go/master/ddns-web.png)
|
||||
|
||||
## Development
|
||||
|
||||
```
|
||||
go get -u github.com/go-bindata/go-bindata/...
|
||||
go-bindata -debug -pkg util -o util/staticPagesData.go static/pages/...
|
||||
go-bindata -pkg static -o static/js_css_data.go -fs -prefix "static/" static/
|
||||
```
|
||||
|
||||
## Release
|
||||
|
||||
```
|
||||
go-bindata -pkg util -o util/staticPagesData.go static/pages/...
|
||||
go-bindata -pkg static -o static/js_css_data.go -fs -prefix "static/" static/
|
||||
|
||||
# 自动发布
|
||||
git tag v0.0.x -m "xxx"
|
||||
git push --tags
|
||||
```
|
||||
|
File diff suppressed because one or more lines are too long
1
go.mod
1
go.mod
@ -4,6 +4,7 @@ go 1.15
|
||||
|
||||
require (
|
||||
github.com/aliyun/alibaba-cloud-sdk-go v1.61.439
|
||||
github.com/go-bindata/go-bindata v3.1.2+incompatible // indirect
|
||||
github.com/jmespath/go-jmespath v0.3.0 // indirect
|
||||
github.com/json-iterator/go v1.1.10 // indirect
|
||||
github.com/modern-go/reflect2 v1.0.1 // indirect
|
||||
|
2
main.go
Executable file → Normal file
2
main.go
Executable file → Normal file
@ -1,9 +1,9 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
static "ddns-go/asserts"
|
||||
"ddns-go/config"
|
||||
"ddns-go/dns"
|
||||
"ddns-go/static"
|
||||
"ddns-go/util"
|
||||
"ddns-go/web"
|
||||
"flag"
|
||||
|
6
static/bootstrap.min.css
vendored
6
static/bootstrap.min.css
vendored
File diff suppressed because one or more lines are too long
@ -6,10 +6,9 @@
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<meta name="author" content="jie">
|
||||
<title>DDNS-GO</title>
|
||||
<!-- Bootstrap CSS -->
|
||||
<link rel="stylesheet" href="/static/bootstrap.min.css">
|
||||
<link rel="stylesheet" href="/static/common.css">
|
||||
<script src="/static/jquery-3.5.1.min.js"></script>
|
||||
<link rel="stylesheet" href="/static/common.css">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
248
util/staticPages.go
Normal file
248
util/staticPages.go
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user