Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
475 changes: 475 additions & 0 deletions app/schemas/io.nekohasekai.sagernet.database.SagerDatabase/37.json

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions app/src/main/java/io/nekohasekai/sagernet/Constants.kt
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,8 @@ object Key {
const val GROUP_LANDING_PROXY_OUTBOUND = "groupLandingOutbound"
const val GROUP_FRONT_PROXY = "groupFrontProxy"
const val GROUP_LANDING_PROXY = "groupLandingProxy"
const val GROUP_UTLS_FINGERPRINT_FOR_TLS = "groupUTLSFingerprintForTLS"
const val GROUP_UTLS_FINGERPRINT_FOR_REALITY = "groupUTLSFingerprintForReality"

const val GROUP_SUBSCRIPTION = "groupSubscription"
const val SUBSCRIPTION_TYPE = "subscriptionType"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,8 @@ object DataStore : OnPreferenceDataStoreChangeListener {
var landingProxyOutbound by profileCacheStore.long(Key.GROUP_LANDING_PROXY_OUTBOUND)
var frontProxy by profileCacheStore.stringToInt(Key.GROUP_FRONT_PROXY)
var landingProxy by profileCacheStore.stringToInt(Key.GROUP_LANDING_PROXY)
var groupUTLSFingerprintForTLS by profileCacheStore.string(Key.GROUP_UTLS_FINGERPRINT_FOR_TLS)
var groupUTLSFingerprintForReality by profileCacheStore.string(Key.GROUP_UTLS_FINGERPRINT_FOR_REALITY)

var serverConfig by profileCacheStore.string(Key.SERVER_CONFIG)

Expand Down
12 changes: 10 additions & 2 deletions app/src/main/java/io/nekohasekai/sagernet/database/ProxyGroup.kt
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ data class ProxyGroup(
var subscription: SubscriptionBean? = null,
var order: Int = GroupOrder.ORIGIN,
@ColumnInfo(defaultValue = (-1L).toString()) var frontProxy: Long = -1L,
@ColumnInfo(defaultValue = (-1L).toString()) var landingProxy: Long = -1L
@ColumnInfo(defaultValue = (-1L).toString()) var landingProxy: Long = -1L,
@ColumnInfo(defaultValue = "") var utlsFingerprintForTLS: String = "",
@ColumnInfo(defaultValue = "") var utlsFingerprintForReality: String = "",
) : Serializable() {

@Transient
Expand All @@ -57,7 +59,7 @@ data class ProxyGroup(
val subscription = subscription!!
subscription.serializeForShare(output)
} else {
output.writeInt(1)
output.writeInt(2)
output.writeLong(id)
output.writeLong(userOrder)
output.writeBoolean(ungrouped)
Expand All @@ -69,6 +71,8 @@ data class ProxyGroup(
output.writeInt(order)
output.writeLong(frontProxy)
output.writeLong(landingProxy)
output.writeString(utlsFingerprintForTLS)
output.writeString(utlsFingerprintForReality)
}
}

Expand Down Expand Up @@ -97,6 +101,10 @@ data class ProxyGroup(
frontProxy = input.readLong()
landingProxy = input.readLong()
}
if (version >= 2) {
utlsFingerprintForTLS = input.readString()
utlsFingerprintForReality = input.readString()
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import kotlinx.coroutines.launch

@Database(
entities = [ProxyGroup::class, ProxyEntity::class, RuleEntity::class, StatsEntity::class, AssetEntity::class],
version = 36,
version = 37,
autoMigrations = [AutoMigration(
from = 12,
to = 14,
Expand Down Expand Up @@ -105,6 +105,9 @@ import kotlinx.coroutines.launch
from = 35,
to = 36,
spec = SagerDatabase_Migration_35_36::class
), AutoMigration(
from = 36,
to = 37,
)]
)
@TypeConverters(value = [KryoConverters::class, GsonConverters::class])
Expand Down
14 changes: 14 additions & 0 deletions app/src/main/java/io/nekohasekai/sagernet/fmt/ConfigBuilder.kt
Original file line number Diff line number Diff line change
Expand Up @@ -602,6 +602,10 @@ fun buildV2RayConfig(
val bean = proxyEntity.requireBean()
currentOutbound = OutboundObject()

val proxyGroup = SagerDatabase.groupDao.getById(proxyEntity.groupId)
val groupUTLSFingerprintForTLS = proxyGroup?.utlsFingerprintForTLS ?: ""
val groupUTLSFingerprintForReality = proxyGroup?.utlsFingerprintForReality ?: ""

val tagIn: String
var needGlobal: Boolean

Expand Down Expand Up @@ -888,6 +892,8 @@ fun buildV2RayConfig(
val overrideFingerprint = DataStore.experimentalFlagsProperties.getProperty("overrideUTLSFingerprintForTLS")
if (!overrideFingerprint.isNullOrEmpty()) {
fingerprint = overrideFingerprint
} else if (!groupUTLSFingerprintForTLS.isNotEmpty()) {
fingerprint = groupUTLSFingerprintForTLS
} else if (bean.utlsFingerprint.isNotEmpty()) {
fingerprint = bean.utlsFingerprint
}
Expand Down Expand Up @@ -918,6 +924,8 @@ fun buildV2RayConfig(
val overrideFingerprint = DataStore.experimentalFlagsProperties.getProperty("overrideUTLSFingerprintForREALITY")
if (!overrideFingerprint.isNullOrEmpty()) {
fingerprint = overrideFingerprint
} else if (groupUTLSFingerprintForReality.isNotEmpty()) {
fingerprint = groupUTLSFingerprintForReality
} else if (bean.realityFingerprint.isNotEmpty()) {
fingerprint = bean.realityFingerprint
}
Expand Down Expand Up @@ -1616,6 +1624,8 @@ fun buildV2RayConfig(
val overrideFingerprint = DataStore.experimentalFlagsProperties.getProperty("overrideUTLSFingerprintForTLS")
if (!overrideFingerprint.isNullOrEmpty()) {
fingerprint = overrideFingerprint
} else if (groupUTLSFingerprintForTLS.isNotEmpty()) {
fingerprint = groupUTLSFingerprintForTLS
} else if (bean.utlsFingerprint.isNotEmpty()) {
fingerprint = bean.utlsFingerprint
}
Expand Down Expand Up @@ -1643,6 +1653,8 @@ fun buildV2RayConfig(
val overrideFingerprint = DataStore.experimentalFlagsProperties.getProperty("overrideUTLSFingerprintForREALITY")
if (!overrideFingerprint.isNullOrEmpty()) {
fingerprint = overrideFingerprint
} else if (groupUTLSFingerprintForReality.isNotEmpty()) {
fingerprint = groupUTLSFingerprintForReality
} else if (bean.realityFingerprint.isNotEmpty()) {
fingerprint = bean.realityFingerprint
}
Expand Down Expand Up @@ -1833,6 +1845,8 @@ fun buildV2RayConfig(
val overrideFingerprint = DataStore.experimentalFlagsProperties.getProperty("overrideUTLSFingerprintForTLS")
if (!overrideFingerprint.isNullOrEmpty()) {
fingerprint = overrideFingerprint
} else if (groupUTLSFingerprintForTLS.isNotEmpty()) {
fingerprint = groupUTLSFingerprintForTLS
} else if (bean.utlsFingerprint.isNotEmpty()) {
fingerprint = bean.utlsFingerprint
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ class GroupSettingsActivity(
DataStore.landingProxyOutbound = landingProxy
DataStore.frontProxy = if (frontProxy >= 0) 1 else 0
DataStore.landingProxy = if (landingProxy >= 0) 1 else 0
DataStore.groupUTLSFingerprintForTLS = utlsFingerprintForTLS
DataStore.groupUTLSFingerprintForReality = utlsFingerprintForReality
}

fun ProxyGroup.serialize() {
Expand All @@ -116,6 +118,8 @@ class GroupSettingsActivity(

frontProxy = if (DataStore.frontProxy == 1) DataStore.frontProxyOutbound else -1
landingProxy = if (DataStore.landingProxy == 1) DataStore.landingProxyOutbound else -1
utlsFingerprintForTLS = DataStore.groupUTLSFingerprintForTLS
utlsFingerprintForReality = DataStore.groupUTLSFingerprintForReality
if (type == GroupType.SUBSCRIPTION) {
subscription = SubscriptionBean().applyDefaultValues().apply {
type = DataStore.subscriptionType
Expand Down
16 changes: 16 additions & 0 deletions app/src/main/res/xml/group_preferences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,22 @@
app:key="groupLandingProxy"
app:title="@string/landing_proxy" />

<io.nekohasekai.sagernet.widget.SimpleMenuPreference
app:icon="@drawable/ic_baseline_fingerprint_24"
app:entries="@array/utls_entry"
app:entryValues="@array/utls_value"
app:key="groupUTLSFingerprintForTLS"
app:title="@string/utls_fingerprint"
app:useSimpleSummaryProvider="true" />

<io.nekohasekai.sagernet.widget.SimpleMenuPreference
app:icon="@drawable/ic_baseline_fingerprint_24"
app:entries="@array/reality_fingerprint_value"
app:entryValues="@array/reality_fingerprint_value"
app:key="groupUTLSFingerprintForReality"
app:title="@string/reality_fingerprint"
app:useSimpleSummaryProvider="true" />

<PreferenceCategory
app:key="groupSubscription"
app:title="@string/subscription_settings">
Expand Down
2 changes: 1 addition & 1 deletion version.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
PACKAGE_NAME=com.github.dyhkwong.sagernet
VERSION_NAME=0.17.46
VERSION_CODE=364
VERSION_CODE=365

NAIVE_VERSION_NAME=149.0.7827.114-1
NAIVE_VERSION=275
Expand Down