Skip to content
This repository was archived by the owner on Feb 13, 2025. It is now read-only.

Commit 72a126e

Browse files
committed
feat: support inline proxy provider
1 parent 20739f5 commit 72a126e

File tree

6 files changed

+231
-176
lines changed

6 files changed

+231
-176
lines changed

adapter/provider/parser.go

+19-16
Original file line numberDiff line numberDiff line change
@@ -57,16 +57,17 @@ type OverrideSchema struct {
5757
}
5858

5959
type proxyProviderSchema struct {
60-
Type string `provider:"type"`
61-
Path string `provider:"path,omitempty"`
62-
URL string `provider:"url,omitempty"`
63-
Proxy string `provider:"proxy,omitempty"`
64-
Interval int `provider:"interval,omitempty"`
65-
Filter string `provider:"filter,omitempty"`
66-
ExcludeFilter string `provider:"exclude-filter,omitempty"`
67-
ExcludeType string `provider:"exclude-type,omitempty"`
68-
DialerProxy string `provider:"dialer-proxy,omitempty"`
69-
SizeLimit int64 `provider:"size-limit,omitempty"`
60+
Type string `provider:"type"`
61+
Path string `provider:"path,omitempty"`
62+
URL string `provider:"url,omitempty"`
63+
Proxy string `provider:"proxy,omitempty"`
64+
Interval int `provider:"interval,omitempty"`
65+
Filter string `provider:"filter,omitempty"`
66+
ExcludeFilter string `provider:"exclude-filter,omitempty"`
67+
ExcludeType string `provider:"exclude-type,omitempty"`
68+
DialerProxy string `provider:"dialer-proxy,omitempty"`
69+
SizeLimit int64 `provider:"size-limit,omitempty"`
70+
Payload []map[string]any `provider:"payload,omitempty"`
7071

7172
HealthCheck healthCheckSchema `provider:"health-check,omitempty"`
7273
Override OverrideSchema `provider:"override,omitempty"`
@@ -99,6 +100,11 @@ func ParseProxyProvider(name string, mapping map[string]any) (types.ProxyProvide
99100
}
100101
hc := NewHealthCheck([]C.Proxy{}, schema.HealthCheck.URL, uint(schema.HealthCheck.TestTimeout), hcInterval, schema.HealthCheck.Lazy, expectedStatus)
101102

103+
parser, err := NewProxiesParser(schema.Filter, schema.ExcludeFilter, schema.ExcludeType, schema.DialerProxy, schema.Override)
104+
if err != nil {
105+
return nil, err
106+
}
107+
102108
var vehicle types.Vehicle
103109
switch schema.Type {
104110
case "file":
@@ -113,16 +119,13 @@ func ParseProxyProvider(name string, mapping map[string]any) (types.ProxyProvide
113119
}
114120
}
115121
vehicle = resource.NewHTTPVehicle(schema.URL, path, schema.Proxy, schema.Header, resource.DefaultHttpTimeout, schema.SizeLimit)
122+
case "inline":
123+
return NewInlineProvider(name, schema.Payload, parser, hc)
116124
default:
117125
return nil, fmt.Errorf("%w: %s", errVehicleType, schema.Type)
118126
}
119127

120128
interval := time.Duration(uint(schema.Interval)) * time.Second
121-
filter := schema.Filter
122-
excludeFilter := schema.ExcludeFilter
123-
excludeType := schema.ExcludeType
124-
dialerProxy := schema.DialerProxy
125-
override := schema.Override
126129

127-
return NewProxySetProvider(name, interval, filter, excludeFilter, excludeType, dialerProxy, override, vehicle, hc)
130+
return NewProxySetProvider(name, interval, parser, vehicle, hc)
128131
}

0 commit comments

Comments
 (0)