Ver código fonte

Fixed capital letter domain cant remove bug

Toby Chui 1 mês atrás
pai
commit
88f7f5b43c

+ 45 - 0
build/release-to-git-src.sh

@@ -0,0 +1,45 @@
+# /bin/sh
+
+# Create a dist version of the system
+cd ../
+
+# Update license before pack
+#go-licenses report imuslab.com/zoraxy > system/gomod-license.csv
+
+# Build release distribution
+#make
+
+# Create and prepare for a Github release style folder structure
+rm -rf ./build/github/src
+mkdir ./build/github
+mkdir ./build/github/src
+
+# Extract the web.tar.gz to src folder
+#tar -xvf ./dist/web.tar.gz -C ./build/github/src
+
+# Copy the mod folder and all root go files
+cp -r ./mod ./build/github/src
+cp -r ./web ./build/github/src
+cp ./*.go ./build/github/src
+
+
+# Copy other important files
+cp Makefile ./build/github/src
+cp start.sh ./build/github/src
+cp go.mod ./build/github/src
+cp go.sum ./build/github/src
+
+
+# Generate the doc folder for important docs
+cp README.md ./build/github/src
+
+# Back to the build folder
+cd ./build
+
+echo "Github Release Structure Created"
+
+echo "Moving to Github app scan path"
+
+rm -rf "D:\Github\zoraxy\src"
+
+cp -r ./github/* "D:\Github\zoraxy\src"

+ 4 - 0
def.go

@@ -87,6 +87,10 @@ var (
 	allowWebFileManager        = flag.Bool("webfm", true, "Enable web file manager for static web server root folder")
 	enableAutoUpdate           = flag.Bool("cfgupgrade", true, "Enable auto config upgrade if breaking change is detected")
 
+	/* Default Configuration Flags */
+	defaultInboundPort          = flag.Int("default_inbound_port", 443, "Default web server listening port")
+	defaultEnableInboundTraffic = flag.Bool("default_inbound_enabled", true, "If web server is enabled by default")
+
 	/* Path Configuration Flags */
 	//path_database  = flag.String("dbpath", "./sys.db", "Database path")
 	//path_conf      = flag.String("conf", "./conf", "Configuration folder path")

+ 13 - 1
mod/dynamicproxy/dpcore/dpcore.go

@@ -2,6 +2,7 @@ package dpcore
 
 import (
 	"context"
+	"crypto/tls"
 	"errors"
 	"io"
 	"log"
@@ -11,6 +12,7 @@ import (
 	"strings"
 	"time"
 
+	"golang.org/x/net/http2"
 	"imuslab.com/zoraxy/mod/dynamicproxy/domainsniff"
 	"imuslab.com/zoraxy/mod/dynamicproxy/permissionpolicy"
 )
@@ -84,6 +86,7 @@ type requestCanceler interface {
 type DpcoreOptions struct {
 	IgnoreTLSVerification bool          //Disable all TLS verification when request pass through this proxy router
 	FlushInterval         time.Duration //Duration to flush in normal requests. Stream request or keep-alive request will always flush with interval of -1 (immediately)
+	UseH2CRoundTripper    bool          //Use H2C RoundTripper for HTTP/2.0 connection
 }
 
 func NewDynamicProxyCore(target *url.URL, prepender string, dpcOptions *DpcoreOptions) *ReverseProxy {
@@ -100,8 +103,17 @@ func NewDynamicProxyCore(target *url.URL, prepender string, dpcOptions *DpcoreOp
 
 	}
 
-	//Hack the default transporter to handle more connections
 	thisTransporter := http.DefaultTransport
+	if dpcOptions.UseH2CRoundTripper {
+		thisTransporter = &http2.Transport{
+			DialTLS: func(network, addr string, cfg *tls.Config) (net.Conn, error) {
+				return net.Dial(network, addr)
+			},
+			AllowHTTP: true,
+		}
+	}
+
+	//Hack the default transporter to handle more connections
 	optimalConcurrentConnection := 32
 	thisTransporter.(*http.Transport).MaxIdleConns = optimalConcurrentConnection * 2
 	thisTransporter.(*http.Transport).MaxIdleConnsPerHost = optimalConcurrentConnection

+ 1 - 1
mod/dynamicproxy/dynamicproxy.go

@@ -354,7 +354,7 @@ func (router *Router) LoadProxy(matchingDomain string) (*ProxyEndpoint, error) {
 			return true
 		}
 
-		if key == matchingDomain {
+		if key == strings.ToLower(matchingDomain) {
 			targetProxyEndpoint = v
 		}
 		return true

+ 2 - 1
mod/dynamicproxy/endpoints.go

@@ -267,7 +267,8 @@ func (ep *ProxyEndpoint) Clone() *ProxyEndpoint {
 
 // Remove this proxy endpoint from running proxy endpoint list
 func (ep *ProxyEndpoint) Remove() error {
-	ep.parent.ProxyEndpoints.Delete(ep.RootOrMatchingDomain)
+	lookupHostname := strings.ToLower(ep.RootOrMatchingDomain)
+	ep.parent.ProxyEndpoints.Delete(lookupHostname)
 	return nil
 }
 

+ 4 - 4
reverseproxy.go

@@ -28,8 +28,8 @@ func ReverseProxtInit() {
 	/*
 		Load Reverse Proxy Global Settings
 	*/
-	inboundPort := 443
-	autoStartReverseProxy := true
+	inboundPort := *defaultInboundPort
+	autoStartReverseProxy := *defaultEnableInboundTraffic
 	if sysdb.KeyExists("settings", "inbound") {
 		//Read settings from database
 		sysdb.Read("settings", "inbound", &inboundPort)
@@ -42,8 +42,8 @@ func ReverseProxtInit() {
 	} else {
 		//Default port
 		if netutils.CheckIfPortOccupied(inboundPort) {
-			inboundPort = 8743
-			SystemWideLogger.Println("Port 443 is occupied. Switching to backup port 8743 instead")
+			autoStartReverseProxy = false
+			SystemWideLogger.Println("Port 443 is occupied. Change the listening port in the webmin panel and press \"Start Service\" to start reverse proxy service")
 		}
 		SystemWideLogger.Println("Inbound port not set. Using default (443)")
 	}

BIN
www/html/test/012.jpg


BIN
www/html/test/425545328_771192708363369_3287282689564963115_n.jpg