This commit is contained in:
51
.gitea/workflows/registry.yml
Normal file
51
.gitea/workflows/registry.yml
Normal file
@@ -0,0 +1,51 @@
|
||||
name: release-tag
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- 'main'
|
||||
jobs:
|
||||
release-image:
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
DOCKER_ORG: sendnrw
|
||||
DOCKER_LATEST: latest
|
||||
RUNNER_TOOL_CACHE: /toolcache
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v2
|
||||
|
||||
- name: Set up Docker BuildX
|
||||
uses: docker/setup-buildx-action@v2
|
||||
with: # replace it with your local IP
|
||||
config-inline: |
|
||||
[registry."git.send.nrw"]
|
||||
http = true
|
||||
insecure = true
|
||||
|
||||
- name: Login to DockerHub
|
||||
uses: docker/login-action@v2
|
||||
with:
|
||||
registry: git.send.nrw # replace it with your local IP
|
||||
username: ${{ secrets.DOCKER_USERNAME }}
|
||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||
|
||||
- name: Get Meta
|
||||
id: meta
|
||||
run: |
|
||||
echo REPO_NAME=$(echo ${GITHUB_REPOSITORY} | awk -F"/" '{print $2}') >> $GITHUB_OUTPUT
|
||||
echo REPO_VERSION=$(git describe --tags --always | sed 's/^v//') >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Build and push
|
||||
uses: docker/build-push-action@v4
|
||||
with:
|
||||
context: .
|
||||
file: ./Dockerfile
|
||||
platforms: |
|
||||
linux/amd64
|
||||
push: true
|
||||
tags: | # replace it with your local IP and tags
|
||||
git.send.nrw/${{ env.DOCKER_ORG }}/${{ steps.meta.outputs.REPO_NAME }}:${{ steps.meta.outputs.REPO_VERSION }}
|
||||
git.send.nrw/${{ env.DOCKER_ORG }}/${{ steps.meta.outputs.REPO_NAME }}:${{ env.DOCKER_LATEST }}
|
10
Dockerfile
Normal file
10
Dockerfile
Normal file
@@ -0,0 +1,10 @@
|
||||
FROM golang:1.23.3
|
||||
RUN mkdir /data
|
||||
COPY data/* /data
|
||||
WORKDIR /app
|
||||
COPY go.mod go.sum ./
|
||||
RUN go mod download
|
||||
COPY *.go ./
|
||||
RUN CGO_ENABLED=0 GOOS=linux go build -o /go-ddns
|
||||
EXPOSE 8080
|
||||
CMD ["/go-ddns"]
|
3
go.mod
Normal file
3
go.mod
Normal file
@@ -0,0 +1,3 @@
|
||||
module git.send.nrw/sendnrw/dyndns_container
|
||||
|
||||
go 1.23.1
|
97
main.go
Normal file
97
main.go
Normal file
@@ -0,0 +1,97 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
"os"
|
||||
"time"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
||||
DEV_TESTING := os.Getenv("DYNDNS_URL")
|
||||
|
||||
DYNDNS_URL := os.Getenv("DYNDNS_URL")
|
||||
DYNDNS_ADDRESS := os.Getenv("DYNDNS_ADDRESS")
|
||||
DYNDNS_IPv4 := os.Getenv("DYNDNS_IPv4")
|
||||
DYNDNS_IPv6 := os.Getenv("DYNDNS_IPv6")
|
||||
DYNDNS_USERNAME := os.Getenv("DYNDNS_USERNAME")
|
||||
DYNDNS_PASSWORD := os.Getenv("DYNDNS_PASSWORD")
|
||||
|
||||
DYNDNS_IPv4_ADDR_RESOLVER := os.Getenv("DYNDNS_IPv4_ADDR_RESOLVER")
|
||||
DYNDNS_IPv6_ADDR_RESOLVER := os.Getenv("DYNDNS_IPv6_ADDR_RESOLVER")
|
||||
|
||||
if DYNDNS_IPv4_ADDR_RESOLVER == "" {
|
||||
DYNDNS_IPv4_ADDR_RESOLVER = "https://dns.hilden.info/ip"
|
||||
}
|
||||
|
||||
if DYNDNS_IPv6_ADDR_RESOLVER == "" {
|
||||
DYNDNS_IPv6_ADDR_RESOLVER = "https://dns.hilden.info/ip"
|
||||
}
|
||||
|
||||
if DEV_TESTING == "" {
|
||||
DYNDNS_URL = "https://dns.hilden.info"
|
||||
DYNDNS_ADDRESS = "devtest.dns.hilden.info"
|
||||
DYNDNS_IPv4 = "9.8.7.6"
|
||||
DYNDNS_IPv6 = "2001:db8::1"
|
||||
DYNDNS_USERNAME = "admin"
|
||||
DYNDNS_PASSWORD = "password"
|
||||
DYNDNS_IPv4_ADDR_RESOLVER = "https://dns.hilden.info/ip"
|
||||
DYNDNS_IPv6_ADDR_RESOLVER = "https://dns.hilden.info/ip"
|
||||
}
|
||||
|
||||
for {
|
||||
/*GetIPv4*/
|
||||
respipv4, err := http.Get(DYNDNS_IPv4_ADDR_RESOLVER)
|
||||
if err != nil {
|
||||
fmt.Println("Fehler beim Abrufen der URL:", DYNDNS_IPv4_ADDR_RESOLVER, err)
|
||||
} else {
|
||||
body, err := io.ReadAll(respipv4.Body)
|
||||
if err != nil {
|
||||
fmt.Println("Fehler beim Lesen des Antwort-Bodys:", err)
|
||||
} else {
|
||||
// Antwort-Inhalt ausgeben
|
||||
DYNDNS_IPv4 = string(body)
|
||||
fmt.Println("Statuscode:", respipv4.StatusCode)
|
||||
fmt.Println("Antwort-Inhalt:", string(body))
|
||||
}
|
||||
respipv4.Body.Close()
|
||||
}
|
||||
|
||||
/*GetIPv6*/
|
||||
respipv6, err := http.Get(DYNDNS_IPv6_ADDR_RESOLVER)
|
||||
if err != nil {
|
||||
fmt.Println("Fehler beim Abrufen der URL:", DYNDNS_IPv6_ADDR_RESOLVER, err)
|
||||
} else {
|
||||
body, err := io.ReadAll(respipv6.Body)
|
||||
if err != nil {
|
||||
fmt.Println("Fehler beim Lesen des Antwort-Bodys:", err)
|
||||
} else {
|
||||
// Antwort-Inhalt ausgeben
|
||||
DYNDNS_IPv6 = string(body)
|
||||
fmt.Println("Statuscode:", respipv6.StatusCode)
|
||||
fmt.Println("Antwort-Inhalt:", string(body))
|
||||
}
|
||||
respipv6.Body.Close()
|
||||
}
|
||||
|
||||
/**/
|
||||
url := DYNDNS_URL + "/?DDNS=" + DYNDNS_ADDRESS + "&IP=" + DYNDNS_IPv4 + "&IPv6=" + DYNDNS_IPv6 + "&USER=" + DYNDNS_USERNAME + "&TOKEN=" + DYNDNS_PASSWORD
|
||||
resp, err := http.Get(url)
|
||||
if err != nil {
|
||||
fmt.Println("Fehler beim Abrufen der URL:", DYNDNS_IPv6_ADDR_RESOLVER, err)
|
||||
} else {
|
||||
body, err := io.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
fmt.Println("Fehler beim Lesen des Antwort-Bodys:", err)
|
||||
} else {
|
||||
// Antwort-Inhalt ausgeben
|
||||
fmt.Println("Statuscode:", resp.StatusCode)
|
||||
fmt.Println("Antwort-Inhalt:", string(body))
|
||||
}
|
||||
resp.Body.Close()
|
||||
}
|
||||
time.Sleep(5 * time.Minute)
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user