mirror of
https://github.com/WiiLink24/wfc-server.git
synced 2026-08-24 17:44:03 -05:00
Merge branch 'WiiLink24:main' into main
This commit is contained in:
@@ -10,8 +10,6 @@ import (
|
||||
)
|
||||
|
||||
func HandleGroups(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
|
||||
u, err := url.Parse(r.URL.String())
|
||||
if err != nil {
|
||||
w.WriteHeader(http.StatusBadRequest)
|
||||
@@ -47,12 +45,18 @@ func HandleGroups(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
}
|
||||
|
||||
jsonData, err := json.Marshal(groups)
|
||||
if err != nil {
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
return
|
||||
var jsonData []byte
|
||||
if len(groups) == 0 {
|
||||
jsonData, _ = json.Marshal([]string{})
|
||||
} else {
|
||||
jsonData, err = json.Marshal(groups)
|
||||
if err != nil {
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.Header().Set("Access-Control-Allow-Origin", "*")
|
||||
w.Header().Set("Content-Length", strconv.Itoa(len(jsonData)))
|
||||
w.Write(jsonData)
|
||||
|
||||
@@ -16,8 +16,6 @@ type Stats struct {
|
||||
}
|
||||
|
||||
func HandleStats(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
|
||||
u, err := url.Parse(r.URL.String())
|
||||
if err != nil {
|
||||
w.WriteHeader(http.StatusBadRequest)
|
||||
@@ -85,6 +83,7 @@ func HandleStats(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.Header().Set("Access-Control-Allow-Origin", "*")
|
||||
w.Header().Set("Content-Length", strconv.Itoa(len(jsonData)))
|
||||
w.Write(jsonData)
|
||||
|
||||
14
nas/https.go
14
nas/https.go
@@ -150,6 +150,13 @@ func startHTTPSProxy(config common.Config) {
|
||||
|
||||
// handleWiiTLS handles the TLS request from the Wii. It may call handleRealTLS if the request is from a modern web browser.
|
||||
func handleWiiTLS(moduleName string, rawConn net.Conn, nasAddr string, privKeyPath string, certsPath string, serverCertsRecord []byte, certLen uint32, rsaKey *rsa.PrivateKey) {
|
||||
// Recover from panics
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
logging.Error(moduleName, "Panic:", r)
|
||||
}
|
||||
}()
|
||||
|
||||
conn := newBufferedConn(rawConn)
|
||||
|
||||
defer conn.Close()
|
||||
@@ -456,6 +463,13 @@ func handleWiiTLS(moduleName string, rawConn net.Conn, nasAddr string, privKeyPa
|
||||
|
||||
// handleRealTLS handles the TLS request legitimately using crypto/tls
|
||||
func handleRealTLS(moduleName string, conn net.Conn, nasAddr string, privKeyPath string, certsPath string) {
|
||||
// Recover from panics
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
logging.Error(moduleName, "Panic:", r)
|
||||
}
|
||||
}()
|
||||
|
||||
// Read server key and certs
|
||||
// TODO: Cache this
|
||||
serverKey, err := os.ReadFile(privKeyPath)
|
||||
|
||||
Reference in New Issue
Block a user