Skip to main content

(Policy Group) Policy Groups

Policy groups are applied in the policies of rules and can contain multiple proxy servers or other policy groups. The types of policy groups supported are: select (manual selection), auto_test (latency test), fallback (availability test), load_balance (load balancing), and external (external resources used to reference local or remote files). Additionally, Egern also supports two default policies: DIRECT (direct connection) and REJECT (reject connection).

(Select) Manual Selection Policy Group

The manual selection policy group allows users to manually select a sub-policy.

Field NameTypeRequiredDescription
namestringYesPolicy name
policiesarray of stringsYesNames of sub-policies or proxy servers

(Auto Test) Latency Test Policy

The latency test policy automatically selects the sub-policy with the lowest latency.

Field NameTypeRequiredDescription
namestringYesPolicy name
policiesarray of stringsYesNames of sub-policies or proxy servers
intervalintegerNoInterval for latency tests, default is 10 minutes
toleranceintegerNoAllowed latency variation, default is 100 milliseconds
timeoutintegerNoLatency test timeout, default is 5 seconds

(Fallback) Availability Test Policy

The availability test policy automatically selects the first accessible sub-policy or proxy.

Field NameTypeRequiredDescription
namestringYesPolicy name
policiesarray of stringsYesNames of sub-policies or proxy servers
intervalintegerNoInterval for availability tests, default is 10 minutes
timeoutintegerNoAvailability test timeout, default is 5 seconds

(Load Balance) Load Balancing Policy

The load balancing policy attempts to evenly distribute traffic across all sub-policies or proxies.

Field NameTypeRequiredDescription
namestringYesPolicy name
policiesarray of stringsYesNames of sub-policies or proxy servers

(External) External Resource Policy

This policy uses local or remote policy groups.

Field NameTypeRequiredDescription
namestringYesPolicy name
typestringYesType of proxy set; options are select, auto_test, fallback, load_balance
urlsarray of stringsYesAddresses of proxy servers (local paths or remote links), compatible with Surge and V2Ray formats
intervalintegerNoInterval for latency tests, default is 10 minutes
toleranceintegerNoAllowed latency variation, default is 100 milliseconds
timeoutintegerNoLatency test timeout, default is 5 seconds
update_intervalintegerNoUpdate interval, default is one day

The local or remote content should be a set of proxy servers.

proxies:
- socks5:
name: Socks5
server: 127.0.0.1
port: 1080
username: ""
password: ""
tfo: true
udp_relay: true
- trojan:
name: Trojan
server: 127.0.0.1
port: 443
sni: bing.com
password: password
tfo: false
udp_relay: true

Configuration Example

Example:

policy_groups:
- select:
name: "Manual Selection"
policies:
- US
- JP
- auto_test:
name: "Latency Test"
policies:
- US
- JP
- fallback:
name: "Availability Test"
policies:
- US
- JP
- load_balance:
name: "Load Balancing"
policies:
- US
- JP
- external:
name: "Remote Proxies"
type: select
urls:
- "https://example/proxies.yaml"

In this configuration, we have set up several policies, including manual selection, latency test, availability test, load balancing, and external resources. Each policy has its own name and lists the proxy servers that can be used for that policy (US and JP). In the external resource policy, we have specified a URL for remote proxies.