Fix footer date year & error path
This commit is contained in:
parent
859e144797
commit
502a87a551
7 changed files with 80 additions and 16 deletions
17
Makefile
17
Makefile
|
@ -3,6 +3,7 @@ DIST_DIR ?= dist/
|
|||
GOOS ?= linux
|
||||
ARCH ?= $(shell uname -m)
|
||||
BUILDINFOSDET ?=
|
||||
GOARCH = $(shell echo $(ARCH) | sed 's/x86_64/amd64/g')
|
||||
|
||||
SOFT_NAME := epee_service
|
||||
SOFT_VERSION := $(shell git describe --tags $(git rev-list --tags --max-count=1))
|
||||
|
@ -13,7 +14,7 @@ URL := https://git.gnous.eu/enpls/epee-service
|
|||
DESCRIPTION := EnPLS Epee (Enpls Proxy EnginE) Utility Service
|
||||
BUILDINFOS := ($(shell date +%FT%T%z)$(BUILDINFOSDET))
|
||||
LDFLAGS := '-X main.version=$(SOFT_VERSION) -X main.buildinfos=$(BUILDINFOS)'
|
||||
|
||||
GOARCH := amd64
|
||||
OUTPUT_SOFT := $(DIST_DIR)epee-$(SOFT_VERSION)-$(GOOS)-$(ARCH)$(EXTENSION)
|
||||
|
||||
.PHONY: vet
|
||||
|
@ -34,7 +35,8 @@ clean:
|
|||
|
||||
.PHONY: build
|
||||
build: prepare
|
||||
go build -ldflags $(LDFLAGS) -o $(OUTPUT_SOFT)
|
||||
@echo Building binary for $(GOOS)/$(GOARCH)
|
||||
env GOOS=$(GOOS) GOARCH=$(GOARCH) go build -ldflags $(LDFLAGS) -o $(OUTPUT_SOFT)
|
||||
|
||||
.PHONY: package-deb
|
||||
package-deb: prepare
|
||||
|
@ -44,10 +46,8 @@ package-deb: prepare
|
|||
--architecture $(ARCH) \
|
||||
--license "$(LICENSE)" \
|
||||
--package $(DIST_DIR) \
|
||||
$(OUTPUT_SOFT)=/usr/bin/frite-web \
|
||||
extra/links.txt.example=/etc/frite/links.txt \
|
||||
extra/frite-web.service=/usr/lib/systemd/system/frite-web.service
|
||||
|
||||
$(OUTPUT_SOFT)=/usr/bin/epee-service \
|
||||
extra/epee.service=/usr/lib/systemd/system/epee.service
|
||||
.PHONY: package-rpm
|
||||
package-rpm: prepare
|
||||
fpm -s dir -t rpm -n $(SOFT_NAME) -v $(VERSION_PKG) \
|
||||
|
@ -56,6 +56,5 @@ package-rpm: prepare
|
|||
--architecture $(ARCH) \
|
||||
--license "$(LICENSE) "\
|
||||
--package $(DIST_DIR) \
|
||||
$(OUTPUT_SOFT)=/usr/bin/frite-web \
|
||||
extra/links.txt.example=/etc/frite/links.txt \
|
||||
extra/frite-web.service=/usr/lib/systemd/system/frite-web.service
|
||||
$(OUTPUT_SOFT)=/usr/bin/epee-service \
|
||||
extra/epee.service=/usr/lib/systemd/system/epee.service
|
32
extra/epee.service
Normal file
32
extra/epee.service
Normal file
|
@ -0,0 +1,32 @@
|
|||
[Unit]
|
||||
Description=Enpls Proxy EnginE Utility Service
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
; User=epee
|
||||
; Group=epee
|
||||
WorkingDirectory=/etc/epee/
|
||||
ExecStart=/usr/bin/epee-service
|
||||
|
||||
NoNewPrivileges=yes
|
||||
ProtectSystem=strict
|
||||
ProtectHome=true
|
||||
RestrictNamespaces=true
|
||||
PrivateTmp=true
|
||||
PrivateDevices=true
|
||||
ProtectClock=true
|
||||
ProtectControlGroups=true
|
||||
ProtectKernelTunables=true
|
||||
ProtectKernelLogs=true
|
||||
ProtectKernelModules=true
|
||||
LockPersonality=true
|
||||
RestrictSUIDSGID=true
|
||||
RemoveIPC=true
|
||||
RestrictRealtime=true
|
||||
SystemCallFilter=@system-service
|
||||
SystemCallArchitectures=native
|
||||
MemoryDenyWriteExecute=true
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
5
go.mod
5
go.mod
|
@ -1,3 +1,8 @@
|
|||
module git.gnous.eu/enpls/epee-service
|
||||
|
||||
go 1.19
|
||||
|
||||
require (
|
||||
github.com/sirupsen/logrus v1.9.0 // indirect
|
||||
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8 // indirect
|
||||
)
|
||||
|
|
11
go.sum
Normal file
11
go.sum
Normal file
|
@ -0,0 +1,11 @@
|
|||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/sirupsen/logrus v1.9.0 h1:trlNQbNUG3OdDrDil03MCb1H2o9nJ1x4/5LYw7byDE0=
|
||||
github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8 h1:0A+M6Uqn+Eje4kHMK80dtF3JCXC4ykBgQG4Fe06QRhQ=
|
||||
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
1
logging.go
Normal file
1
logging.go
Normal file
|
@ -0,0 +1 @@
|
|||
package main
|
23
main.go
23
main.go
|
@ -5,8 +5,9 @@ import (
|
|||
"encoding/json"
|
||||
"fmt"
|
||||
"html/template"
|
||||
"log"
|
||||
"net/http"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
//go:embed static
|
||||
|
@ -24,10 +25,14 @@ type Error struct {
|
|||
func main() {
|
||||
port := "5900"
|
||||
|
||||
http.Handle("/static/", http.FileServer(http.FS(staticFS)))
|
||||
http.Handle("/cdn-cgi/static/", http.StripPrefix("/cdn-cgi/", http.FileServer(http.FS(staticFS))))
|
||||
http.HandleFunc("/cdn-cgi/trace", headersHandler)
|
||||
http.HandleFunc("/", errorHandler)
|
||||
|
||||
log.Printf("Listening on :%s...", port)
|
||||
log.WithFields(log.Fields{
|
||||
"port": port,
|
||||
}).Info("Started webserver listening")
|
||||
|
||||
err := http.ListenAndServe(fmt.Sprintf(":%s", port), nil)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
|
@ -51,8 +56,8 @@ func errorHandler(w http.ResponseWriter, r *http.Request) {
|
|||
}
|
||||
errorData := errors[errorCode]
|
||||
if errorData.Title == "" {
|
||||
errorData.Title = "Error"
|
||||
errorData.Message = "An error occurred."
|
||||
errorData.Title = "Oops 🤓"
|
||||
errorData.Message = "It seems like something went wrong. Please try again later."
|
||||
}
|
||||
|
||||
// Render error page
|
||||
|
@ -75,3 +80,11 @@ func generateInternalServerError(w http.ResponseWriter, err error) {
|
|||
w.WriteHeader(http.StatusInternalServerError)
|
||||
w.Write([]byte(`{"error": "Internal Server Error"}`))
|
||||
}
|
||||
|
||||
func headersHandler(w http.ResponseWriter, r *http.Request) {
|
||||
for name, headers := range r.Header {
|
||||
for _, h := range headers {
|
||||
fmt.Fprintf(w, "%v: %v\n", name, h)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>{{.Title}}</title>
|
||||
<link rel="stylesheet" href="/static/main.css">
|
||||
<link rel="stylesheet" href="/cdn-cgi/static/main.css">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
@ -21,9 +21,12 @@
|
|||
href="mailto:mael@enpls.org">contact us</a>.
|
||||
</div>
|
||||
<div class="footer">
|
||||
<p>© Copyright {{.Year}} EnPLS Network - <a href="https://enpls.org">enpls.org</a> </p>
|
||||
<p>© Copyright <span id="year"></span> EnPLS Network - <a href="https://enpls.org">enpls.org</a> </p>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
document.getElementById("year").innerHTML = new Date().getFullYear();
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
Loading…
Reference in a new issue