Documentation
¶
Overview ¶
Package dns is the panel's DNS preset module: built-in and custom presets, the DnsService admin API, and the rule that picks the preset that applies to a user (user, then group, then the instance default, then the built-in default). Turning a preset into what a client understands lives next to it: the provider catalog (providers.go), Resolve (transport.go: which endpoints a given client gets for the preset's preferred transport), and HappRouting for Happ (happ.go); the Mihomo and AmneziaWG renderers only add callers of Effective and Preset.EndpointsFor.
The instance default is stored here (setting "dns.default_preset"); SubscriptionService reads and writes SubscriptionSettings.default_dns_preset_id through DefaultPresetID / SetDefaultPresetID so there is one source of truth.
Index ¶
- Constants
- Variables
- func AppRouting(p Preset, scheme string) (string, error)
- func Clean(name, description string, servers []Server, split []SplitRule) (n, d string, srv []Server, sp []SplitRule, err error)
- func CountryOf(p Preset) string
- func GeoCodes() []string
- func HappRouting(p Preset) (string, error)
- func HappRoutingNotes(p Preset) []string
- func LookupVariant(id string) (Variant, Provider, bool)
- func NormalizeSuffix(s string) (string, error)
- type Category
- type Client
- type Endpoint
- type Kind
- type LinkDNS
- type MihomoDNS
- type MihomoPolicy
- type MihomoProvider
- type NodeChoices
- func (c NodeChoices) Choice(nodeID string) string
- func (c NodeChoices) Default(nodeID string) string
- func (c NodeChoices) Effective(nodeID string) string
- func (c NodeChoices) Options(nodeID string) []string
- func (c NodeChoices) Pick(nodeID string) string
- func (c NodeChoices) UpdatedMs(nodeID string) int64
- type Preset
- func (p Preset) ClientPlan(c Client) (main []Endpoint, split []SplitPlan, notes []string, err error)
- func (p Preset) DescriptionIn(lang string) string
- func (p Preset) EndpointsFor(c Client) ([]Endpoint, []string)
- func (p Preset) MihomoDNS(group string) (MihomoDNS, error)
- func (p Preset) NameIn(lang string) string
- func (p Preset) SingboxDNS(group string) (SingboxDNS, error)
- func (p Preset) SplitEndpointsFor(c Client, i int) ([]Endpoint, []string)
- func (p Preset) XrayDNS() (XrayDNS, error)
- type ProfileDNS
- type Provider
- type Server
- type Service
- func (s *Service) CreateDnsPreset(ctx context.Context, req *connect.Request[adminv1.CreateDnsPresetRequest]) (*connect.Response[adminv1.CreateDnsPresetResponse], error)
- func (s *Service) DefaultPresetID(ctx context.Context) (string, error)
- func (s *Service) DeleteDnsPreset(ctx context.Context, req *connect.Request[adminv1.DeleteDnsPresetRequest]) (*connect.Response[adminv1.DeleteDnsPresetResponse], error)
- func (s *Service) Effective(ctx context.Context, userID string) (Preset, Source, error)
- func (s *Service) EffectiveOnNode(ctx context.Context, userID, nodeID string) (Preset, error)
- func (s *Service) GetUserDnsChoices(ctx context.Context, req *connect.Request[adminv1.GetUserDnsChoicesRequest]) (*connect.Response[adminv1.GetUserDnsChoicesResponse], error)
- func (s *Service) Handler() (string, http.Handler)
- func (s *Service) LinkEffective(ctx context.Context, userID string) (Preset, error)
- func (s *Service) LinkOptions(ctx context.Context) (*adminv1.LinkDnsOptions, error)
- func (s *Service) ListDnsPresets(ctx context.Context, _ *connect.Request[adminv1.ListDnsPresetsRequest]) (*connect.Response[adminv1.ListDnsPresetsResponse], error)
- func (s *Service) ListNodeDnsOptions(ctx context.Context, _ *connect.Request[adminv1.ListNodeDnsOptionsRequest]) (*connect.Response[adminv1.ListNodeDnsOptionsResponse], error)
- func (s *Service) NodeChoices(ctx context.Context, userID string) (NodeChoices, error)
- func (s *Service) PresetByID(ctx context.Context, id string) (Preset, error)
- func (s *Service) Presets(ctx context.Context) (map[string]Preset, error)
- func (s *Service) ResetUserDnsChoices(ctx context.Context, req *connect.Request[adminv1.ResetUserDnsChoicesRequest]) (*connect.Response[adminv1.ResetUserDnsChoicesResponse], error)
- func (s *Service) SetDefaultPresetID(ctx context.Context, id string) error
- func (s *Service) SetLinkOptions(ctx context.Context, o *adminv1.LinkDnsOptions) error
- func (s *Service) SetNodeDnsOptions(ctx context.Context, req *connect.Request[adminv1.SetNodeDnsOptionsRequest]) (*connect.Response[adminv1.SetNodeDnsOptionsResponse], error)
- func (s *Service) SubscriptionState(ctx context.Context, userID string) (SubscriptionState, error)
- func (s *Service) UpdateDnsPreset(ctx context.Context, req *connect.Request[adminv1.UpdateDnsPresetRequest]) (*connect.Response[adminv1.UpdateDnsPresetResponse], error)
- type SingboxDNS
- type SingboxDNSRule
- type SingboxRuleSet
- type SingboxSection
- type SingboxServer
- type SingboxServerTLS
- type Source
- type SplitPlan
- type SplitRule
- type SubscriptionState
- type Variant
- type XrayDNS
- type XrayGeo
- type XraySection
- type XrayServer
Constants ¶
const ( SingboxRemoteTag = "remote" // dns.final SingboxLocalTag = "local" // route.default_domain_resolver )
Tags of the servers in the block that the rest of the profile refers to.
const ( MaxServers = 16 // main resolvers, and the servers of one split rule MaxSplitRules = 64 // split rules per preset MaxSuffixesPerRule = 256 // domain suffixes in one split rule )
Limits of a preset.
const CatalogVersion = "2026-09-30"
The provider catalog: well-known public resolvers with their plain, DoT and DoH endpoints. It ships with the panel and changes with releases; a preset server may point at a variant ("cloudflare/family") instead of carrying bare addresses, so a corrected address reaches every preset on the next upgrade.
CatalogVersion is the date every endpoint below was last checked against the provider's own documentation.
const HappProfileName = "DNS"
HappProfileName is the Name of the generated routing profile.
const (
MaxGeoPerRule = 32
)
geositePrefix starts the code of a category alone in Geo; maxGeositeName bounds the name after it, MaxGeoPerRule the codes of one rule.
const MaxNodeOptions = 20
MaxNodeOptions is how many presets one node may offer.
const MihomoProviderInterval = 86400
MihomoProviderInterval is how often a provider is refreshed, in seconds.
const XrayDNSTag = "dns-internal"
XrayDNSTag is the "tag" of the dns block: routing rules match the resolvers' traffic with it.
Variables ¶
var Clients = []Client{ClientHapp, ClientMihomo, ClientXray, ClientSingbox, ClientAmneziaWG}
Clients lists the clients in display order (the DNS editor's "what each app gets"): the apps on the link, then the key.
var ErrLinkOptions = errors.New("link_dns")
ErrLinkOptions wraps every refusal of SetLinkOptions: an unknown or repeated preset, a default that is not offered, too many.
var ErrUnknownPreset = errors.New("dns: unknown preset")
ErrUnknownPreset is returned when a preset id does not exist.
Functions ¶
func AppRouting ¶
AppRouting is HappRouting for another app that reads the same profile under its own link scheme (INCY: "incy"): the profile is the same JSON, only the scheme of the link differs.
func Clean ¶
func Clean(name, description string, servers []Server, split []SplitRule) (n, d string, srv []Server, sp []SplitRule, err error)
Clean validates and normalises the editable fields of a preset.
func CountryOf ¶ added in v0.1.64
CountryOf is the country of a regional preset ("RU", "CN"), "" for the others.
func GeoCodes ¶ added in v0.1.64
func GeoCodes() []string
GeoCodes lists the codes a split rule may carry, sorted.
func HappRouting ¶
HappRouting returns the value of the `routing` header for a preset; its split becomes direct domains only when the preset's SplitDirect is on. An error means Happ cannot express any main server of the preset: the caller leaves the header out.
func HappRoutingNotes ¶
HappRoutingNotes lists, in English, which parts of the preset the Happ profile drops or changes.
func LookupVariant ¶
LookupVariant returns a catalog variant and its provider.
func NormalizeSuffix ¶
NormalizeSuffix validates a domain suffix: ".ru", "gosuslugi.ru", ".рф", "*.example.com". The result is lower case punycode; a leading dot is kept when given (".ru" and "ru" both match the domain and its subdomains, at a label boundary).
Types ¶
type Category ¶
type Category string
Category tells what a variant is for. The admin UI groups the catalog and filters the presets by it.
const ( CategoryRegional Category = "regional" // built for resolving one country's sites from inside it (Variant.Country says which) CategoryRegular Category = "regular" // no filtering CategoryNoAds Category = "no_ads" // blocks ads and trackers CategoryFamily Category = "family" // blocks adult content (and malware) CategorySecurity Category = "security" // blocks malware and phishing )
func CategoryOf ¶
CategoryOf is the category a preset is listed under.
type Client ¶
type Client string
Client is an app that carries the DNS of a subscription.
const ( ClientHapp Client = "happ" ClientMihomo Client = "mihomo" // the Mihomo core and apps built on it ClientAmneziaWG Client = "amneziawg" // ClientXray is an Xray JSON config (Happ, v2rayNG and the like read it). ClientSingbox is a sing-box profile. // See XrayDNS and SingboxDNS for what each takes of a preset. ClientXray Client = "xray" ClientSingbox Client = "singbox" )
func (Client) IPv6 ¶
IPv6 reports whether IPv6 resolver addresses are usable: Mihomo takes them; Happ's profile, Amnezia's key and .conf and the Xray and sing-box profiles (UseIPv4, ipv4_only) are IPv4 only.
func (Client) Transports ¶
Transports is what a client can carry. Sources: the client config formats (Mihomo dns:, Amnezia dns1/dns2), happ.go (Happ has plain and DoH, no DoT).
type Endpoint ¶
type Endpoint struct {
Kind Kind // the transport actually used
Address string // plain: "ip" or "ip:port"; DoH: the URL; DoT: "host" or "host:port"
// IPs of the DoH/DoT host (Happ and Mihomo want an address next to a host name); empty for plain and for a host
// the catalog does not know.
IPs []string
// Variant is the catalog id it came from, "" for a custom server.
Variant string
}
Endpoint is one resolver as a client gets it.
func Resolve ¶
Resolve turns a server list (the main servers of a preset, or one split rule's) into the endpoints a client can carry, best first, plus notes (English) on what was dropped. pref is the preset's preferred transport, ipv4Only drops IPv6 addresses. The order follows the server list, round-robin: the first endpoint of every server, then the second of every server. A plain variant has two addresses, so the first two plain endpoints of [Cloudflare, Google] are 1.1.1.1 and 8.8.8.8 (what AmneziaWG's two-address DNS wants).
type Kind ¶
type Kind string
Kind is how a server is reached.
const ( KindPlain Kind = "plain" // UDP/TCP DNS: "77.88.8.8" or "77.88.8.8:53" KindDoH Kind = "doh" // DNS over HTTPS: "https://dns.example.com/dns-query" KindDoT Kind = "dot" // DNS over TLS: "dns.example.com" or "94.140.14.14:853" )
func NormalizeTransport ¶
NormalizeTransport validates a preferred transport; "" means plain.
type LinkDNS ¶ added in v0.1.43
type LinkDNS struct {
Choice string // the person's pick while it is offered ("" = none)
Effective string // what the link apps get: the pick, else Default
Default string // what they get without a pick: the user's own preset, the group's, the offer's default, the instance's
Options []string // what the owner offers for them, in order; empty = no choice
}
LinkDNS is the DNS of a person's link apps (Happ, the Mihomo apps, Xray JSON, sing-box): one for all servers. Effective and Default are "" only when no preset at all can be read.
type MihomoDNS ¶
type MihomoDNS struct {
Nameserver []string
DefaultNameserver []string // may be empty: the core's own defaults apply
ProxyServerNameserver []string // never empty ("system" at worst)
Policy []MihomoPolicy
// Direct are the suffix bodies (lower-case punycode, no leading dot) whose traffic goes DIRECT; they are exactly
// the suffixes of Policy.
Direct []string
// Providers are the rule providers of the country lists, and the RULE-SET rules to DIRECT that go with them, in order.
Providers []MihomoProvider
// Block are the rule providers of the ad list (Preset.BlockAds) and the RULE-SET rules to REJECT that go with them. Their
// rules come before every other rule, whatever the split says.
Block []MihomoProvider
// Notes (English) say what of the preset a Mihomo profile cannot carry.
Notes []string
}
MihomoDNS is the dns section and the direct suffixes of one preset.
type MihomoPolicy ¶
MihomoPolicy is one nameserver-policy entry: Domain is "+.<suffix>" (the suffix and its subdomains).
type MihomoProvider ¶ added in v0.1.64
type MihomoProvider struct {
Name string // "geosite-cn": the key of rule-providers and the name RULE-SET refers to
Behavior string // "domain" or "ipcidr"
URL string
}
MihomoProvider is one rule provider of a country list: a key of rule-providers.
func (MihomoProvider) Rule ¶ added in v0.1.64
func (p MihomoProvider) Rule() string
Rule is the rule line that sends the provider's traffic DIRECT. The address list is matched without a lookup.
func (MihomoProvider) RuleTo ¶ added in v0.1.67
func (p MihomoProvider) RuleTo(target string) string
RuleTo is the rule line that sends the provider's traffic to target (DIRECT, REJECT).
type NodeChoices ¶ added in v0.1.17
type NodeChoices struct {
// contains filtered or unexported fields
}
NodeChoices is what decides the DNS of one person on each node, read once: the offers of every node and the person's picks.
func NewNodeChoices ¶ added in v0.1.17
func NewNodeChoices(offers map[string][]store.NodeDNSOption, picks map[string]store.UserNodeDNS) NodeChoices
NewNodeChoices is NodeChoices over rows already read.
func (NodeChoices) Choice ¶ added in v0.1.17
func (c NodeChoices) Choice(nodeID string) string
Choice is the person's raw pick on the node, offered or not ("" = none).
func (NodeChoices) Default ¶ added in v0.1.17
func (c NodeChoices) Default(nodeID string) string
Default is the node's default preset ("" = none).
func (NodeChoices) Effective ¶ added in v0.1.17
func (c NodeChoices) Effective(nodeID string) string
Effective is the preset id that applies on the node by rules 1 and 2; "" when the node has no choice or no default and no pick (rule 3, the caller's fallback, applies).
func (NodeChoices) Options ¶ added in v0.1.17
func (c NodeChoices) Options(nodeID string) []string
Options lists the presets a node offers, in the owner's order; nil when it offers nothing.
func (NodeChoices) Pick ¶ added in v0.1.17
func (c NodeChoices) Pick(nodeID string) string
Pick is the person's pick on the node while the node still offers it, else "".
func (NodeChoices) UpdatedMs ¶ added in v0.1.17
func (c NodeChoices) UpdatedMs(nodeID string) int64
UpdatedMs is when the person picked on the node (Unix milliseconds, 0 = never).
type Preset ¶
type Preset struct {
ID, Name, Description string
Builtin bool
Servers []Server
Split []SplitRule
IPv4Only bool
// SplitDirect: the split rules' domains bypass the VPN (Happ can only send a split resolver's domains
// direct). Off = clients that cannot keep the split proxied ignore it.
SplitDirect bool
// BlockAds: the apps drop the domains of the category-ads-all list themselves, before any other rule
// (Mihomo, Xray, sing-box, Happ; AmneziaWG keys and the link list have no rules).
BlockAds bool
// Transport is the preferred transport (plain, dot, doh); see Resolve. Never empty for a stored preset.
Transport Kind
}
Preset is a DNS preset ready for use (validated, servers and split decoded).
func (Preset) ClientPlan ¶ added in v0.1.40
func (p Preset) ClientPlan(c Client) (main []Endpoint, split []SplitPlan, notes []string, err error)
ClientPlan is what a client can carry of a preset, before it is written in the client's syntax: the main endpoints (for every domain that is not split off), the split rules (only when SplitDirect is on; off = the split is ignored, with a note), and notes (English) on what was dropped. An error means no main endpoint can be carried; the caller leaves the dns section out. Mihomo, Xray and sing-box renderers share it.
IPv6 resolver addresses are left out when the client takes IPv6 but the profile switches IPv6 answers off (Mihomo): a resolver reached over IPv6 only adds noise. They are kept only when nothing else is left of a list and the preset allows IPv6.
func (Preset) DescriptionIn ¶ added in v0.1.17
DescriptionIn is the description in the language of the page. A built-in one is stored as "Russian\nEnglish" and is split; a description of an owner's own preset is one text, shown in any language.
func (Preset) EndpointsFor ¶
EndpointsFor is Resolve for the main servers of a preset: what the client gets for every domain that is not split off.
func (Preset) MihomoDNS ¶
MihomoDNS renders the preset for a Mihomo profile. group is the proxy group the main servers' queries go through ("" = no "#group", the queries use the core's own routing). An error means no main server can be expressed; the caller leaves the dns section out.
func (Preset) NameIn ¶ added in v0.1.17
NameIn is the name of the preset in the language of the page.
func (Preset) SingboxDNS ¶ added in v0.1.40
func (p Preset) SingboxDNS(group string) (SingboxDNS, error)
SingboxDNS renders the preset for a sing-box profile. group is the outbound (the selector) the main resolver's queries go through ("" = no detour). An error means no main server can be expressed; the caller leaves the dns block out.
func (Preset) SplitEndpointsFor ¶
SplitEndpointsFor is Resolve for the servers of split rule i of a preset.
type ProfileDNS ¶
type ProfileDNS struct {
RemoteType, RemoteDomain, RemoteIP, DomesticType, DomesticDomain, DomesticIP string
Hosts map[string]string
}
ProfileDNS is the DNS part of a routing profile of a preset: the two resolvers (type, DoH address, IP) and the host pins of DoH host names. It is what the owner's own routing profile takes from the person's preset; the preset's split and ad rules are not part of it.
func ProfileDNSOf ¶
func ProfileDNSOf(p Preset) (ProfileDNS, error)
ProfileDNSOf returns the DNS fields the Happ profile of the preset has (what HappRouting would carry in them). An error means no main server of the preset can be written in a profile.
type Server ¶
type Server struct {
Kind Kind `json:"kind,omitempty"`
Address string `json:"address,omitempty"`
Variant string `json:"variant,omitempty"`
}
Server is one resolver: a catalog variant (Variant set, see providers.go) or a custom address (Kind and Address).
func NormalizeServer ¶
NormalizeServer validates a server and returns it in canonical form.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service implements DnsService and answers "which preset applies to this user".
func (*Service) CreateDnsPreset ¶
func (*Service) DefaultPresetID ¶
DefaultPresetID returns the instance default as chosen by the admin ("" = the built-in default, also when the stored id no longer exists).
func (*Service) DeleteDnsPreset ¶
func (*Service) Effective ¶
Effective returns the preset that applies to a user and where it comes from: the user's own, else the user's group's, else the instance default, else the built-in default. store.ErrNotFound for an unknown user.
func (*Service) EffectiveOnNode ¶ added in v0.1.17
EffectiveOnNode is the preset that applies to a person on a node (rules 1 to 3 above).
func (*Service) GetUserDnsChoices ¶ added in v0.1.17
func (*Service) Handler ¶
Handler returns the Connect path and handler of DnsService (session checks are added by the HTTP server).
func (*Service) LinkEffective ¶ added in v0.1.43
LinkEffective is the preset of a person's link apps (see linkOf). store.ErrNotFound for an unknown user or when no preset can be read.
func (*Service) LinkOptions ¶ added in v0.1.43
LinkOptions is what the owner offers for the link apps, in order.
func (*Service) ListDnsPresets ¶
func (*Service) ListNodeDnsOptions ¶ added in v0.1.17
func (*Service) NodeChoices ¶ added in v0.1.17
NodeChoices reads the offers of every node and the picks of one person.
func (*Service) PresetByID ¶ added in v0.1.17
PresetByID loads one preset; store.ErrNotFound when it is gone.
func (*Service) Presets ¶ added in v0.1.23
Presets loads every preset, by id, in one query (a page names every preset its nodes offer). A row that cannot be decoded is left out, as a preset that is gone.
func (*Service) ResetUserDnsChoices ¶ added in v0.1.17
func (*Service) SetDefaultPresetID ¶
SetDefaultPresetID sets the instance default; "" selects the built-in default. ErrUnknownPreset when the id does not exist. A real change is written to the audit log (the settings page saves it with every edit).
func (*Service) SetLinkOptions ¶ added in v0.1.43
SetLinkOptions replaces what the owner offers for the link apps (the rules of a node's offer, checkOffer). A real change is written to the audit log as link_dns_options: how many presets and the default.
func (*Service) SetNodeDnsOptions ¶ added in v0.1.17
func (*Service) SubscriptionState ¶ added in v0.1.26
SubscriptionState reads node choices, presets and the effective preset in one D1 batch.
func (*Service) UpdateDnsPreset ¶
type SingboxDNS ¶ added in v0.1.40
type SingboxDNS struct {
Section SingboxSection
// Direct are the suffix bodies (lower-case punycode, no leading dot) whose traffic goes direct; they are exactly
// the suffixes of the DNS rules.
Direct []string
// RuleSets are the remote rule sets of the country lists (route.rule_set); DirectSets the tags of both lists of each, which
// the route rule sends direct.
RuleSets []SingboxRuleSet
DirectSets []string
// BlockSets are the tags of the ad list's rule set (Preset.BlockAds), whose first entry in RuleSets it is: the first DNS rule
// answers it NXDOMAIN and the route rule after ip_is_private rejects its connections.
BlockSets []string
// Notes (English) say what of the preset a sing-box profile cannot carry.
Notes []string
}
SingboxDNS is the dns block of one preset and what the assembler needs around it.
type SingboxDNSRule ¶ added in v0.1.40
type SingboxDNSRule struct {
DomainSuffix []string `json:"domain_suffix,omitempty"`
RuleSet []string `json:"rule_set,omitempty"`
Action string `json:"action"`
Server string `json:"server,omitempty"`
Rcode string `json:"rcode,omitempty"` // action predefined
}
SingboxDNSRule sends the queries of some suffixes to one server.
type SingboxRuleSet ¶ added in v0.1.64
type SingboxRuleSet struct {
Type string `json:"type"`
Tag string `json:"tag"`
Format string `json:"format"`
URL string `json:"url"`
}
SingboxRuleSet is one entry of route.rule_set: a remote binary list.
type SingboxSection ¶ added in v0.1.40
type SingboxSection struct {
Servers []SingboxServer `json:"servers"`
Rules []SingboxDNSRule `json:"rules,omitempty"`
Final string `json:"final"`
Strategy string `json:"strategy"`
}
SingboxSection is the JSON of the "dns" key.
type SingboxServer ¶ added in v0.1.40
type SingboxServer struct {
Type string `json:"type"`
Tag string `json:"tag"`
Server string `json:"server,omitempty"`
ServerPort int `json:"server_port,omitempty"` // only off the type's default port
Path string `json:"path,omitempty"` // DoH, only off /dns-query
TLS *SingboxServerTLS `json:"tls,omitempty"`
Detour string `json:"detour,omitempty"`
}
SingboxServer is one entry of dns.servers (types udp, tls, https and local).
type SingboxServerTLS ¶ added in v0.1.40
type SingboxServerTLS struct {
ServerName string `json:"server_name"`
}
SingboxServerTLS is the tls block of a DoT/DoH server.
type Source ¶
type Source string
Source tells where an effective preset comes from.
const ( SourceUser Source = store.DNSSourceUser SourceGroup Source = store.DNSSourceGroup SourceDefault Source = store.DNSSourceDefault )
type SplitPlan ¶ added in v0.1.40
type SplitPlan struct {
Rule int // index in Preset.Split
Endpoints []Endpoint // never empty
// Suffixes are the bodies (lower-case punycode, no leading dot) not claimed by an earlier rule: the first rule
// that names a suffix wins, like Happ's DirectSites. May be empty when every suffix was claimed earlier.
Suffixes []string
// Geo are the codes of the country lists and site categories (geo.go) not claimed by an earlier rule, first rule wins as with
// suffixes. A category alone has no address list.
Geo []string
}
SplitPlan is one split rule as a client carries it: the resolvers that answer its suffixes, and the suffixes.
type SplitRule ¶
type SplitRule struct {
Suffixes []string `json:"suffixes"`
Geo []string `json:"geo,omitempty"`
Servers []Server `json:"servers"`
}
SplitRule sends domains ending in one of Suffixes, and the sites of the countries in Geo, to Servers instead of the preset's main ones. A rule has suffixes or geo codes (see geo.go), or both.
type SubscriptionState ¶ added in v0.1.26
type SubscriptionState struct {
Choices NodeChoices
Presets map[string]Preset
Effective Preset
Link LinkDNS
}
SubscriptionState is the DNS read shared by the public user page and the access view. Effective is what applies where no node decides (the AmneziaWG keys of a node without a choice); Link is what the link apps get, Link.Default what they get without the person's pick.
type Variant ¶
type Variant struct {
ID string // "provider/variant"
NameRU, NameEN string
Category Category
Country string // ISO 3166-1 alpha-2 of a regional variant ("RU", "CN"); empty for the others
IPv4, IPv6 []string
NoPlain bool // the addresses do not answer plain DNS (they only bootstrap DoT/DoH)
DoTHost string // empty: no DoT endpoint
DoTPort int
DoHURL string // empty: no DoH endpoint
NoteRU, NoteEN string
}
Variant is one way to use a provider. The IP addresses answer plain DNS (primary first) and, being anycast addresses of the same service, also serve as the bootstrap addresses of the DoT and DoH host names.
type XrayDNS ¶ added in v0.1.40
type XrayDNS struct {
Section XraySection
// Direct are the suffix bodies (lower-case punycode, no leading dot) whose traffic goes direct; they are exactly
// the suffixes of the split servers.
Direct []string
// DirectGeo are the lists (geo.go) whose sites and addresses go direct: "geosite:cn" joins the domain rule, "geoip:cn" is
// a rule of its own (an ip rule; the config's domainStrategy AsIs keeps it to connections made to an address).
DirectGeo []XrayGeo
// Block are the lists whose domains the routing drops (Preset.BlockAds): "geosite:category-ads-all", sent to a blackhole
// outbound. The rule comes after the resolvers' and the OS's DNS rules and before private and direct.
Block []string
// DirectIPs are the addresses of the split resolvers: the routing rule for XrayDNSTag sends them direct (the
// main resolvers' traffic goes through the proxy).
DirectIPs []string
// Notes (English) say what of the preset an Xray config cannot carry.
Notes []string
}
XrayDNS is the dns block of one preset and what the assembler needs around it.
type XrayGeo ¶ added in v0.1.64
type XrayGeo struct{ Site, IP string }
XrayGeo is one country list as Xray names it; IP is empty for a site category alone.
type XraySection ¶ added in v0.1.40
type XraySection struct {
Tag string `json:"tag"`
QueryStrategy string `json:"queryStrategy"`
Hosts map[string]string `json:"hosts,omitempty"`
Servers []XrayServer `json:"servers"`
}
XraySection is the JSON of the "dns" key.