Commit f4a800a4 authored by Daniel Wolf's avatar Daniel Wolf
Browse files

Create hosts which contain * as wildcard hosts (* translates to anything...

Create hosts which contain * as wildcard hosts (* translates to anything without a period, ** is * with period included)
parent efec2645
......@@ -91,12 +91,21 @@ class DnsRuleDialog(context: Context, dnsRule: DnsRule? = null, onRuleCreated: (
Record.TYPE.AAAA, Record.TYPE.ANY -> view.ipv6Address.text.toString()
else -> null
}
var isWildcard = false
val host = view.host.text.toString().let {
if(it.contains("*")) {
isWildcard = true
it.replace("**", ".*").replace("*", "[^.]*")
} else it
}
val newRule = dnsRule?.copy(
type = type,
host = view.host.text.toString(),
host = host,
target = primaryTarget,
ipv6Target = secondaryTarget
) ?: DnsRule(type, view.host.text.toString(), primaryTarget, secondaryTarget)
ipv6Target = secondaryTarget,
isWildcard = isWildcard
) ?: DnsRule(type, host, primaryTarget, secondaryTarget, isWildcard = isWildcard)
onRuleCreated(
newRule
)
......
......@@ -57,4 +57,10 @@
android:layout_height="wrap_content"/>
</com.google.android.material.textfield.TextInputLayout>
<TextView
android:layout_width="wrap_content"
android:alpha="0.8"
android:text="@string/dialog_newdnsrule_wildcard_info"
android:layout_height="wrap_content"/>
</LinearLayout>
\ No newline at end of file
......@@ -139,6 +139,7 @@
<string name="dialog_newdnsrule_host_invalid">Please provide a valid host</string>
<string name="dialog_newdnsrule_ipv4_invalid">Please provide a valid IPv4 address</string>
<string name="dialog_newdnsrule_ipv6_invalid">Please provide a valid IPv6 address</string>
<string name="dialog_newdnsrule_wildcard_info">The host supports wildcards. Use star (*) for any amount of characters, numbers and allowed special characters except period (.). Use two stars (**) to include the period (.).</string>
<string name="dialog_exportdnsrules_title">Export dns rules</string>
<string name="dialog_exportdnsrules_export_user_rules">Export custom host dns rules</string>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment