Browse Source

auto update script executed

Toby Chui 1 year ago
parent
commit
ad109570b8

+ 1 - 1
main.go

@@ -37,7 +37,7 @@ var (
 	name        = "Zoraxy"
 	version     = "2.2"
 	nodeUUID    = "generic"
-	development = false //Set this to false to use embedded web fs
+	development = true //Set this to false to use embedded web fs
 
 	/*
 		Binary Embedding File System

+ 0 - 2
mod/dynamicproxy/Server.go

@@ -1,7 +1,6 @@
 package dynamicproxy
 
 import (
-	"fmt"
 	"net/http"
 	"os"
 	"strings"
@@ -75,7 +74,6 @@ func (h *ProxyHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
 
 		if potentialProxtEndpoint != nil {
 			//Missing tailing slash. Redirect to target proxy endpoint
-			fmt.Println("Missing back slash. Redirecting to " + r.RequestURI + "/")
 			http.Redirect(w, r, r.RequestURI+"/", http.StatusTemporaryRedirect)
 			//h.proxyRequest(w, r, potentialProxtEndpoint)
 		} else {

+ 5 - 4
mod/dynamicproxy/dpcore/dpcore.go

@@ -2,7 +2,6 @@ package dpcore
 
 import (
 	"errors"
-	"fmt"
 	"io"
 	"log"
 	"net"
@@ -334,9 +333,11 @@ func (p *ReverseProxy) ProxyHTTP(rw http.ResponseWriter, req *http.Request, rrr
 
 	//Custom header rewriter functions
 	if res.Header.Get("Location") != "" {
-		fmt.Println(">>> REQ", req)
-		fmt.Println(">>> OUTR", outreq)
-		fmt.Println(">>> RESP", res)
+		/*
+			fmt.Println(">>> REQ", req)
+			fmt.Println(">>> OUTR", outreq)
+			fmt.Println(">>> RESP", res)
+		*/
 		locationRewrite := res.Header.Get("Location")
 		originLocation := res.Header.Get("Location")
 		res.Header.Set("zr-origin-location", originLocation)

+ 2 - 3
mod/dynamicproxy/proxyRequestHandler.go

@@ -95,8 +95,7 @@ func (h *ProxyHandler) subdomainRequest(w http.ResponseWriter, r *http.Request,
 
 func (h *ProxyHandler) proxyRequest(w http.ResponseWriter, r *http.Request, target *ProxyEndpoint) {
 	rewriteURL := h.Parent.rewriteURL(target.Root, r.RequestURI)
-	var err error
-	r.URL, err = url.Parse(rewriteURL)
+	r.URL, _ = url.Parse(rewriteURL)
 
 	r.Header.Set("X-Forwarded-Host", r.Host)
 	if r.Header["Upgrade"] != nil && strings.ToLower(r.Header["Upgrade"][0]) == "websocket" {
@@ -118,7 +117,7 @@ func (h *ProxyHandler) proxyRequest(w http.ResponseWriter, r *http.Request, targ
 
 	originalHostHeader := r.Host
 	r.Host = r.URL.Host
-	err = target.Proxy.ServeHTTP(w, r, &dpcore.ResponseRewriteRuleSet{
+	err := target.Proxy.ServeHTTP(w, r, &dpcore.ResponseRewriteRuleSet{
 		ProxyDomain:  target.Domain,
 		OriginalHost: originalHostHeader,
 	})

+ 6 - 6
mod/tlscert/tlscert.go

@@ -23,14 +23,14 @@ type Manager struct {
 //go:embed localhost.crt localhost.key
 var buildinCertStore embed.FS
 
-func NewManager(certStore string) (*Manager, error) {
+func NewManager(certStore string, verbal bool) (*Manager, error) {
 	if !utils.FileExists(certStore) {
 		os.MkdirAll(certStore, 0775)
 	}
 
 	thisManager := Manager{
 		CertStore: certStore,
-		verbal:    true,
+		verbal:    verbal,
 	}
 
 	return &thisManager, nil
@@ -115,17 +115,17 @@ func (m *Manager) GetCert(helloInfo *tls.ClientHelloInfo) (*tls.Certificate, err
 	return &cer, nil
 }
 
-//Check if both the default cert public key and private key exists
+// Check if both the default cert public key and private key exists
 func (m *Manager) DefaultCertExists() bool {
 	return utils.FileExists(filepath.Join(m.CertStore, "default.crt")) && utils.FileExists(filepath.Join(m.CertStore, "default.key"))
 }
 
-//Check if the default cert exists returning seperate results for pubkey and prikey
+// Check if the default cert exists returning seperate results for pubkey and prikey
 func (m *Manager) DefaultCertExistsSep() (bool, bool) {
 	return utils.FileExists(filepath.Join(m.CertStore, "default.crt")), utils.FileExists(filepath.Join(m.CertStore, "default.key"))
 }
 
-//Delete the cert if exists
+// Delete the cert if exists
 func (m *Manager) RemoveCert(domain string) error {
 	pubKey := filepath.Join(m.CertStore, domain+".crt")
 	priKey := filepath.Join(m.CertStore, domain+".key")
@@ -146,7 +146,7 @@ func (m *Manager) RemoveCert(domain string) error {
 	return nil
 }
 
-//Check if the given file is a valid TLS file
+// Check if the given file is a valid TLS file
 func IsValidTLSFile(file io.Reader) bool {
 	// Read the contents of the uploaded file
 	contents, err := io.ReadAll(file)

+ 1 - 1
start.go

@@ -58,7 +58,7 @@ func startupSequence() {
 	})
 
 	//Create a TLS certificate manager
-	tlsCertManager, err = tlscert.NewManager("./certs")
+	tlsCertManager, err = tlscert.NewManager("./certs", !development)
 	if err != nil {
 		panic(err)
 	}