mirror of
https://github.com/caddyserver/caddy.git
synced 2025-10-19 15:53:17 +00:00
core: add modular network_proxy
support (#6399)
* core: add modular `network_proxy` support Co-authored-by: @ImpostorKeanu Signed-off-by: Mohammed Al Sahaf <msaa1990@gmail.com> * move modules around Signed-off-by: Mohammed Al Sahaf <msaa1990@gmail.com> * add caddyfile implementation Signed-off-by: Mohammed Al Sahaf <msaa1990@gmail.com> * address feedbcak * Apply suggestions from code review Co-authored-by: Francis Lavoie <lavofr@gmail.com> * adapt ForwardProxyURL to use the NetworkProxyRaw Signed-off-by: Mohammed Al Sahaf <msaa1990@gmail.com> * remove redundant `url` in log Co-authored-by: Matt Holt <mholt@users.noreply.github.com> * code review Signed-off-by: Mohammed Al Sahaf <msaa1990@gmail.com> * remove `.source` from the module ID Signed-off-by: Mohammed Al Sahaf <msaa1990@gmail.com> --------- Signed-off-by: Mohammed Al Sahaf <msaa1990@gmail.com> Co-authored-by: Francis Lavoie <lavofr@gmail.com> Co-authored-by: Matt Holt <mholt@users.noreply.github.com>
This commit is contained in:
parent
7b1f00c330
commit
173573035c
8 changed files with 347 additions and 12 deletions
10
modules.go
10
modules.go
|
@ -18,6 +18,8 @@ import (
|
|||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"reflect"
|
||||
"sort"
|
||||
"strings"
|
||||
|
@ -360,6 +362,14 @@ func isModuleMapType(typ reflect.Type) bool {
|
|||
isJSONRawMessage(typ.Elem())
|
||||
}
|
||||
|
||||
// ProxyFuncProducer is implemented by modules which produce a
|
||||
// function that returns a URL to use as network proxy. Modules
|
||||
// in the namespace `caddy.network_proxy` must implement this
|
||||
// interface.
|
||||
type ProxyFuncProducer interface {
|
||||
ProxyFunc() func(*http.Request) (*url.URL, error)
|
||||
}
|
||||
|
||||
var (
|
||||
modules = make(map[string]ModuleInfo)
|
||||
modulesMu sync.RWMutex
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue