Integrierten HTTPS-Server aktiviert und an ENV gebunden
All checks were successful
release-tag / release-image (push) Successful in 1m28s
build-binaries / build (, amd64, linux) (push) Successful in 10m5s
build-binaries / build (, arm, 7, linux) (push) Successful in 10m5s
build-binaries / build (, arm64, linux) (push) Successful in 10m3s
build-binaries / build (.exe, amd64, windows) (push) Successful in 10m6s
build-binaries / release (push) Successful in 32s
All checks were successful
release-tag / release-image (push) Successful in 1m28s
build-binaries / build (, amd64, linux) (push) Successful in 10m5s
build-binaries / build (, arm, 7, linux) (push) Successful in 10m5s
build-binaries / build (, arm64, linux) (push) Successful in 10m3s
build-binaries / build (.exe, amd64, windows) (push) Successful in 10m6s
build-binaries / release (push) Successful in 32s
This commit is contained in:
@@ -29,7 +29,11 @@ ENV EW_USERNAME=admin \
|
|||||||
EW_PASSWORD=admin \
|
EW_PASSWORD=admin \
|
||||||
EW_DB=/data/machines.json \
|
EW_DB=/data/machines.json \
|
||||||
EW_PRODUCTIVE=true \
|
EW_PRODUCTIVE=true \
|
||||||
EW_FORCEINSECURECOOKIE=false
|
EW_FORCEINSECURECOOKIE=false \
|
||||||
|
HTTP_PORT=8080 \
|
||||||
|
HTTP_TLS=false \
|
||||||
|
HTTP_TLS_CERTIFICATE=./server-cert.pem \
|
||||||
|
HTTP_TLS_PRIVATEKEY=./server-key.pem
|
||||||
|
|
||||||
|
|
||||||
ENTRYPOINT ["/bin/edgewol"]
|
ENTRYPOINT ["/bin/edgewol"]
|
26
main.go
26
main.go
@@ -41,6 +41,10 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
HTTP_PORT string = "8080"
|
||||||
|
HTTP_TLS bool = false
|
||||||
|
HTTP_TLS_PRIVATEKEY string = ""
|
||||||
|
HTTP_TLS_CERTIFICATE string = ""
|
||||||
username = GetENV("EW_USERNAME", "root")
|
username = GetENV("EW_USERNAME", "root")
|
||||||
password = GetENV("EW_PASSWORD", "root")
|
password = GetENV("EW_PASSWORD", "root")
|
||||||
productive = Enabled("EW_PRODUCTIVE", false)
|
productive = Enabled("EW_PRODUCTIVE", false)
|
||||||
@@ -191,6 +195,11 @@ func main() {
|
|||||||
dbPath = "./machines.json"
|
dbPath = "./machines.json"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
HTTP_PORT = GetENV("HTTP_PORT", "8080")
|
||||||
|
HTTP_TLS = Enabled("HTTP_TLS", true)
|
||||||
|
HTTP_TLS_CERTIFICATE = GetENV("HTTP_TLS_CERTIFICATE", "./server-cert.pem")
|
||||||
|
HTTP_TLS_PRIVATEKEY = GetENV("HTTP_TLS_PRIVATEKEY", "./server-key.pem")
|
||||||
|
|
||||||
loadMachines()
|
loadMachines()
|
||||||
|
|
||||||
// Save on SIGINT/SIGTERM.
|
// Save on SIGINT/SIGTERM.
|
||||||
@@ -315,15 +324,18 @@ func main() {
|
|||||||
http.HandleFunc("/add", addHandler)
|
http.HandleFunc("/add", addHandler)
|
||||||
http.HandleFunc("/remove", removeHandler)
|
http.HandleFunc("/remove", removeHandler)
|
||||||
|
|
||||||
addr := os.Getenv("LISTEN")
|
if HTTP_TLS {
|
||||||
if addr == "" {
|
log.Printf("WoL server listening on %s (DB: %s)", ":"+HTTP_PORT, dbPath)
|
||||||
addr = ":8080"
|
if err := http.ListenAndServeTLS(":"+HTTP_PORT, HTTP_TLS_CERTIFICATE, HTTP_TLS_PRIVATEKEY, nil); err != nil {
|
||||||
}
|
|
||||||
|
|
||||||
log.Printf("WoL server listening on %s (DB: %s)", addr, dbPath)
|
|
||||||
if err := http.ListenAndServe(addr, nil); err != nil {
|
|
||||||
log.Fatalf("http server error: %v", err)
|
log.Fatalf("http server error: %v", err)
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
log.Printf("WoL server listening on %s (DB: %s)", ":"+HTTP_PORT, dbPath)
|
||||||
|
if err := http.ListenAndServe(":"+HTTP_PORT, nil); err != nil {
|
||||||
|
log.Fatalf("http server error: %v", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ========= persistence =========
|
// ========= persistence =========
|
||||||
|
Reference in New Issue
Block a user