|
@@ -8,6 +8,7 @@ import (
|
|
|
|
|
|
"imuslab.com/zoraxy/mod/access"
|
|
"imuslab.com/zoraxy/mod/access"
|
|
"imuslab.com/zoraxy/mod/dynamicproxy/dpcore"
|
|
"imuslab.com/zoraxy/mod/dynamicproxy/dpcore"
|
|
|
|
+ "imuslab.com/zoraxy/mod/dynamicproxy/loadbalance"
|
|
"imuslab.com/zoraxy/mod/dynamicproxy/permissionpolicy"
|
|
"imuslab.com/zoraxy/mod/dynamicproxy/permissionpolicy"
|
|
"imuslab.com/zoraxy/mod/dynamicproxy/redirection"
|
|
"imuslab.com/zoraxy/mod/dynamicproxy/redirection"
|
|
"imuslab.com/zoraxy/mod/geodb"
|
|
"imuslab.com/zoraxy/mod/geodb"
|
|
@@ -25,23 +26,26 @@ type ProxyHandler struct {
|
|
Parent *Router
|
|
Parent *Router
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+/* Router Object Options */
|
|
type RouterOption struct {
|
|
type RouterOption struct {
|
|
- HostUUID string //The UUID of Zoraxy, use for heading mod
|
|
|
|
- HostVersion string //The version of Zoraxy, use for heading mod
|
|
|
|
- Port int //Incoming port
|
|
|
|
- UseTls bool //Use TLS to serve incoming requsts
|
|
|
|
- ForceTLSLatest bool //Force TLS1.2 or above
|
|
|
|
- NoCache bool //Force set Cache-Control: no-store
|
|
|
|
- ListenOnPort80 bool //Enable port 80 http listener
|
|
|
|
- ForceHttpsRedirect bool //Force redirection of http to https endpoint
|
|
|
|
- TlsManager *tlscert.Manager
|
|
|
|
- RedirectRuleTable *redirection.RuleTable
|
|
|
|
- GeodbStore *geodb.Store //GeoIP resolver
|
|
|
|
- AccessController *access.Controller //Blacklist / whitelist controller
|
|
|
|
- StatisticCollector *statistic.Collector
|
|
|
|
- WebDirectory string //The static web server directory containing the templates folder
|
|
|
|
|
|
+ HostUUID string //The UUID of Zoraxy, use for heading mod
|
|
|
|
+ HostVersion string //The version of Zoraxy, use for heading mod
|
|
|
|
+ Port int //Incoming port
|
|
|
|
+ UseTls bool //Use TLS to serve incoming requsts
|
|
|
|
+ ForceTLSLatest bool //Force TLS1.2 or above
|
|
|
|
+ NoCache bool //Force set Cache-Control: no-store
|
|
|
|
+ ListenOnPort80 bool //Enable port 80 http listener
|
|
|
|
+ ForceHttpsRedirect bool //Force redirection of http to https endpoint
|
|
|
|
+ TlsManager *tlscert.Manager //TLS manager for serving SAN certificates
|
|
|
|
+ RedirectRuleTable *redirection.RuleTable //Redirection rules handler and table
|
|
|
|
+ GeodbStore *geodb.Store //GeoIP resolver
|
|
|
|
+ AccessController *access.Controller //Blacklist / whitelist controller
|
|
|
|
+ StatisticCollector *statistic.Collector //Statistic collector for storing stats on incoming visitors
|
|
|
|
+ WebDirectory string //The static web server directory containing the templates folder
|
|
|
|
+ LoadBalancer *loadbalance.RouteManager //Load balancer that handle load balancing of proxy target
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+/* Router Object */
|
|
type Router struct {
|
|
type Router struct {
|
|
Option *RouterOption
|
|
Option *RouterOption
|
|
ProxyEndpoints *sync.Map
|
|
ProxyEndpoints *sync.Map
|
|
@@ -50,6 +54,7 @@ type Router struct {
|
|
mux http.Handler
|
|
mux http.Handler
|
|
server *http.Server
|
|
server *http.Server
|
|
tlsListener net.Listener
|
|
tlsListener net.Listener
|
|
|
|
+ loadBalancer *loadbalance.RouteManager //Load balancer routing manager
|
|
routingRules []*RoutingRule
|
|
routingRules []*RoutingRule
|
|
|
|
|
|
tlsRedirectStop chan bool //Stop channel for tls redirection server
|
|
tlsRedirectStop chan bool //Stop channel for tls redirection server
|
|
@@ -57,6 +62,7 @@ type Router struct {
|
|
rateLimitCounter RequestCountPerIpTable //Request counter for rate limter
|
|
rateLimitCounter RequestCountPerIpTable //Request counter for rate limter
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+/* Basic Auth Related Data structure*/
|
|
// Auth credential for basic auth on certain endpoints
|
|
// Auth credential for basic auth on certain endpoints
|
|
type BasicAuthCredentials struct {
|
|
type BasicAuthCredentials struct {
|
|
Username string
|
|
Username string
|
|
@@ -74,6 +80,7 @@ type BasicAuthExceptionRule struct {
|
|
PathPrefix string
|
|
PathPrefix string
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+/* Custom Header Related Data structure */
|
|
// Header injection direction type
|
|
// Header injection direction type
|
|
type HeaderDirection int
|
|
type HeaderDirection int
|
|
|
|
|
|
@@ -90,6 +97,8 @@ type UserDefinedHeader struct {
|
|
IsRemove bool //Instead of set, remove this key instead
|
|
IsRemove bool //Instead of set, remove this key instead
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+/* Routing Rule Data Structures */
|
|
|
|
+
|
|
// A Virtual Directory endpoint, provide a subset of ProxyEndpoint for better
|
|
// A Virtual Directory endpoint, provide a subset of ProxyEndpoint for better
|
|
// program structure than directly using ProxyEndpoint
|
|
// program structure than directly using ProxyEndpoint
|
|
type VirtualDirectoryEndpoint struct {
|
|
type VirtualDirectoryEndpoint struct {
|