mirror of
https://github.com/tobychui/zoraxy.git
synced 2025-06-07 16:17:22 +02:00
3.0.8 init
- Fixed rate limit bug #216 - Added HSTS auto subdomain include check
This commit is contained in:
parent
a18413dd03
commit
7e62fef879
@ -55,9 +55,9 @@ var logOutputToFile = flag.Bool("log", true, "Log terminal output to file")
|
|||||||
|
|
||||||
var (
|
var (
|
||||||
name = "Zoraxy"
|
name = "Zoraxy"
|
||||||
version = "3.0.7"
|
version = "3.0.8"
|
||||||
nodeUUID = "generic"
|
nodeUUID = "generic"
|
||||||
development = false //Set this to false to use embedded web fs
|
development = true //Set this to false to use embedded web fs
|
||||||
bootTime = time.Now().Unix()
|
bootTime = time.Now().Unix()
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -51,7 +51,13 @@ func (ept *ProxyEndpoint) SplitInboundOutboundHeaders() ([][]string, [][]string)
|
|||||||
|
|
||||||
//Check if the endpoint require HSTS headers
|
//Check if the endpoint require HSTS headers
|
||||||
if ept.HSTSMaxAge > 0 {
|
if ept.HSTSMaxAge > 0 {
|
||||||
downstreamHeaders[downstreamHeaderCounter] = []string{"Strict-Transport-Security", "max-age=" + strconv.Itoa(int(ept.HSTSMaxAge))}
|
if ept.ContainsWildcardName(true) {
|
||||||
|
//Endpoint listening domain includes wildcards.
|
||||||
|
downstreamHeaders[downstreamHeaderCounter] = []string{"Strict-Transport-Security", "max-age=" + strconv.Itoa(int(ept.HSTSMaxAge)) + "; includeSubdomains"}
|
||||||
|
} else {
|
||||||
|
downstreamHeaders[downstreamHeaderCounter] = []string{"Strict-Transport-Security", "max-age=" + strconv.Itoa(int(ept.HSTSMaxAge))}
|
||||||
|
}
|
||||||
|
|
||||||
downstreamHeaderCounter++
|
downstreamHeaderCounter++
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -133,6 +133,30 @@ func (ep *ProxyEndpoint) AddVirtualDirectoryRule(vdir *VirtualDirectoryEndpoint)
|
|||||||
return readyRoutingRule, nil
|
return readyRoutingRule, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check if the proxy endpoint hostname or alias name contains subdomain wildcard
|
||||||
|
func (ep *ProxyEndpoint) ContainsWildcardName(skipAliasCheck bool) bool {
|
||||||
|
hostname := ep.RootOrMatchingDomain
|
||||||
|
aliasHostnames := ep.MatchingDomainAlias
|
||||||
|
|
||||||
|
wildcardCheck := func(hostname string) bool {
|
||||||
|
return len(hostname) > 0 && hostname[0] == '*'
|
||||||
|
}
|
||||||
|
|
||||||
|
if wildcardCheck(hostname) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
if !skipAliasCheck {
|
||||||
|
for _, aliasHostname := range aliasHostnames {
|
||||||
|
if wildcardCheck(aliasHostname) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
// Create a deep clone object of the proxy endpoint
|
// Create a deep clone object of the proxy endpoint
|
||||||
// Note the returned object is not activated. Call to prepare function before pushing into runtime
|
// Note the returned object is not activated. Call to prepare function before pushing into runtime
|
||||||
func (ep *ProxyEndpoint) Clone() *ProxyEndpoint {
|
func (ep *ProxyEndpoint) Clone() *ProxyEndpoint {
|
||||||
|
@ -475,9 +475,12 @@ func ReverseProxyHandleEditEndpoint(w http.ResponseWriter, r *http.Request) {
|
|||||||
utils.SendErrorResponse(w, "invalid rate limit number")
|
utils.SendErrorResponse(w, "invalid rate limit number")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if proxyRateLimit <= 0 {
|
|
||||||
|
if requireRateLimit && proxyRateLimit <= 0 {
|
||||||
utils.SendErrorResponse(w, "rate limit number must be greater than 0")
|
utils.SendErrorResponse(w, "rate limit number must be greater than 0")
|
||||||
return
|
return
|
||||||
|
}else if proxyRateLimit < 0 {
|
||||||
|
proxyRateLimit = 1000
|
||||||
}
|
}
|
||||||
|
|
||||||
// Bypass WebSocket Origin Check
|
// Bypass WebSocket Origin Check
|
||||||
|
@ -51,8 +51,8 @@
|
|||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
<p>
|
<p>
|
||||||
<i class="angle double right blue icon"></i> Sent additional custom headers to origin server <br>
|
<i class="angle double right blue icon"></i> Add or remove headers before sending to origin server <br>
|
||||||
<i class="angle double left orange icon"></i> Inject custom headers into origin server responses
|
<i class="angle double left orange icon"></i> Modify headers from origin server responses before sending to client
|
||||||
</p>
|
</p>
|
||||||
<div class="ui divider"></div>
|
<div class="ui divider"></div>
|
||||||
<h4>Edit Custom Header</h4>
|
<h4>Edit Custom Header</h4>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user