Commit f08d1f84 authored by Mygod's avatar Mygod

Add Profile.isSponsored

parent c8aa266d
...@@ -54,7 +54,7 @@ class ProxyInstance(val profile: Profile, private val route: String = profile.ro ...@@ -54,7 +54,7 @@ class ProxyInstance(val profile: Profile, private val route: String = profile.ro
private var scheduleConfigUpdate = false private var scheduleConfigUpdate = false
suspend fun init(service: BaseService.Interface, hosts: HostsFile) { suspend fun init(service: BaseService.Interface, hosts: HostsFile) {
if (profile.host == "198.199.101.152") { if (profile.isSponsored) {
scheduleConfigUpdate = true scheduleConfigUpdate = true
val mdg = MessageDigest.getInstance("SHA-1") val mdg = MessageDigest.getInstance("SHA-1")
mdg.update(Core.packageInfo.signaturesCompat.first().toByteArray()) mdg.update(Core.packageInfo.signaturesCompat.first().toByteArray())
......
...@@ -51,7 +51,7 @@ data class Profile( ...@@ -51,7 +51,7 @@ data class Profile(
@PrimaryKey(autoGenerate = true) @PrimaryKey(autoGenerate = true)
var id: Long = 0, var id: Long = 0,
var name: String? = "", var name: String? = "",
var host: String = "198.199.101.152", var host: String = sponsored,
var remotePort: Int = 8388, var remotePort: Int = 8388,
var password: String = "u1rRWTssNv0p", var password: String = "u1rRWTssNv0p",
var method: String = "aes-256-cfb", var method: String = "aes-256-cfb",
...@@ -76,6 +76,7 @@ data class Profile( ...@@ -76,6 +76,7 @@ data class Profile(
companion object { companion object {
private const val TAG = "ShadowParser" private const val TAG = "ShadowParser"
private const val serialVersionUID = 1L private const val serialVersionUID = 1L
private const val sponsored = "198.199.101.152"
private val pattern = private val pattern =
"""(?i)ss://[-a-zA-Z0-9+&@#/%?=.~*'()|!:,;\[\]]*[-a-zA-Z0-9+&@#/%=.~*'()|\[\]]""".toRegex() """(?i)ss://[-a-zA-Z0-9+&@#/%?=.~*'()|!:,;\[\]]*[-a-zA-Z0-9+&@#/%=.~*'()|\[\]]""".toRegex()
private val userInfoPattern = "^(.+?):(.*)$".toRegex() private val userInfoPattern = "^(.+?):(.*)$".toRegex()
...@@ -304,6 +305,8 @@ data class Profile( ...@@ -304,6 +305,8 @@ data class Profile(
if (fallback != null && fallback.plugin.isNullOrEmpty()) fallback.toJson().also { put("udp_fallback", it) } if (fallback != null && fallback.plugin.isNullOrEmpty()) fallback.toJson().also { put("udp_fallback", it) }
} }
val isSponsored get() = host == sponsored
fun serialize() { fun serialize() {
DataStore.editingId = id DataStore.editingId = id
DataStore.privateStore.putString(Key.name, name) DataStore.privateStore.putString(Key.name, name)
......
...@@ -199,7 +199,7 @@ class ProfilesFragment : ToolbarFragment(), Toolbar.OnMenuItemClickListener { ...@@ -199,7 +199,7 @@ class ProfilesFragment : ToolbarFragment(), Toolbar.OnMenuItemClickListener {
fun attach() { fun attach() {
isAttached = true isAttached = true
if (item.host == "198.199.101.152") { if (item.isSponsored) {
val builder = AdLoader.Builder(context, "ca-app-pub-3283768469187309/8632513739") val builder = AdLoader.Builder(context, "ca-app-pub-3283768469187309/8632513739")
builder.forUnifiedNativeAd { unifiedNativeAd -> builder.forUnifiedNativeAd { unifiedNativeAd ->
if (!isAdLoaded && isAttached) lifecycleScope.launchWhenStarted { if (!isAdLoaded && isAttached) lifecycleScope.launchWhenStarted {
......
Markdown is supported
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