Added DNS configuration functionality. (#24)

* Changed app icon from default to Yggdrasil leaf.

* Added workaround for DNS-reslver and fix for unmetered networks.

* Added DNS configuration functionality.

* Changed DNS configuration UI. Disabled DNS config by default. Added DNS fix for Chrome-based browsers.
This commit is contained in:
Revertron 2022-10-30 22:14:30 +01:00 committed by GitHub
parent 24573625a4
commit 772dfdef8c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 620 additions and 26 deletions

View file

@ -0,0 +1,245 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".DnsActivity">
<FrameLayout
android:id="@+id/settings"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:dividerPadding="4pt"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/pageTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="8pt"
android:text="@string/dns_activity_title"
android:textColor="?attr/textDefault"
android:textSize="24sp"
android:textStyle="bold" />
<Space
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1" />
<ImageButton
android:id="@+id/addServerButton"
android:layout_width="16pt"
android:layout_height="16pt"
android:layout_marginTop="6pt"
android:layout_marginRight="8pt"
android:background="@android:color/transparent"
app:srcCompat="@drawable/ic_baseline_add_circle_24" />
</LinearLayout>
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:id="@+id/configuredDnsLabel"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="16pt"
android:layout_marginLeft="16pt"
android:layout_marginTop="8pt"
android:layout_marginEnd="8pt"
android:layout_marginRight="8pt"
android:layout_marginBottom="2pt"
android:alpha="0.7"
android:paddingRight="8pt"
android:text=""
android:textAllCaps="true"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textSize="12sp" />
<TableLayout
android:id="@+id/configuredDnsTableLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="8pt"
android:layout_marginLeft="8pt"
android:layout_marginEnd="8pt"
android:layout_marginRight="8pt"
android:background="@drawable/rounded"
android:divider="#46878787"
android:dividerPadding="4pt"
android:paddingLeft="4pt"
android:paddingTop="2pt"
android:paddingRight="4pt"
android:paddingBottom="2pt"
android:showDividers="middle" />
<TextView
android:id="@+id/configuredDnsHint"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="16pt"
android:layout_marginLeft="16pt"
android:layout_marginTop="4pt"
android:layout_marginEnd="8pt"
android:layout_marginRight="8pt"
android:layout_marginBottom="4pt"
android:alpha="0.7"
android:paddingRight="8pt"
android:text="@string/dns_configured_servers_hint"
android:textAllCaps="false"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textSize="12sp" />
<TextView
android:id="@+id/usableDnsLabel"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="16pt"
android:layout_marginLeft="16pt"
android:layout_marginTop="8pt"
android:layout_marginEnd="8pt"
android:layout_marginRight="8pt"
android:layout_marginBottom="2pt"
android:alpha="0.7"
android:paddingRight="8pt"
android:text="@string/dns_usable_servers"
android:textAllCaps="true"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textSize="12sp" />
<TableLayout
android:id="@+id/usableDnsTableLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="8pt"
android:layout_marginLeft="8pt"
android:layout_marginEnd="8pt"
android:layout_marginRight="8pt"
android:background="@drawable/rounded"
android:divider="#46878787"
android:dividerPadding="4pt"
android:paddingLeft="4pt"
android:paddingTop="2pt"
android:paddingRight="4pt"
android:paddingBottom="2pt"
android:showDividers="middle" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="16pt"
android:layout_marginLeft="16pt"
android:layout_marginTop="4pt"
android:layout_marginEnd="8pt"
android:layout_marginRight="8pt"
android:layout_marginBottom="4pt"
android:alpha="0.7"
android:paddingRight="8pt"
android:text="@string/dns_usable_servers_hint"
android:textAllCaps="false"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textSize="12sp" />
<Space
android:layout_width="match_parent"
android:layout_height="32px" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="16pt"
android:layout_marginLeft="16pt"
android:layout_marginEnd="8pt"
android:layout_marginRight="8pt"
android:layout_marginBottom="2pt"
android:alpha="0.7"
android:paddingRight="8pt"
android:text="@string/dns_fixes"
android:textAllCaps="true"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textSize="12sp" />
<TableLayout
android:id="@+id/fixesTableLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="8pt"
android:layout_marginLeft="8pt"
android:layout_marginEnd="8pt"
android:layout_marginRight="8pt"
android:background="@drawable/rounded"
android:divider="#46878787"
android:dividerPadding="4pt"
android:paddingLeft="4pt"
android:paddingTop="2pt"
android:paddingRight="4pt"
android:paddingBottom="2pt"
android:showDividers="middle">
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clickable="true"
android:paddingStart="4pt"
android:paddingTop="2pt"
android:paddingEnd="4pt"
android:paddingBottom="4pt">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/dns_fix_chrome_based_browsers"
android:textColor="?attr/textDefault" />
<Space
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="2" />
<Switch
android:id="@+id/enableChromeFix"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</TableRow>
</TableLayout>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="16pt"
android:layout_marginLeft="16pt"
android:layout_marginTop="4pt"
android:layout_marginEnd="8pt"
android:layout_marginRight="8pt"
android:alpha="0.7"
android:paddingRight="8pt"
android:text="@string/dns_fix_chrome_based_browsers_hint"
android:textAllCaps="false"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textSize="12sp" />
</LinearLayout>
</ScrollView>
</LinearLayout>
</FrameLayout>
</LinearLayout>

View file

@ -94,7 +94,7 @@
android:layout_weight="2" />
<Switch
android:id="@+id/enableMulticastBeacon"
android:id="@+id/enableYggdrasil"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
@ -347,6 +347,50 @@
app:srcCompat="@drawable/ic_baseline_chevron_right_24" />
</TableRow>
<TableRow
android:id="@+id/dnsTableRow"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?android:attr/selectableItemBackground"
android:clickable="true"
android:paddingStart="4pt"
android:paddingTop="6pt"
android:paddingEnd="4pt"
android:paddingBottom="6pt">
<TextView
android:id="@+id/dnsLabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="DNS servers"
android:textColor="?attr/textDefault" />
<Space
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="2" />
<TextView
android:id="@+id/dnsValue"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:alpha="0.5"
android:text="No servers"
android:textAlignment="textEnd" />
<ImageView
android:id="@+id/dnsChevron"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginLeft="2pt"
android:alpha="0.4"
android:cropToPadding="false"
android:scaleType="fitEnd"
android:scaleX="1.2"
android:scaleY="1.2"
app:srcCompat="@drawable/ic_baseline_chevron_right_24" />
</TableRow>
<TableRow
android:id="@+id/settingsTableRow"
android:layout_width="match_parent"
@ -426,12 +470,12 @@
android:layout_height="wrap_content"
android:layout_marginStart="16pt"
android:layout_marginLeft="16pt"
android:layout_marginTop="2pt"
android:layout_marginTop="4pt"
android:layout_marginEnd="8pt"
android:layout_marginRight="8pt"
android:alpha="0.7"
android:paddingRight="8pt"
android:text="You must re-enable Yggdrasil after modifying Peers or Settings to make any changes effective."
android:text="You must re-enable Yggdrasil after modifying Peers, DNS servers or Settings to make any changes effective."
android:textAllCaps="false"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textSize="12sp" />

View file

@ -128,7 +128,7 @@
android:layout_height="wrap_content"
android:layout_marginStart="16pt"
android:layout_marginLeft="16pt"
android:layout_marginTop="2pt"
android:layout_marginTop="4pt"
android:layout_marginEnd="8pt"
android:layout_marginRight="8pt"
android:layout_marginBottom="4pt"
@ -237,7 +237,7 @@
android:layout_height="wrap_content"
android:layout_marginStart="16pt"
android:layout_marginLeft="16pt"
android:layout_marginTop="2pt"
android:layout_marginTop="4pt"
android:layout_marginEnd="8pt"
android:layout_marginRight="8pt"
android:alpha="0.7"

View file

@ -0,0 +1,34 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingLeft="10pt"
android:paddingTop="4pt"
android:paddingRight="10pt"
android:paddingBottom="4pt">
<TextView
android:id="@+id/textView2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Enter the IP address of DNS server to add. It will be used by OS and all apps when Yggdrasil starts." />
<com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/addDnsInput"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="4pt"
android:lines="1"
android:hint="8.8.8.8 or 302:7991::53" />
</com.google.android.material.textfield.TextInputLayout>
</LinearLayout>
</FrameLayout>

View file

@ -27,6 +27,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="4pt"
android:lines="1"
android:hint="tcp://address:port" />
</com.google.android.material.textfield.TextInputLayout>
</LinearLayout>

View file

@ -0,0 +1,47 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/tableRow"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/serverValue"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="18dp"
android:layout_marginTop="4dp"
android:layout_marginEnd="18dp"
android:layout_marginBottom="12dp"
android:ellipsize="end"
android:singleLine="true"
android:text=""
android:textColor="?attr/textDefault"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/addButton"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@+id/space" />
<Space
android:id="@+id/space"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintBottom_toTopOf="@+id/addButton"
app:layout_constraintEnd_toStartOf="@+id/addButton"
app:layout_constraintStart_toEndOf="@+id/serverValue"
app:layout_constraintTop_toTopOf="@+id/addButton" />
<ImageButton
android:id="@+id/addButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_marginEnd="4dp"
android:layout_marginBottom="10dp"
android:background="@android:color/transparent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/ic_baseline_add_circle_24" />
</androidx.constraintlayout.widget.ConstraintLayout>

View file

@ -1,7 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/tableRow"
android:layout_width="match_parent"
android:layout_height="wrap_content">
@ -16,7 +15,7 @@
android:layout_marginBottom="12dp"
android:ellipsize="end"
android:singleLine="true"
android:text="TextView"
android:text=""
android:textColor="?attr/textDefault"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/deletePeerButton"

View file

@ -1,3 +1,20 @@
<resources>
<string name="app_name">Yggdrasil</string>
<string name="dns_configured_servers_hint">Yggdrasil will use these DNS servers in VPN config when service starts. All your DNS requests will be resolved by them.</string>
<string name="dns_configured_servers_hint_empty">Yggdrasil will not configure any DNS servers when service starts. All your DNS requests will be resolved by system resolver.</string>
<string name="dns_usable_servers_hint">These are DNS servers run by community members. Click plus button to add them to a list above. Long-tap to see more info.</string>
<string name="dns_no_configured_servers">No servers configured</string>
<string name="dns_configured_servers">Configured servers</string>
<string name="dns_server_info_revertron">The server supports resolving regular ICANN domains, ALFIS domains, OpenNIC domains.\n\nAlso, it blocks ads, analytics and malware websites.\n\nThe server is run by Revertron.</string>
<string name="dns_server_info_dialog_title">Server info</string>
<string name="ok">OK</string>
<string name="cancel">Cancel</string>
<string name="remove">Remove</string>
<string name="add">Add</string>
<string name="dns_add_server_dialog_title">Add DNS server</string>
<string name="dns_activity_title">DNS</string>
<string name="dns_usable_servers">Usable servers</string>
<string name="dns_fix_chrome_based_browsers">Fix Chrome-based browsers</string>
<string name="dns_fix_chrome_based_browsers_hint">Chrome-based browsers need an additional fix to understand that you have IPv6 connectivity.</string>
<string name="dns_fixes">DNS fixes</string>
</resources>