Skip to content

Commit

Permalink
add udp proxy fqdn
Browse files Browse the repository at this point in the history
  • Loading branch information
Asutorufa committed Jun 8, 2024
1 parent 2151f62 commit ec16ff0
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 5 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ android {

dependencies {
implementation(fileTree(mapOf("include" to listOf("*.aar", "*.jar"), "dir" to "libs")))
implementation("androidx.appcompat:appcompat:1.6.1")
implementation("androidx.appcompat:appcompat:1.7.0")
implementation("androidx.preference:preference-ktx:1.2.1")
implementation("com.google.android.material:material:1.12.0")
implementation("androidx.browser:browser:1.8.0")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,20 @@ class RulePreferenceFragment : PreferenceFragmentCompat() {
profile.bypass.udp = strToBypassType(newValue as String).value
}
}

findPreference<SwitchPreferenceCompat>(resources.getString(R.string.udp_proxy_fqdn))!!.also {
it.isChecked = profile.udpProxyFqdn
setOnPreferenceChangeListener(it) { _, newValue ->
profile.udpProxyFqdn = newValue as Boolean
}
}
}

override fun onDisplayPreferenceDialog(preference: Preference) {
when (preference) {
is ListPreference, is EditTextPreference, is MultiSelectListPreference ->
showDialog(preference)

else -> super.onDisplayPreferenceDialog(preference)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ data class Profile (
defaultValue = Bypass.DefaultJson
) var bypass: Bypass = Bypass.Default,

@ColumnInfo(name = "udp_proxy_fqdn", defaultValue = "0")
var udpProxyFqdn: Boolean = false,

@ColumnInfo(
name = "hosts",
defaultValue = "{}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import androidx.sqlite.db.SupportSQLiteDatabase

@Database(
entities = [Profile::class, LastProfile::class],
version = 11,
version = 12,
exportSchema = false
)
@TypeConverters(Converters::class)
Expand Down Expand Up @@ -45,7 +45,7 @@ abstract class YuhaiinDatabase : RoomDatabase() {
.addMigrations(
MIGRATION_2_3, MIGRATION_3_4, MIGRATION_4_5, MIGRATION_5_6,
MIGRATION_6_7, MIGRATION_7_8, MIGRATION_8_9, MIGRATION_9_10,
MIGRATION_10_11
MIGRATION_10_11, MIGRATION_11_12
)
.build()
}
Expand Down Expand Up @@ -98,5 +98,10 @@ abstract class YuhaiinDatabase : RoomDatabase() {
db.execSQL("ALTER TABLE profile ADD COLUMN fake_dnsv6_cidr TEXT NOT NULL DEFAULT 'fc00::/64'")
}
}
private val MIGRATION_11_12 = object : Migration(11, 12) {
override fun migrate(db: SupportSQLiteDatabase) {
db.execSQL("ALTER TABLE profile ADD COLUMN udp_proxy_fqdn INTEGER NOT NULL DEFAULT 0")
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,7 @@ class YuhaiinVpnService : VpnService() {
setMtu(VPN_MTU)
setSession(profile.name)

addAddress(PRIVATE_VLAN4_ADDRESS, 24).
addRoute(PRIVATE_VLAN4_PORTAL, 32)
addAddress(PRIVATE_VLAN4_ADDRESS, 24).addRoute(PRIVATE_VLAN4_PORTAL, 32)

// Route all IPv6 traffic
addAddress(PRIVATE_VLAN6_ADDRESS, 64)
Expand Down Expand Up @@ -294,6 +293,7 @@ class YuhaiinVpnService : VpnService() {
direct = profile.ruleDirect
tcp = profile.bypass.tcp
udp = profile.bypass.udp
udpSkipResolveFqdn = profile.udpProxyFqdn
}

tun = TUN().apply {
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
<item>@string/bypass_proxy</item>
<item>@string/bypass_block</item>
</string-array>
<string name="udp_proxy_fqdn">UDP proxy FQDN</string>


<string name="adv_dns_Key">dns</string>
Expand Down
6 changes: 6 additions & 0 deletions app/src/main/res/xml/rule.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@
app:useSimpleSummaryProvider="true"
android:entryValues="@array/adv_bypass_mode" />

<SwitchPreferenceCompat
android:icon="@drawable/vpn_key"
android:key="@string/udp_proxy_fqdn"
android:title="@string/udp_proxy_fqdn"
android:layout_height="match_parent" />

<EditTextPreference
android:key="@string/rule_direct"
android:title="@string/rule_direct_title"
Expand Down

0 comments on commit ec16ff0

Please sign in to comment.