123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181 |
- package dynamicproxy
- import (
- _ "embed"
- "net"
- "net/http"
- "sync"
- "imuslab.com/zoraxy/mod/access"
- "imuslab.com/zoraxy/mod/dynamicproxy/dpcore"
- "imuslab.com/zoraxy/mod/dynamicproxy/loadbalance"
- "imuslab.com/zoraxy/mod/dynamicproxy/permissionpolicy"
- "imuslab.com/zoraxy/mod/dynamicproxy/redirection"
- "imuslab.com/zoraxy/mod/geodb"
- "imuslab.com/zoraxy/mod/statistic"
- "imuslab.com/zoraxy/mod/tlscert"
- )
- const (
- ProxyType_Root = 0
- ProxyType_Host = 1
- ProxyType_Vdir = 2
- )
- type ProxyHandler struct {
- Parent *Router
- }
- type RouterOption struct {
- HostUUID string
- HostVersion string
- Port int
- UseTls bool
- ForceTLSLatest bool
- NoCache bool
- ListenOnPort80 bool
- ForceHttpsRedirect bool
- TlsManager *tlscert.Manager
- RedirectRuleTable *redirection.RuleTable
- GeodbStore *geodb.Store
- AccessController *access.Controller
- StatisticCollector *statistic.Collector
- WebDirectory string
- LoadBalancer *loadbalance.RouteManager
- }
- type Router struct {
- Option *RouterOption
- ProxyEndpoints *sync.Map
- Running bool
- Root *ProxyEndpoint
- mux http.Handler
- server *http.Server
- tlsListener net.Listener
- loadBalancer *loadbalance.RouteManager
- routingRules []*RoutingRule
- tlsRedirectStop chan bool
- rateLimterStop chan bool
- rateLimitCounter RequestCountPerIpTable
- }
- type BasicAuthCredentials struct {
- Username string
- PasswordHash string
- }
- type BasicAuthUnhashedCredentials struct {
- Username string
- Password string
- }
- type BasicAuthExceptionRule struct {
- PathPrefix string
- }
- type HeaderDirection int
- const (
- HeaderDirection_ZoraxyToUpstream HeaderDirection = 0
- HeaderDirection_ZoraxyToDownstream HeaderDirection = 1
- )
- type UserDefinedHeader struct {
- Direction HeaderDirection
- Key string
- Value string
- IsRemove bool
- }
- type VirtualDirectoryEndpoint struct {
- MatchingPath string
- Domain string
- RequireTLS bool
- SkipCertValidations bool
- Disabled bool
- proxy *dpcore.ReverseProxy `json:"-"`
- parent *ProxyEndpoint `json:"-"`
- }
- type ProxyEndpoint struct {
- ProxyType int
- RootOrMatchingDomain string
- MatchingDomainAlias []string
- ActiveOrigins []*loadbalance.Upstream
- InactiveOrigins []*loadbalance.Upstream
- UseStickySession bool
- UseActiveLoadBalance bool
- Disabled bool
-
- BypassGlobalTLS bool
-
- VirtualDirectories []*VirtualDirectoryEndpoint
-
- UserDefinedHeaders []*UserDefinedHeader
- HSTSMaxAge int64
- EnablePermissionPolicyHeader bool
- PermissionPolicy *permissionpolicy.PermissionsPolicy
- DisableHopByHopHeaderRemoval bool
-
- RequireBasicAuth bool
- BasicAuthCredentials []*BasicAuthCredentials
- BasicAuthExceptionRules []*BasicAuthExceptionRule
-
- RequireRateLimit bool
- RateLimit int64
-
- AccessFilterUUID string
-
- DefaultSiteOption int
- DefaultSiteValue string
-
- parent *Router `json:"-"`
- }
- const (
- DefaultSite_InternalStaticWebServer = 0
- DefaultSite_ReverseProxy = 1
- DefaultSite_Redirect = 2
- DefaultSite_NotFoundPage = 3
- )
- var (
-
- page_forbidden []byte
-
- page_hosterror []byte
- )
|