mirror of
https://github.com/Threnklyn/wg-ui.git
synced 2026-06-07 14:03:33 +02:00
Add some static assets
This commit is contained in:
@@ -1 +1,2 @@
|
|||||||
wireguard-ui
|
wireguard-ui
|
||||||
|
bindata.go
|
||||||
|
|||||||
+4
-1
@@ -1,10 +1,13 @@
|
|||||||
FROM golang:1.12 AS build
|
FROM golang:1.12 AS build
|
||||||
WORKDIR /build
|
WORKDIR /build
|
||||||
|
RUN go get -u github.com/go-bindata/go-bindata/... &&\
|
||||||
|
go get github.com/elazarl/go-bindata-assetfs/...
|
||||||
COPY go.mod .
|
COPY go.mod .
|
||||||
COPY go.sum .
|
COPY go.sum .
|
||||||
RUN go mod download
|
RUN go mod download
|
||||||
COPY . .
|
COPY . .
|
||||||
RUN go install .
|
RUN go-bindata-assetfs -prefix html html html/img &&\
|
||||||
|
go install .
|
||||||
|
|
||||||
FROM gcr.io/distroless/base:latest
|
FROM gcr.io/distroless/base:latest
|
||||||
COPY --from=build /go/bin/wireguard-ui /
|
COPY --from=build /go/bin/wireguard-ui /
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ require (
|
|||||||
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc // indirect
|
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc // indirect
|
||||||
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf // indirect
|
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf // indirect
|
||||||
github.com/dgrijalva/jwt-go v3.2.0+incompatible
|
github.com/dgrijalva/jwt-go v3.2.0+incompatible
|
||||||
|
github.com/elazarl/go-bindata-assetfs v1.0.0
|
||||||
github.com/google/nftables v0.0.0-20190430150743-07c974e3643d
|
github.com/google/nftables v0.0.0-20190430150743-07c974e3643d
|
||||||
github.com/julienschmidt/httprouter v1.2.0
|
github.com/julienschmidt/httprouter v1.2.0
|
||||||
github.com/koneu/natend v0.0.0-20150829182554-ec0926ea948d // indirect
|
github.com/koneu/natend v0.0.0-20150829182554-ec0926ea948d // indirect
|
||||||
|
|||||||
@@ -5,6 +5,8 @@ github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRF
|
|||||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/dgrijalva/jwt-go v3.2.0+incompatible h1:7qlOGliEKZXTDg6OTjfoBKDXWrumCAMpl/TFQ4/5kLM=
|
github.com/dgrijalva/jwt-go v3.2.0+incompatible h1:7qlOGliEKZXTDg6OTjfoBKDXWrumCAMpl/TFQ4/5kLM=
|
||||||
github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
|
github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
|
||||||
|
github.com/elazarl/go-bindata-assetfs v1.0.0 h1:G/bYguwHIzWq9ZoyUQqrjTmJbbYn3j3CKKpKinvZLFk=
|
||||||
|
github.com/elazarl/go-bindata-assetfs v1.0.0/go.mod h1:v+YaWX3bdea5J/mo8dSETolEo7R71Vk1u8bnjau5yw4=
|
||||||
github.com/google/go-cmp v0.2.0 h1:+dTQ8DZQJz0Mb/HjFlkptS1FeQ4cWSnN941F8aEG4SQ=
|
github.com/google/go-cmp v0.2.0 h1:+dTQ8DZQJz0Mb/HjFlkptS1FeQ4cWSnN941F8aEG4SQ=
|
||||||
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
|
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
|
||||||
github.com/google/nftables v0.0.0-20190430150743-07c974e3643d h1:TC4HtISCtWOTUVPQmq4CAqe0+8R2fvnkJlQn47ep2hI=
|
github.com/google/nftables v0.0.0-20190430150743-07c974e3643d h1:TC4HtISCtWOTUVPQmq4CAqe0+8R2fvnkJlQn47ep2hI=
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 17 KiB |
@@ -0,0 +1,12 @@
|
|||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>Wireguard</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>Wireguard UI</h1>
|
||||||
|
<img src="/img/wireguard.png"/>
|
||||||
|
<p>
|
||||||
|
hello, ui
|
||||||
|
</p>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -13,6 +13,7 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/dgrijalva/jwt-go"
|
"github.com/dgrijalva/jwt-go"
|
||||||
|
"github.com/elazarl/go-bindata-assetfs"
|
||||||
"github.com/google/nftables"
|
"github.com/google/nftables"
|
||||||
"github.com/google/nftables/expr"
|
"github.com/google/nftables/expr"
|
||||||
"github.com/julienschmidt/httprouter"
|
"github.com/julienschmidt/httprouter"
|
||||||
@@ -43,6 +44,7 @@ type Server struct {
|
|||||||
Config *ServerConfig
|
Config *ServerConfig
|
||||||
ipAddr net.IP
|
ipAddr net.IP
|
||||||
clientIPRange *net.IPNet
|
clientIPRange *net.IPNet
|
||||||
|
assets http.Handler
|
||||||
}
|
}
|
||||||
|
|
||||||
type WgLink struct {
|
type WgLink struct {
|
||||||
@@ -82,12 +84,14 @@ func NewServer() *Server {
|
|||||||
config := NewServerConfig(cfgPath)
|
config := NewServerConfig(cfgPath)
|
||||||
|
|
||||||
log.Debug("Configuration loaded with public key: ", config.PublicKey)
|
log.Debug("Configuration loaded with public key: ", config.PublicKey)
|
||||||
|
assets := http.FileServer(&assetfs.AssetFS{Asset: Asset, AssetDir: AssetDir, AssetInfo: AssetInfo, Prefix: ""})
|
||||||
|
|
||||||
s := Server{
|
s := Server{
|
||||||
serverConfigPath: cfgPath,
|
serverConfigPath: cfgPath,
|
||||||
Config: config,
|
Config: config,
|
||||||
ipAddr: ipAddr,
|
ipAddr: ipAddr,
|
||||||
clientIPRange: ipNet,
|
clientIPRange: ipNet,
|
||||||
|
assets: assets,
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Debug("Server initialized: ", *dataDir)
|
log.Debug("Server initialized: ", *dataDir)
|
||||||
@@ -271,6 +275,7 @@ func (s *Server) Start() error {
|
|||||||
|
|
||||||
router := httprouter.New()
|
router := httprouter.New()
|
||||||
router.GET("/", s.Index)
|
router.GET("/", s.Index)
|
||||||
|
router.GET("/img/*filepath", s.Index)
|
||||||
router.GET("/api/v1/users/:user/devices/:device", s.withAuth(s.GetDevice))
|
router.GET("/api/v1/users/:user/devices/:device", s.withAuth(s.GetDevice))
|
||||||
router.PUT("/api/v1/users/:user/devices/:device", s.withAuth(s.EditDevice))
|
router.PUT("/api/v1/users/:user/devices/:device", s.withAuth(s.EditDevice))
|
||||||
router.DELETE("/api/v1/users/:user/devices/:device", s.withAuth(s.DeleteDevice))
|
router.DELETE("/api/v1/users/:user/devices/:device", s.withAuth(s.DeleteDevice))
|
||||||
@@ -339,7 +344,7 @@ func (s *Server) withAuth(handler httprouter.Handle) httprouter.Handle {
|
|||||||
|
|
||||||
func (s *Server) Index(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
|
func (s *Server) Index(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
|
||||||
log.Debug("Index")
|
log.Debug("Index")
|
||||||
w.Write([]byte("Hello World"))
|
s.assets.ServeHTTP(w, r)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Server) GetDevices(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
|
func (s *Server) GetDevices(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
|
||||||
|
|||||||
Reference in New Issue
Block a user