Initial cleanup for folders
continuous-integration/drone/push Build was killed
Details
continuous-integration/drone/push Build was killed
Details
This commit is contained in:
parent
dfdd8ceea4
commit
150e238c05
|
@ -1,91 +0,0 @@
|
|||
stages:
|
||||
- build-static
|
||||
- build-binary
|
||||
- build-docker
|
||||
|
||||
build-static:
|
||||
image: mhart/alpine-node:latest
|
||||
stage: build-static
|
||||
script:
|
||||
- npm install -g @vue/cli
|
||||
- cd joker
|
||||
- npm install
|
||||
- npm run build
|
||||
artifacts:
|
||||
paths:
|
||||
- joker/dist
|
||||
|
||||
build-windows-amd64:
|
||||
image: golang:alpine
|
||||
stage: build-binary
|
||||
script:
|
||||
- apk --no-cache add git
|
||||
- go get -d
|
||||
- GOOS=windows go build -o joker.exe
|
||||
artifacts:
|
||||
paths:
|
||||
- joker.exe
|
||||
|
||||
build-linux-amd64:
|
||||
image: golang:alpine
|
||||
stage: build-binary
|
||||
script:
|
||||
- apk --no-cache add git
|
||||
- go get -d
|
||||
- GOOS=linux go build -o joker-amd64
|
||||
artifacts:
|
||||
paths:
|
||||
- joker-amd64
|
||||
|
||||
build-linux-arm:
|
||||
image: golang:alpine
|
||||
stage: build-binary
|
||||
script:
|
||||
- apk --no-cache add git
|
||||
- go get -d
|
||||
- GOARCH=arm GOOS=linux go build -o joker-arm
|
||||
artifacts:
|
||||
paths:
|
||||
- joker-arm
|
||||
|
||||
build-linux-arm64:
|
||||
image: golang:alpine
|
||||
stage: build-binary
|
||||
script:
|
||||
- apk --no-cache add git
|
||||
- go get -d
|
||||
- GOARCH=arm64 GOOS=linux go build -o joker-arm64
|
||||
artifacts:
|
||||
paths:
|
||||
- joker-arm64
|
||||
|
||||
build-docker-amd64:
|
||||
image: docker:latest
|
||||
stage: build-docker
|
||||
script:
|
||||
- apk --no-cache add git
|
||||
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
|
||||
- docker image build -t $CI_REGISTRY_IMAGE:amd64-latest -f docker/Dockerfile .
|
||||
- docker push $CI_REGISTRY_IMAGE:amd64-latest
|
||||
|
||||
build-docker-arm:
|
||||
image: docker:latest
|
||||
stage: build-docker
|
||||
script:
|
||||
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
|
||||
- mkdir tmp
|
||||
- wget -O tmp/qemu-arm-static https://github.com/multiarch/qemu-user-static/releases/download/v2.12.0/qemu-arm-static
|
||||
- chmod +x tmp/qemu-arm-static
|
||||
- docker image build -t $CI_REGISTRY_IMAGE:arm-latest -f docker/Dockerfile.arm .
|
||||
- docker push $CI_REGISTRY_IMAGE:arm-latest
|
||||
|
||||
build-docker-arm64:
|
||||
image: docker:latest
|
||||
stage: build-docker
|
||||
script:
|
||||
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
|
||||
- mkdir tmp
|
||||
- wget -O tmp/qemu-aarch64-static https://github.com/multiarch/qemu-user-static/releases/download/v2.12.0/qemu-aarch64-static
|
||||
- chmod +x tmp/qemu-aarch64-static
|
||||
- docker image build -t $CI_REGISTRY_IMAGE:arm64-latest -f docker/Dockerfile.arm64 .
|
||||
- docker push $CI_REGISTRY_IMAGE:arm64-latest
|
|
@ -2,7 +2,7 @@ FROM golang:alpine AS build-env
|
|||
|
||||
ADD . /src
|
||||
RUN apk add --no-cache gcc git musl-dev
|
||||
RUN cd /src && go get -d && go build -o joker-bin
|
||||
RUN cd /src && go build -o joker-bin
|
||||
|
||||
FROM node:alpine AS static-env
|
||||
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
module meow.tf/joker
|
||||
|
||||
go 1.12
|
||||
|
||||
require (
|
||||
github.com/asaskevich/govalidator v0.0.0-20190424111038-f61b66f89f4a
|
||||
github.com/hoisie/redis v0.0.0-20160730154456-b5c6e81454e0
|
||||
github.com/julienschmidt/httprouter v1.2.0
|
||||
github.com/weppos/publicsuffix-go v0.10.0
|
||||
golang.org/x/net v0.0.0-20190926025831-c00fd9afed17 // indirect
|
||||
)
|
|
@ -0,0 +1,14 @@
|
|||
github.com/asaskevich/govalidator v0.0.0-20190424111038-f61b66f89f4a h1:idn718Q4B6AGu/h5Sxe66HYVdqdGu2l9Iebqhi/AEoA=
|
||||
github.com/asaskevich/govalidator v0.0.0-20190424111038-f61b66f89f4a/go.mod h1:lB+ZfQJz7igIIfQNfa7Ml4HSf2uFQQRzpGGRXenZAgY=
|
||||
github.com/hoisie/redis v0.0.0-20160730154456-b5c6e81454e0 h1:mjZV3MTu2A5gwfT5G9IIiLGdwZNciyVq5qqnmJJZ2JI=
|
||||
github.com/hoisie/redis v0.0.0-20160730154456-b5c6e81454e0/go.mod h1:pMYMxVaKJqCDC1JUg/XbPJ4/fSazB25zORpFzqsIGIc=
|
||||
github.com/julienschmidt/httprouter v1.2.0 h1:TDTW5Yz1mjftljbcKqRcrYhd4XeOoI98t+9HbQbYf7g=
|
||||
github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
|
||||
github.com/weppos/publicsuffix-go v0.10.0 h1:u6FEJZ3kGCsIVns99k49dV9y4cE7dLpdaWscDllWOzQ=
|
||||
github.com/weppos/publicsuffix-go v0.10.0/go.mod h1:z3LCPQ38eedDQSwmsSRW4Y7t2L8Ln16JPQ02lHAdn5k=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/net v0.0.0-20190926025831-c00fd9afed17 h1:qPnAdmjNA41t3QBTx2mFGf/SD1IoslhYu7AmdsVzCcs=
|
||||
golang.org/x/net v0.0.0-20190926025831-c00fd9afed17/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
|
@ -1,9 +1,9 @@
|
|||
<template>
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<h3 v-if="this.$route.params.domain">{{ this.$route.params.domain }}</h3>
|
||||
<h3 v-if="this.$route.params.name">{{ this.$route.params.name }}</h3>
|
||||
<p>
|
||||
<span v-if="this.$route.params.domain">
|
||||
<span v-if="this.$route.params.name">
|
||||
<button @click.stop="$router.go(-1)" class="btn btn-info">Back</button>
|
||||
|
||||
</span>
|
||||
|
@ -28,7 +28,7 @@
|
|||
</form>
|
||||
</b-modal>
|
||||
<div class="col-12">
|
||||
<b-table id="records" ref="table" striped bordered hover fixed :items="items" :fields="fields" v-on:row-clicked="rowClicked" v-on:row-dblclicked="edit" head-variant="dark" sort-by="domain">
|
||||
<b-table id="records" ref="table" striped bordered hover fixed :items="items" :fields="fields" v-on:row-clicked="rowClicked" v-on:row-dblclicked="edit" head-variant="dark" sort-by="name">
|
||||
<template slot="ip" slot-scope="row">
|
||||
<span v-if="row.item.editing">
|
||||
<input ref="ip" :value="row.item.ip"/>
|
||||
|
@ -60,12 +60,12 @@
|
|||
import axios from 'axios';
|
||||
|
||||
let data = {
|
||||
domain: null,
|
||||
name: null,
|
||||
name: '',
|
||||
value: '',
|
||||
items: [],
|
||||
fields: [
|
||||
{key: "domain", label: 'Domain', sortable: true},
|
||||
{key: "name", label: 'Name', sortable: true},
|
||||
{key: 'ip', label: 'IP', sortable: true},
|
||||
{key: 'actions', label: 'Actions'}
|
||||
]
|
||||
|
@ -73,7 +73,7 @@
|
|||
|
||||
export default {
|
||||
name: 'DNS',
|
||||
props: ['domain'],
|
||||
props: ['name'],
|
||||
methods: {
|
||||
handleOk(evt) {
|
||||
// Prevent modal from closing
|
||||
|
@ -97,10 +97,10 @@
|
|||
}
|
||||
|
||||
axios.post('/update', {
|
||||
domain: this.name,
|
||||
name: this.name,
|
||||
ip: this.value
|
||||
}).then(() => {
|
||||
this.refreshData(this.domain);
|
||||
this.refreshData(this.name);
|
||||
});
|
||||
|
||||
this.name = '';
|
||||
|
@ -108,8 +108,8 @@
|
|||
|
||||
this.$refs.modal.hide()
|
||||
},
|
||||
refreshData: function(domain) {
|
||||
axios.get('/records' + (domain ? '/' + domain : ''))
|
||||
refreshData: function(name) {
|
||||
axios.get('/records' + (name ? '/' + name : ''))
|
||||
.then((response) => {
|
||||
data.items = response.data;
|
||||
});
|
||||
|
@ -130,13 +130,13 @@
|
|||
},
|
||||
rowClicked: function (item) {
|
||||
if (item.itemCount > 1) {
|
||||
this.$router.push({name: 'dns', params: {domain: item.domain}});
|
||||
this.$router.push({name: 'dns', params: {name: item.name}});
|
||||
}
|
||||
},
|
||||
edit: function (item) {
|
||||
// Nothing
|
||||
if (item.ip === '-') {
|
||||
this.$router.push({name: 'dns', params: {domain: item.domain}});
|
||||
this.$router.push({name: 'dns', params: {name: item.name}});
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -149,7 +149,7 @@
|
|||
item.ip = this.$refs.ip.value;
|
||||
|
||||
axios.post('/update', {
|
||||
domain: item.domain,
|
||||
name: item.name,
|
||||
ip: item.ip
|
||||
}).then(() => {
|
||||
Vue.set(item, 'editing', false);
|
||||
|
@ -167,10 +167,10 @@
|
|||
}
|
||||
|
||||
axios.post('/remove', {
|
||||
domain: item.domain,
|
||||
name: item.name,
|
||||
group: item.itemCount > 1
|
||||
}).then(() => {
|
||||
this.refreshData(this.domain);
|
||||
this.refreshData(this.name);
|
||||
});
|
||||
}
|
||||
},
|
||||
|
@ -178,8 +178,8 @@
|
|||
return data;
|
||||
},
|
||||
mounted: function() {
|
||||
this.domain = this.$route.params.domain;
|
||||
this.refreshData(this.domain);
|
||||
this.name = this.$route.params.name;
|
||||
this.refreshData(this.name);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
|
36
main.go
36
main.go
|
@ -1,16 +1,16 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"github.com/julienschmidt/httprouter"
|
||||
"github.com/hoisie/redis"
|
||||
"encoding/json"
|
||||
"github.com/weppos/publicsuffix-go/publicsuffix"
|
||||
"strings"
|
||||
"github.com/asaskevich/govalidator"
|
||||
"flag"
|
||||
"os"
|
||||
"github.com/asaskevich/govalidator"
|
||||
"github.com/hoisie/redis"
|
||||
"github.com/julienschmidt/httprouter"
|
||||
"github.com/weppos/publicsuffix-go/publicsuffix"
|
||||
"log"
|
||||
"net/http"
|
||||
"os"
|
||||
"strings"
|
||||
)
|
||||
|
||||
var c *redis.Client
|
||||
|
@ -78,7 +78,7 @@ func getInfo(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
|
|||
}
|
||||
|
||||
type tableRow struct {
|
||||
Domain string `json:"domain"`
|
||||
Name string `json:"name"`
|
||||
IP string `json:"ip"`
|
||||
ItemCount int `json:"itemCount"`
|
||||
}
|
||||
|
@ -132,7 +132,7 @@ func getRecords(w http.ResponseWriter, r *http.Request, p httprouter.Params) {
|
|||
}
|
||||
|
||||
out = append(out, &tableRow{
|
||||
Domain: domain,
|
||||
Name: domain,
|
||||
IP: ip,
|
||||
ItemCount: len(children),
|
||||
})
|
||||
|
@ -140,7 +140,7 @@ func getRecords(w http.ResponseWriter, r *http.Request, p httprouter.Params) {
|
|||
} else {
|
||||
for domain, ip := range groups[zone] {
|
||||
out = append(out, &tableRow{
|
||||
Domain: domain,
|
||||
Name: domain,
|
||||
IP: ip,
|
||||
ItemCount: 1,
|
||||
})
|
||||
|
@ -159,7 +159,7 @@ func mapFirst(m map[string]string) string {
|
|||
}
|
||||
|
||||
type domainRequest struct {
|
||||
Domain string `json:"domain"`
|
||||
Name string `json:"name"`
|
||||
IP string `json:"ip"`
|
||||
Group bool `json:"group"`
|
||||
}
|
||||
|
@ -177,10 +177,10 @@ func updateRecord(w http.ResponseWriter, r *http.Request, p httprouter.Params) {
|
|||
return
|
||||
}
|
||||
|
||||
req.Domain = strings.ToLower(req.Domain)
|
||||
req.Name = strings.ToLower(req.Name)
|
||||
|
||||
// Replace wildcards with an 'a' to test the domain
|
||||
testDomain := req.Domain
|
||||
testDomain := req.Name
|
||||
testDomain = strings.Replace(testDomain, "*", "a", -1)
|
||||
|
||||
if !govalidator.IsDNSName(testDomain) || !govalidator.IsIP(req.IP) {
|
||||
|
@ -188,7 +188,7 @@ func updateRecord(w http.ResponseWriter, r *http.Request, p httprouter.Params) {
|
|||
return
|
||||
}
|
||||
|
||||
if _, err := c.Hset(key, req.Domain, []byte(req.IP)); err != nil {
|
||||
if _, err := c.Hset(key, req.Name, []byte(req.IP)); err != nil {
|
||||
errorResponse(w, http.StatusInternalServerError, "Unable to save record: " + err.Error())
|
||||
return
|
||||
}
|
||||
|
@ -205,9 +205,9 @@ func removeRecord(w http.ResponseWriter, r *http.Request, p httprouter.Params) {
|
|||
return
|
||||
}
|
||||
|
||||
req.Domain = strings.ToLower(req.Domain)
|
||||
req.Name = strings.ToLower(req.Name)
|
||||
|
||||
if !govalidator.IsDNSName(strings.Replace(req.Domain, "*", "a", -1)) {
|
||||
if !govalidator.IsDNSName(strings.Replace(req.Name, "*", "a", -1)) {
|
||||
w.WriteHeader(http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
|
@ -223,7 +223,7 @@ func removeRecord(w http.ResponseWriter, r *http.Request, p httprouter.Params) {
|
|||
for host, _ := range hosts {
|
||||
host = strings.ToLower(host)
|
||||
|
||||
if !strings.HasSuffix(host, req.Domain) {
|
||||
if !strings.HasSuffix(host, req.Name) {
|
||||
continue
|
||||
}
|
||||
|
||||
|
@ -232,7 +232,7 @@ func removeRecord(w http.ResponseWriter, r *http.Request, p httprouter.Params) {
|
|||
c.Publish("godns:remove_record", []byte(host))
|
||||
}
|
||||
} else {
|
||||
if _, err := c.Hdel(key, req.Domain); err != nil {
|
||||
if _, err := c.Hdel(key, req.Name); err != nil {
|
||||
errorResponse(w, http.StatusInternalServerError, "Unable to delete record: " + err.Error())
|
||||
return
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue