CountryRule

open class CountryRule: Rule

The rule matches the session based on the geographical location of the corresponding IP address.

  • The ISO code of the country.

    Declaration

    Swift

    open let countryCode: String
  • The rule should match the session which matches the country or not.

    Declaration

    Swift

    open let match: Bool
  • Undocumented

    Declaration

    Swift

    open class CountryRule: Rule
  • Create a new CountryRule instance.

    Declaration

    Swift

    public init(countryCode: String, match: Bool, adapterFactory: AdapterFactory)

    Parameters

    countryCode

    The ISO code of the country.

    match

    The rule should match the session which matches the country or not.

    adapterFactory

    The factory which builds a corresponding adapter when needed.

  • Match DNS request to this rule.

    Declaration

    Swift

    override open func matchDNS(_ session: DNSSession, type: DNSSessionMatchType) -> DNSSessionMatchResult

    Parameters

    session

    The DNS session to match.

    type

    What kind of information is available.

    Return Value

    The result of match.

  • Match connect session to this rule.

    Declaration

    Swift

    override open func match(_ session: ConnectSession) -> AdapterFactory?

    Parameters

    session

    connect session to match.

    Return Value

    The configured adapter if matched, return nil if not matched.