fix: disabling tcp webserver sockets, fixes #434

This commit is contained in:
Soner Sayakci 2022-12-06 11:55:33 +00:00
parent 9f38246fe2
commit 0a2cba647c
No known key found for this signature in database
2 changed files with 9 additions and 7 deletions

View File

@ -4,8 +4,6 @@ import (
"encoding/json" "encoding/json"
"flag" "flag"
"fmt" "fmt"
"github.com/muety/wakapi/utils"
"github.com/robfig/cron/v3"
"io/ioutil" "io/ioutil"
"net/http" "net/http"
"os" "os"
@ -14,6 +12,9 @@ import (
"strings" "strings"
"time" "time"
"github.com/muety/wakapi/utils"
"github.com/robfig/cron/v3"
"github.com/emvi/logbuch" "github.com/emvi/logbuch"
"github.com/gorilla/securecookie" "github.com/gorilla/securecookie"
"github.com/jinzhu/configor" "github.com/jinzhu/configor"
@ -451,7 +452,7 @@ func Load(version string) *Config {
} }
// some validation checks // some validation checks
if config.Server.ListenIpV4 == "" && config.Server.ListenIpV6 == "" && config.Server.ListenSocket == "" { if config.Server.ListenIpV4 == "-" && config.Server.ListenIpV6 == "-" && config.Server.ListenSocket == "" {
logbuch.Fatal("either of listen_ipv4 or listen_ipv6 or listen_socket must be set") logbuch.Fatal("either of listen_ipv4 or listen_ipv6 or listen_socket must be set")
} }
if config.Db.MaxConn <= 0 { if config.Db.MaxConn <= 0 {

View File

@ -2,7 +2,6 @@ package main
import ( import (
"embed" "embed"
"github.com/muety/wakapi/static/docs"
"io/fs" "io/fs"
"log" "log"
"net" "net"
@ -11,11 +10,13 @@ import (
"strconv" "strconv"
"time" "time"
"github.com/muety/wakapi/static/docs"
"github.com/emvi/logbuch" "github.com/emvi/logbuch"
"github.com/gorilla/handlers" "github.com/gorilla/handlers"
"github.com/gorilla/mux" "github.com/gorilla/mux"
"github.com/lpar/gzipped/v2" "github.com/lpar/gzipped/v2"
"github.com/swaggo/http-swagger" httpSwagger "github.com/swaggo/http-swagger"
conf "github.com/muety/wakapi/config" conf "github.com/muety/wakapi/config"
"github.com/muety/wakapi/middlewares" "github.com/muety/wakapi/middlewares"
@ -298,7 +299,7 @@ func listen(handler http.Handler) {
var s4, s6, sSocket *http.Server var s4, s6, sSocket *http.Server
// IPv4 // IPv4
if config.Server.ListenIpV4 != "" { if config.Server.ListenIpV4 != "-" {
bindString4 := config.Server.ListenIpV4 + ":" + strconv.Itoa(config.Server.Port) bindString4 := config.Server.ListenIpV4 + ":" + strconv.Itoa(config.Server.Port)
s4 = &http.Server{ s4 = &http.Server{
Handler: handler, Handler: handler,
@ -309,7 +310,7 @@ func listen(handler http.Handler) {
} }
// IPv6 // IPv6
if config.Server.ListenIpV6 != "" { if config.Server.ListenIpV6 != "-" {
bindString6 := "[" + config.Server.ListenIpV6 + "]:" + strconv.Itoa(config.Server.Port) bindString6 := "[" + config.Server.ListenIpV6 + "]:" + strconv.Itoa(config.Server.Port)
s6 = &http.Server{ s6 = &http.Server{
Handler: handler, Handler: handler,