typedef.go 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. package dynamicproxy
  2. import (
  3. "net"
  4. "net/http"
  5. "sync"
  6. "imuslab.com/zoraxy/mod/dynamicproxy/dpcore"
  7. "imuslab.com/zoraxy/mod/dynamicproxy/redirection"
  8. "imuslab.com/zoraxy/mod/geodb"
  9. "imuslab.com/zoraxy/mod/statistic"
  10. "imuslab.com/zoraxy/mod/tlscert"
  11. )
  12. const (
  13. ProxyType_Subdomain = 0
  14. ProxyType_Vdir = 1
  15. )
  16. type ProxyHandler struct {
  17. Parent *Router
  18. }
  19. type RouterOption struct {
  20. HostUUID string //The UUID of Zoraxy, use for heading mod
  21. Port int //Incoming port
  22. UseTls bool //Use TLS to serve incoming requsts
  23. ForceTLSLatest bool //Force TLS1.2 or above
  24. ForceHttpsRedirect bool //Force redirection of http to https endpoint
  25. TlsManager *tlscert.Manager
  26. RedirectRuleTable *redirection.RuleTable
  27. GeodbStore *geodb.Store //GeoIP blacklist and whitelist
  28. StatisticCollector *statistic.Collector
  29. }
  30. type Router struct {
  31. Option *RouterOption
  32. ProxyEndpoints *sync.Map
  33. SubdomainEndpoint *sync.Map
  34. Running bool
  35. Root *ProxyEndpoint
  36. mux http.Handler
  37. server *http.Server
  38. tlsListener net.Listener
  39. routingRules []*RoutingRule
  40. tlsRedirectStop chan bool
  41. }
  42. // Auth credential for basic auth on certain endpoints
  43. type BasicAuthCredentials struct {
  44. Username string
  45. PasswordHash string
  46. }
  47. // Auth credential for basic auth on certain endpoints
  48. type BasicAuthUnhashedCredentials struct {
  49. Username string
  50. Password string
  51. }
  52. // A proxy endpoint record
  53. type ProxyEndpoint struct {
  54. ProxyType int //The type of this proxy, see const def
  55. RootOrMatchingDomain string //Root for vdir or Matching domain for subd
  56. Domain string //Domain or IP to proxy to
  57. RequireTLS bool //Target domain require TLS
  58. SkipCertValidations bool //Set to true to accept self signed certs
  59. RequireBasicAuth bool //Set to true to request basic auth before proxy
  60. BasicAuthCredentials []*BasicAuthCredentials `json:"-"`
  61. Proxy *dpcore.ReverseProxy `json:"-"`
  62. }
  63. type RootOptions struct {
  64. ProxyLocation string
  65. RequireTLS bool
  66. SkipCertValidations bool
  67. RequireBasicAuth bool
  68. BasicAuthCredentials []*BasicAuthCredentials
  69. }
  70. type VdirOptions struct {
  71. RootName string
  72. Domain string
  73. RequireTLS bool
  74. SkipCertValidations bool
  75. RequireBasicAuth bool
  76. BasicAuthCredentials []*BasicAuthCredentials
  77. }
  78. type SubdOptions struct {
  79. MatchingDomain string
  80. Domain string
  81. RequireTLS bool
  82. SkipCertValidations bool
  83. RequireBasicAuth bool
  84. BasicAuthCredentials []*BasicAuthCredentials
  85. }
  86. /*
  87. type ProxyEndpoint struct {
  88. Root string
  89. Domain string
  90. RequireTLS bool
  91. Proxy *reverseproxy.ReverseProxy `json:"-"`
  92. }
  93. type SubdomainEndpoint struct {
  94. MatchingDomain string
  95. Domain string
  96. RequireTLS bool
  97. Proxy *reverseproxy.ReverseProxy `json:"-"`
  98. }
  99. */