fix ruleset application bug where rulesets that apply other rulesets are not applied on a single proxychain pass
This commit is contained in:
@@ -156,6 +156,13 @@ func (chain *ProxyChain) AddOnceResponseModifications(mods ...ResponseModificati
|
|||||||
// AddResponseModifications sets the ProxyChain's response modifiers
|
// AddResponseModifications sets the ProxyChain's response modifiers
|
||||||
// the modifier will not fire until ProxyChain.Execute() is run.
|
// the modifier will not fire until ProxyChain.Execute() is run.
|
||||||
func (chain *ProxyChain) AddResponseModifications(mods ...ResponseModification) *ProxyChain {
|
func (chain *ProxyChain) AddResponseModifications(mods ...ResponseModification) *ProxyChain {
|
||||||
|
chain.responseModifications = append(chain.responseModifications, mods...)
|
||||||
|
return chain
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetResponseModifications sets the ProxyChain's response modifiers
|
||||||
|
// the modifier will not fire until ProxyChain.Execute() is run.
|
||||||
|
func (chain *ProxyChain) SetResponseModifications(mods ...ResponseModification) *ProxyChain {
|
||||||
chain.responseModifications = mods
|
chain.responseModifications = mods
|
||||||
return chain
|
return chain
|
||||||
}
|
}
|
||||||
@@ -462,13 +469,16 @@ func (chain *ProxyChain) _execute() (io.Reader, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Apply onceRequestModifications to proxychain and clear them
|
// Apply onceRequestModifications to proxychain and clear them
|
||||||
for _, applyOnceRequestModificationsTo := range chain.onceRequestModifications {
|
for len(chain.onceRequestModifications) > 0 {
|
||||||
err := applyOnceRequestModificationsTo(chain)
|
i := 0
|
||||||
|
modFn := chain.onceRequestModifications[i]
|
||||||
|
err := modFn(chain)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, chain.abort(err)
|
return nil, chain.abort(err)
|
||||||
}
|
}
|
||||||
|
// pop modFn off slice
|
||||||
|
chain.onceRequestModifications = append(chain.onceRequestModifications[:i], chain.onceRequestModifications[i+1:]...)
|
||||||
}
|
}
|
||||||
chain.onceRequestModifications = []RequestModification{}
|
|
||||||
|
|
||||||
// ======== SEND REQUEST UPSTREAM :: client -> [ladder -> upstream] -> ladder -> client =============================
|
// ======== SEND REQUEST UPSTREAM :: client -> [ladder -> upstream] -> ladder -> client =============================
|
||||||
// Send Request Upstream
|
// Send Request Upstream
|
||||||
@@ -499,13 +509,16 @@ func (chain *ProxyChain) _execute() (io.Reader, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Apply onceResponseModifications to proxychain and clear them
|
// Apply onceResponseModifications to proxychain and clear them
|
||||||
for _, applyOnceResponseModificationsTo := range chain.onceResponseModifications {
|
for len(chain.onceResponseModifications) > 0 {
|
||||||
err := applyOnceResponseModificationsTo(chain)
|
i := 0
|
||||||
|
modFn := chain.onceResponseModifications[i]
|
||||||
|
err := modFn(chain)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, chain.abort(err)
|
return nil, chain.abort(err)
|
||||||
}
|
}
|
||||||
|
// pop modFn off slice
|
||||||
|
chain.onceResponseModifications = append(chain.onceResponseModifications[:i], chain.onceResponseModifications[i+1:]...)
|
||||||
}
|
}
|
||||||
chain.onceResponseModifications = []ResponseModification{}
|
|
||||||
|
|
||||||
// ======== RETURN BODY TO CLIENT :: client -> ladder -> upstream -> [ladder -> client] =============================
|
// ======== RETURN BODY TO CLIENT :: client -> ladder -> upstream -> [ladder -> client] =============================
|
||||||
return chain.Response.Body, nil
|
return chain.Response.Body, nil
|
||||||
|
|||||||
Reference in New Issue
Block a user