35 files changed, 39 insertions(+), 37 deletions(-)
M Dockerfile
R felu.go => cmd/felu/main.go
M go.mod
R api/key.go => internal/api/key.go
R components/adminpartials.templ => internal/components/adminpartials.templ
R components/adminpartials_templ.go => internal/components/adminpartials_templ.go
R components/base.templ => internal/components/base.templ
R components/base_templ.go => internal/components/base_templ.go
R components/index.templ => internal/components/index.templ
R components/index_templ.go => internal/components/index_templ.go
R components/login.templ => internal/components/login.templ
R components/login_templ.go => internal/components/login_templ.go
R components/manage.templ => internal/components/manage.templ
R components/manage_templ.go => internal/components/manage_templ.go
R components/manageadmin.templ => internal/components/manageadmin.templ
R components/manageadmin_templ.go => internal/components/manageadmin_templ.go
R components/managepartials.templ => internal/components/managepartials.templ
R components/managepartials_templ.go => internal/components/managepartials_templ.go
R config/config.go => internal/config/config.go
R db/db.go => internal/db/db.go
R db/domains.go => internal/db/domains.go
R db/migrations.go => internal/db/migrations.go
R db/users.go => internal/db/users.go
R dns/handle.go => internal/dns/handle.go
R dns/query.go => internal/dns/query.go
R dns/server.go => internal/dns/server.go
R handlers/admin.go => internal/handlers/admin.go
R handlers/adminpartials.go => internal/handlers/adminpartials.go
R handlers/login.go => internal/handlers/login.go
R handlers/managedomains.go => internal/handlers/managedomains.go
R handlers/managepartials.go => internal/handlers/managepartials.go
R handlers/users.go => internal/handlers/users.go
R middlewares/admin.go => internal/middlewares/admin.go
R middlewares/auth.go => internal/middlewares/auth.go
R renderer.go => internal/renderer/renderer.go
M Dockerfile => Dockerfile +3 -2
@@ 10,10 10,11 @@ WORKDIR /usr/src/app
COPY go.mod go.sum ./
RUN go mod download && go mod verify
-COPY . .
+COPY cmd/ ./cmd
+COPY internal/ ./internal
RUN --mount=type=cache,target=/root/.cache/go-build \
-CGO_ENABLED=1 GOOS=linux go build -ldflags=-X=main.version=${VERSION} -v -o /felu ./*.go
+CGO_ENABLED=1 GOOS=linux go build -ldflags=-X=main.version=${VERSION} -v -o /felu ./cmd/felu/main.go
# tester
FROM builder AS tester
R felu.go => cmd/felu/main.go +10 -9
@@ 13,12 13,13 @@ import (
"strconv"
"time"
- "git.src.quest/~skye/felu-ddns/components"
- "git.src.quest/~skye/felu-ddns/config"
- "git.src.quest/~skye/felu-ddns/db"
- "git.src.quest/~skye/felu-ddns/dns"
- "git.src.quest/~skye/felu-ddns/handlers"
- "git.src.quest/~skye/felu-ddns/middlewares"
+ "git.src.quest/~skye/felu-ddns/internal/components"
+ "git.src.quest/~skye/felu-ddns/internal/config"
+ "git.src.quest/~skye/felu-ddns/internal/db"
+ "git.src.quest/~skye/felu-ddns/internal/dns"
+ "git.src.quest/~skye/felu-ddns/internal/handlers"
+ "git.src.quest/~skye/felu-ddns/internal/middlewares"
+ "git.src.quest/~skye/felu-ddns/internal/renderer"
"github.com/alexedwards/scs/v2"
"github.com/gin-gonic/gin"
"golang.org/x/sync/errgroup"
@@ 61,7 62,7 @@ func setupFrontendRouter() *gin.Engine {
return ginLogFormat(param, "frontend")
}))
r.Static("/static", "./static")
- r.HTMLRender = &TemplRender{}
+ r.HTMLRender = &renderer.TemplRender{}
r.GET("/", func(c *gin.Context) {
c.HTML(http.StatusOK, "", components.Index())
@@ 80,13 81,13 @@ func setupFrontendRouter() *gin.Engine {
manage := r.Group("/manage").Use(middlewares.SessionExists(sessionManager))
{
manage.GET("/", func(c *gin.Context) {
- c.HTML(http.StatusOK, "", components.Manage())
+ c.HTML(http.StatusOK, "", components.Manage()) //TODO: yeah move these to handlers/manage.go
})
manage.GET("/settings", func(c *gin.Context) {
c.HTML(http.StatusOK, "", components.ManageSettings())
})
- manage.POST("/domains", handlers.PostDomain())
+ manage.POST("/domains", handlers.PostDomain()) //TODO: move these to handlers/domains.go
manage.PATCH("/domains/:id") // TODO:
manage.DELETE("/domains/:id", handlers.DeleteDomain())
M go.mod => go.mod +5 -5
@@ 5,12 5,16 @@ go 1.20
require (
git.src.quest/~skye/erya-go v0.0.0-20231011145529-3201c2bf8ec7
github.com/a-h/templ v0.2.364
+ github.com/alexedwards/scs/v2 v2.5.1
github.com/gin-gonic/gin v1.9.1
+ github.com/matthewhartstonge/argon2 v0.3.4
+ github.com/mattn/go-sqlite3 v1.14.17
+ github.com/miekg/dns v1.1.56
+ github.com/oklog/ulid/v2 v2.1.0
golang.org/x/sync v0.4.0
)
require (
- github.com/alexedwards/scs/v2 v2.5.1 // indirect
github.com/bytedance/sonic v1.10.2 // indirect
github.com/chenzhuoyu/base64x v0.0.0-20230717121745-296ad89f973d // indirect
github.com/chenzhuoyu/iasm v0.9.0 // indirect
@@ 25,13 29,9 @@ require (
github.com/klauspost/cpuid/v2 v2.2.5 // indirect
github.com/kr/pretty v0.3.1 // indirect
github.com/leodido/go-urn v1.2.4 // indirect
- github.com/matthewhartstonge/argon2 v0.3.4 // indirect
github.com/mattn/go-isatty v0.0.19 // indirect
- github.com/mattn/go-sqlite3 v1.14.17 // indirect
- github.com/miekg/dns v1.1.56 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
- github.com/oklog/ulid/v2 v2.1.0 // indirect
github.com/pelletier/go-toml/v2 v2.1.0 // indirect
github.com/rogpeppe/go-internal v1.11.0 // indirect
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
R api/key.go => internal/api/key.go +0 -0
R components/adminpartials.templ => internal/components/adminpartials.templ +1 -1
@@ 1,6 1,6 @@
package components
-import "git.src.quest/~skye/felu-ddns/db"
+import "git.src.quest/~skye/felu-ddns/internal/db"
import "strconv"
templ AdminPartialsUsersList(users []db.User) {
R components/adminpartials_templ.go => internal/components/adminpartials_templ.go +1 -1
@@ 9,7 9,7 @@ import "context"
import "io"
import "bytes"
-import "git.src.quest/~skye/felu-ddns/db"
+import "git.src.quest/~skye/felu-ddns/internal/db"
import "strconv"
func AdminPartialsUsersList(users []db.User) templ.Component {
R components/base.templ => internal/components/base.templ +1 -1
@@ 1,6 1,6 @@
package components
-import "git.src.quest/~skye/felu-ddns/config"
+import "git.src.quest/~skye/felu-ddns/internal/config"
func serviceName() string {
return config.FeluConfig.ServiceName
R components/base_templ.go => internal/components/base_templ.go +1 -1
@@ 9,7 9,7 @@ import "context"
import "io"
import "bytes"
-import "git.src.quest/~skye/felu-ddns/config"
+import "git.src.quest/~skye/felu-ddns/internal/config"
func serviceName() string {
return config.FeluConfig.ServiceName
R components/index.templ => internal/components/index.templ +0 -0
R components/index_templ.go => internal/components/index_templ.go +0 -0
R components/login.templ => internal/components/login.templ +0 -0
R components/login_templ.go => internal/components/login_templ.go +0 -0
R components/manage.templ => internal/components/manage.templ +1 -1
@@ 1,6 1,6 @@
package components
-import "git.src.quest/~skye/felu-ddns/config"
+import "git.src.quest/~skye/felu-ddns/internal/config"
func getDomainPattern() string {
return config.FeluConfig.DNSPattern
R components/manage_templ.go => internal/components/manage_templ.go +1 -1
@@ 9,7 9,7 @@ import "context"
import "io"
import "bytes"
-import "git.src.quest/~skye/felu-ddns/config"
+import "git.src.quest/~skye/felu-ddns/internal/config"
func getDomainPattern() string {
return config.FeluConfig.DNSPattern
R components/manageadmin.templ => internal/components/manageadmin.templ +0 -0
R components/manageadmin_templ.go => internal/components/manageadmin_templ.go +0 -0
R components/managepartials.templ => internal/components/managepartials.templ +1 -1
@@ 1,6 1,6 @@
package components
-import "git.src.quest/~skye/felu-ddns/db"
+import "git.src.quest/~skye/felu-ddns/internal/db"
import "fmt"
templ ManagePartialDomains(domains []db.Domain) {
R components/managepartials_templ.go => internal/components/managepartials_templ.go +1 -1
@@ 9,7 9,7 @@ import "context"
import "io"
import "bytes"
-import "git.src.quest/~skye/felu-ddns/db"
+import "git.src.quest/~skye/felu-ddns/internal/db"
import "fmt"
func ManagePartialDomains(domains []db.Domain) templ.Component {
R config/config.go => internal/config/config.go +0 -0
R db/db.go => internal/db/db.go +1 -1
@@ 9,7 9,7 @@ package db
import (
"database/sql"
- "git.src.quest/~skye/felu-ddns/config"
+ "git.src.quest/~skye/felu-ddns/internal/config"
_ "github.com/mattn/go-sqlite3"
)
R db/domains.go => internal/db/domains.go +1 -1
@@ 7,7 7,7 @@
package db
import (
- "git.src.quest/~skye/felu-ddns/api"
+ "git.src.quest/~skye/felu-ddns/internal/api"
"github.com/oklog/ulid/v2"
)
R db/migrations.go => internal/db/migrations.go +0 -0
R db/users.go => internal/db/users.go +0 -0
R dns/handle.go => internal/dns/handle.go +0 -0
R dns/query.go => internal/dns/query.go +0 -0
R dns/server.go => internal/dns/server.go +1 -1
@@ 7,7 7,7 @@
package dns
import (
- "git.src.quest/~skye/felu-ddns/config"
+ "git.src.quest/~skye/felu-ddns/internal/config"
"github.com/miekg/dns"
)
R handlers/admin.go => internal/handlers/admin.go +1 -1
@@ 9,7 9,7 @@ package handlers
import (
"net/http"
- "git.src.quest/~skye/felu-ddns/components"
+ "git.src.quest/~skye/felu-ddns/internal/components"
"github.com/gin-gonic/gin"
)
R handlers/adminpartials.go => internal/handlers/adminpartials.go +2 -2
@@ 9,8 9,8 @@ package handlers
import (
"net/http"
- "git.src.quest/~skye/felu-ddns/components"
- "git.src.quest/~skye/felu-ddns/db"
+ "git.src.quest/~skye/felu-ddns/internal/components"
+ "git.src.quest/~skye/felu-ddns/internal/db"
"github.com/gin-gonic/gin"
)
R handlers/login.go => internal/handlers/login.go +1 -1
@@ 10,7 10,7 @@ import (
"log"
"net/http"
- "git.src.quest/~skye/felu-ddns/db"
+ "git.src.quest/~skye/felu-ddns/internal/db"
"github.com/alexedwards/scs/v2"
"github.com/gin-gonic/gin"
)
R handlers/managedomains.go => internal/handlers/managedomains.go +1 -1
@@ 11,7 11,7 @@ import (
"net"
"net/http"
- "git.src.quest/~skye/felu-ddns/db"
+ "git.src.quest/~skye/felu-ddns/internal/db"
"github.com/gin-gonic/gin"
)
R handlers/managepartials.go => internal/handlers/managepartials.go +2 -2
@@ 9,8 9,8 @@ package handlers
import (
"net/http"
- "git.src.quest/~skye/felu-ddns/components"
- "git.src.quest/~skye/felu-ddns/db"
+ "git.src.quest/~skye/felu-ddns/internal/components"
+ "git.src.quest/~skye/felu-ddns/internal/db"
"github.com/gin-gonic/gin"
)
R handlers/users.go => internal/handlers/users.go +1 -1
@@ 10,7 10,7 @@ import (
"log"
"net/http"
- "git.src.quest/~skye/felu-ddns/db"
+ "git.src.quest/~skye/felu-ddns/internal/db"
"github.com/gin-gonic/gin"
)
R middlewares/admin.go => internal/middlewares/admin.go +1 -1
@@ 9,7 9,7 @@ package middlewares
import (
"net/http"
- "git.src.quest/~skye/felu-ddns/db"
+ "git.src.quest/~skye/felu-ddns/internal/db"
"github.com/gin-gonic/gin"
)
R middlewares/auth.go => internal/middlewares/auth.go +0 -0
R renderer.go => internal/renderer/renderer.go +1 -1
@@ 4,7 4,7 @@
* This file is licensed under AGPL-3.0-or-later, see NOTICE and LICENSE for
* more information.
*/
-package main
+package renderer
import (
"context"