Checkpoint

This commit is contained in:
2025-10-01 21:10:48 +02:00
parent 03352e3312
commit a23259cfdc
52 changed files with 2214 additions and 39 deletions

View File

@@ -33,6 +33,8 @@ func (c Config) Proxies(log logger.Structured) ([]*proxy.Proxy, error) {
var (
onRequest []proxy.RequestHandler
onDial []proxy.DialHandler
onForward []proxy.ForwardHandler
onResponse []proxy.ResponseHandler
)
for _, name := range c.Proxy.On.Request {
@@ -43,6 +45,22 @@ func (c Config) Proxies(log logger.Structured) ([]*proxy.Proxy, error) {
}
onRequest = append(onRequest, policy.NewRequestHandler(p))
}
for _, name := range c.Proxy.On.Dial {
log.Value("policy", name).Debug("Resolving dial policy")
p, ok := policies[name]
if !ok {
return nil, fmt.Errorf("on dial: no policy named %q", name)
}
onDial = append(onDial, policy.NewDialHandler(p))
}
for _, name := range c.Proxy.On.Forward {
log.Value("policy", name).Debug("Resolving forward policy")
p, ok := policies[name]
if !ok {
return nil, fmt.Errorf("on forward: no policy named %q", name)
}
onForward = append(onForward, policy.NewForwardHandler(p))
}
for _, name := range c.Proxy.On.Response {
log.Value("policy", name).Debug("Resolving response policy")
p, ok := policies[name]
@@ -60,6 +78,8 @@ func (c Config) Proxies(log logger.Structured) ([]*proxy.Proxy, error) {
return nil, err
}
p.OnRequest = append(p.OnRequest, onRequest...)
p.OnDial = append(p.OnDial, onDial...)
p.OnForward = append(p.OnForward, onForward...)
p.OnResponse = append(p.OnResponse, onResponse...)
proxies = append(proxies, p)
}
@@ -114,6 +134,8 @@ func (c PortConfig) Proxy() (*proxy.Proxy, error) {
type ProxyPolicyConfig struct {
Intercept []string `hcl:"intercept,optional"`
Request []string `hcl:"request,optional"`
Dial []string `hcl:"dial,optional"`
Forward []string `hcl:"forward,optional"`
Response []string `hcl:"response,optional"`
}