Simplified tls keys
This commit is contained in:
@@ -26,27 +26,12 @@ func webserver() {
|
||||
quitChan <- "web arg"
|
||||
return
|
||||
}
|
||||
http.DefaultTransport.(*http.Transport).TLSClientConfig = &tls.Config{InsecureSkipVerify: true}
|
||||
http.Handle("/SWAssistant/", swaHandler{})
|
||||
http.Handle("/", http.FileServer(http.Dir(path)))
|
||||
http.Handle("/SWAssistant/", swaHandler{})
|
||||
http.Handle("/CDR/", cdrHandler{})
|
||||
http.Handle("rpg.darkstorm.tech/", sup{})
|
||||
http.DefaultTransport.(*http.Transport).TLSClientConfig = &tls.Config{InsecureSkipVerify: true}
|
||||
tlsConf := &tls.Config{
|
||||
InsecureSkipVerify: true,
|
||||
}
|
||||
cert, err := tls.LoadX509KeyPair(keyPath+"/cert.pem", keyPath+"/key.pem")
|
||||
if err != nil {
|
||||
log.Println("Error while serving website:", err)
|
||||
quitChan <- "web err"
|
||||
return
|
||||
}
|
||||
tlsConf.Certificates = append(tlsConf.Certificates, cert)
|
||||
serve := http.Server{
|
||||
Addr: ":443",
|
||||
TLSConfig: tlsConf,
|
||||
}
|
||||
err = serve.ListenAndServeTLS("", "")
|
||||
// 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)
|
||||
quitChan <- "web err"
|
||||
}
|
||||
@@ -65,7 +50,7 @@ func (s sup) ServeHTTP(writer http.ResponseWriter, req *http.Request) {
|
||||
|
||||
type swaHandler struct{}
|
||||
|
||||
func (s swaHandler) ServeHTTP(writer http.ResponseWriter, req *http.Request) {
|
||||
func (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 {
|
||||
http.FileServer(http.Dir(flag.Arg(0))).ServeHTTP(writer, req)
|
||||
} else {
|
||||
@@ -73,3 +58,14 @@ func (s swaHandler) ServeHTTP(writer http.ResponseWriter, req *http.Request) {
|
||||
// log.Println("https://darkstorm.tech/SWAssistant/#" + strings.TrimPrefix(req.URL.EscapedPath(), "/SWAssistant"))
|
||||
}
|
||||
}
|
||||
|
||||
type cdrHandler struct{}
|
||||
|
||||
func (cdrHandler) 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 {
|
||||
http.FileServer(http.Dir(flag.Arg(0))).ServeHTTP(writer, req)
|
||||
} else {
|
||||
http.Redirect(writer, req, "https://darkstorm.tech/CDR/#"+strings.TrimPrefix(req.URL.EscapedPath(), "/CDR"), http.StatusFound)
|
||||
// log.Println("https://darkstorm.tech/SWAssistant/#" + strings.TrimPrefix(req.URL.EscapedPath(), "/SWAssistant"))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user