rpg
This commit is contained in:
@@ -2,8 +2,11 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"flag"
|
"flag"
|
||||||
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"net/http/httputil"
|
||||||
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
"strings"
|
"strings"
|
||||||
@@ -24,14 +27,27 @@ func webserver() {
|
|||||||
}
|
}
|
||||||
http.Handle("/SWAssistant/", swaHandler{})
|
http.Handle("/SWAssistant/", swaHandler{})
|
||||||
http.Handle("/", http.FileServer(http.Dir(path)))
|
http.Handle("/", http.FileServer(http.Dir(path)))
|
||||||
|
http.Handle("rpg.darkstorm.tech/", sup{})
|
||||||
err := http.ListenAndServeTLS(":443", keyPath+"/cert.pem", keyPath+"/key.pem", nil)
|
err := http.ListenAndServeTLS(":443", keyPath+"/cert.pem", keyPath+"/key.pem", nil)
|
||||||
log.Println("Error while serving website:", err)
|
log.Println("Error while serving website:", err)
|
||||||
quitChan <- "web err"
|
quitChan <- "web err"
|
||||||
}
|
}
|
||||||
|
|
||||||
type swaHandler struct {
|
type sup struct{}
|
||||||
|
|
||||||
|
func (s sup) ServeHTTP(writer http.ResponseWriter, req *http.Request) {
|
||||||
|
fmt.Println(req.URL)
|
||||||
|
url, err := url.Parse("http://localhost:30000")
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
http.FileServer(http.Dir(flag.Arg(0))).ServeHTTP(writer, req)
|
||||||
|
}
|
||||||
|
rvProx := httputil.NewSingleHostReverseProxy(url)
|
||||||
|
rvProx.ServeHTTP(writer, req)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type swaHandler struct{}
|
||||||
|
|
||||||
func (s swaHandler) ServeHTTP(writer http.ResponseWriter, req *http.Request) {
|
func (s swaHandler) ServeHTTP(writer http.ResponseWriter, req *http.Request) {
|
||||||
if _, err := os.Open(path.Join(flag.Arg(0) + req.URL.EscapedPath())); strings.Contains(req.URL.EscapedPath(), "#") || err == nil {
|
if _, err := os.Open(path.Join(flag.Arg(0) + req.URL.EscapedPath())); strings.Contains(req.URL.EscapedPath(), "#") || err == nil {
|
||||||
http.FileServer(http.Dir(flag.Arg(0))).ServeHTTP(writer, req)
|
http.FileServer(http.Dir(flag.Arg(0))).ServeHTTP(writer, req)
|
||||||
|
|||||||
Reference in New Issue
Block a user