浏览代码

Added new header rewrite structure

Toby Chui 9 月之前
父节点
当前提交
fb3f708a68
共有 3 个文件被更改,包括 36 次插入5 次删除
  1. 15 0
      build_linux.bat
  2. 8 3
      mod/dynamicproxy/Server.go
  3. 13 2
      mod/dynamicproxy/typedef.go

+ 15 - 0
build_linux.bat

@@ -0,0 +1,15 @@
+@echo off
+REM Set the environment variables for cross-compilation
+set GOOS=linux
+set GOARCH=amd64
+
+REM Build the Go program
+go build -o zoraxy_linux_amd64
+
+REM Check if the build was successful
+if %ERRORLEVEL% neq 0 (
+    echo Build failed.
+    exit /b %ERRORLEVEL%
+)
+
+echo Build succeeded. The output file is zoraxy_linux_amd64.

+ 8 - 3
mod/dynamicproxy/Server.go

@@ -14,11 +14,16 @@ import (
 	Main server for dynamic proxy core
 
 	Routing Handler Priority (High to Low)
-	- Blacklist
-	- Whitelist
+	- Special Routing Rule (e.g. acme)
 	- Redirectable
 	- Subdomain Routing
-	- Vitrual Directory Routing
+		- Access Router
+			- Blacklist
+			- Whitelist
+		- Basic Auth
+		- Vitrual Directory Proxy
+		- Subdomain Proxy
+	- Root router (default site router)
 */
 
 func (h *ProxyHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {

+ 13 - 2
mod/dynamicproxy/typedef.go

@@ -72,10 +72,21 @@ type BasicAuthExceptionRule struct {
 	PathPrefix string
 }
 
+// Header injection direction type
+type HeaderDirection int
+
+const (
+	HeaderDirection_ZoraxyToUpstream   HeaderDirection = 0 //Inject (or remove) header to request out-going from Zoraxy to backend server
+	HeaderDirection_ZoraxyToDownstream HeaderDirection = 1 //Inject (or remove) header to request out-going from Zoraxy to client (e.g. browser)
+)
+
 // User defined headers to add into a proxy endpoint
 type UserDefinedHeader struct {
-	Key   string
-	Value string
+	Direction HeaderDirection
+	Key       string
+	Value     string
+	IsRemove  bool //Instead of set, remove this key instead
+	IsAppend  bool //Instead of set, append to the current one with "," as seperator
 }
 
 // A Virtual Directory endpoint, provide a subset of ProxyEndpoint for better