This commit is contained in:
Caleb Gardner
2022-06-22 04:17:24 -05:00
parent 026a7010fc
commit d8099c4410
3 changed files with 33 additions and 4 deletions
+4 -1
View File
@@ -2,4 +2,7 @@ module github.com/CalebQ42/darkstorm-server
go 1.17
require github.com/1lann/udp-forward v0.0.0-20191015034046-6b774a53ea39
require (
github.com/1lann/udp-forward v0.0.0-20191015034046-6b774a53ea39
github.com/cssivision/reverseproxy v0.0.1
)
+2
View File
@@ -1,2 +1,4 @@
github.com/1lann/udp-forward v0.0.0-20191015034046-6b774a53ea39 h1:wAEqazqaAqb7wwijTl14KruBl7cvYytD3SkhXT9v5zs=
github.com/1lann/udp-forward v0.0.0-20191015034046-6b774a53ea39/go.mod h1:zK6NTEHRcxPf9N4gcm0WXvE8RpsJfg/a8hMSW6dAQ0c=
github.com/cssivision/reverseproxy v0.0.1 h1:IvhNE3XITZOWFhON2faKbrDeGpqa+yfessLQKSSt15U=
github.com/cssivision/reverseproxy v0.0.1/go.mod h1:+QTeWrlVNQDAiB3pnaecTCk5rh1sS3cJltUl/+L2APg=
+27 -3
View File
@@ -1,6 +1,7 @@
package main
import (
"crypto/tls"
"flag"
"fmt"
"log"
@@ -25,10 +26,34 @@ 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("rpg.darkstorm.tech/", sup{})
err := http.ListenAndServeTLS(":443", keyPath+"/cert.pem", keyPath+"/key.pem", nil)
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)
cert, err = tls.LoadX509KeyPair(keyPath+"/foundrycert.pem", keyPath+"/foundrykey.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)
log.Println("Error while serving website:", err)
quitChan <- "web err"
}
@@ -36,8 +61,7 @@ func webserver() {
type sup struct{}
func (s sup) ServeHTTP(writer http.ResponseWriter, req *http.Request) {
fmt.Println(req.URL)
url, err := url.Parse("http://localhost:30000")
url, err := url.Parse("https://localhost:30000")
if err != nil {
fmt.Println(err)
http.FileServer(http.Dir(flag.Arg(0))).ServeHTTP(writer, req)