DNS fix and allow non 9000 port (#9019)
This commit is contained in:
parent
bc7d8c8672
commit
d058e32c2c
|
@ -5,7 +5,7 @@ ext {
|
||||||
extName = 'Mango'
|
extName = 'Mango'
|
||||||
pkgNameSuffix = 'all.mango'
|
pkgNameSuffix = 'all.mango'
|
||||||
extClass = '.Mango'
|
extClass = '.Mango'
|
||||||
extVersionCode = 4
|
extVersionCode = 5
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
|
|
|
@ -22,6 +22,7 @@ import eu.kanade.tachiyomi.source.model.SManga
|
||||||
import eu.kanade.tachiyomi.source.online.HttpSource
|
import eu.kanade.tachiyomi.source.online.HttpSource
|
||||||
import info.debatty.java.stringsimilarity.JaroWinkler
|
import info.debatty.java.stringsimilarity.JaroWinkler
|
||||||
import info.debatty.java.stringsimilarity.Levenshtein
|
import info.debatty.java.stringsimilarity.Levenshtein
|
||||||
|
import okhttp3.Dns
|
||||||
import okhttp3.FormBody
|
import okhttp3.FormBody
|
||||||
import okhttp3.Headers
|
import okhttp3.Headers
|
||||||
import okhttp3.Interceptor
|
import okhttp3.Interceptor
|
||||||
|
@ -184,6 +185,7 @@ class Mango : ConfigurableSource, HttpSource() {
|
||||||
override val supportsLatest = false
|
override val supportsLatest = false
|
||||||
|
|
||||||
override val baseUrl by lazy { getPrefBaseUrl() }
|
override val baseUrl by lazy { getPrefBaseUrl() }
|
||||||
|
private val port by lazy { getPrefPort() }
|
||||||
private val username by lazy { getPrefUsername() }
|
private val username by lazy { getPrefUsername() }
|
||||||
private val password by lazy { getPrefPassword() }
|
private val password by lazy { getPrefPassword() }
|
||||||
private val gson by lazy { Gson() }
|
private val gson by lazy { Gson() }
|
||||||
|
@ -199,6 +201,7 @@ class Mango : ConfigurableSource, HttpSource() {
|
||||||
|
|
||||||
override val client: OkHttpClient =
|
override val client: OkHttpClient =
|
||||||
network.client.newBuilder()
|
network.client.newBuilder()
|
||||||
|
.dns(Dns.SYSTEM)
|
||||||
.addInterceptor { authIntercept(it) }
|
.addInterceptor { authIntercept(it) }
|
||||||
.build()
|
.build()
|
||||||
|
|
||||||
|
@ -211,7 +214,7 @@ class Mango : ConfigurableSource, HttpSource() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Do the login if we have not gotten the cookies yet
|
// Do the login if we have not gotten the cookies yet
|
||||||
if (apiCookies.isEmpty() || !apiCookies.contains("mango-sessid-9000", true)) {
|
if (apiCookies.isEmpty() || !apiCookies.contains("mango-sessid-$port", true)) {
|
||||||
doLogin(chain)
|
doLogin(chain)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -243,16 +246,17 @@ class Mango : ConfigurableSource, HttpSource() {
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun setupPreferenceScreen(screen: androidx.preference.PreferenceScreen) {
|
override fun setupPreferenceScreen(screen: androidx.preference.PreferenceScreen) {
|
||||||
screen.addPreference(screen.editTextPreference(ADDRESS_TITLE, ADDRESS_DEFAULT, baseUrl))
|
screen.addPreference(screen.editTextPreference(ADDRESS_TITLE, ADDRESS_DEFAULT, baseUrl, "The URL to access your Mango instance. Please include the port number if you didn't set up a reverse proxy"))
|
||||||
screen.addPreference(screen.editTextPreference(USERNAME_TITLE, USERNAME_DEFAULT, username))
|
screen.addPreference(screen.editTextPreference(PORT_TITLE, PORT_DEFAULT, port, "The port number to use if it's not the default 9000"))
|
||||||
screen.addPreference(screen.editTextPreference(PASSWORD_TITLE, PASSWORD_DEFAULT, password, true))
|
screen.addPreference(screen.editTextPreference(USERNAME_TITLE, USERNAME_DEFAULT, username, "Your login username"))
|
||||||
|
screen.addPreference(screen.editTextPreference(PASSWORD_TITLE, PASSWORD_DEFAULT, password, "Your login password", true))
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun androidx.preference.PreferenceScreen.editTextPreference(title: String, default: String, value: String, isPassword: Boolean = false): androidx.preference.EditTextPreference {
|
private fun androidx.preference.PreferenceScreen.editTextPreference(title: String, default: String, value: String, summary: String, isPassword: Boolean = false): androidx.preference.EditTextPreference {
|
||||||
return androidx.preference.EditTextPreference(context).apply {
|
return androidx.preference.EditTextPreference(context).apply {
|
||||||
key = title
|
key = title
|
||||||
this.title = title
|
this.title = title
|
||||||
summary = value
|
this.summary = summary
|
||||||
this.setDefaultValue(default)
|
this.setDefaultValue(default)
|
||||||
dialogTitle = title
|
dialogTitle = title
|
||||||
|
|
||||||
|
@ -283,14 +287,17 @@ class Mango : ConfigurableSource, HttpSource() {
|
||||||
}
|
}
|
||||||
return path
|
return path
|
||||||
}
|
}
|
||||||
|
private fun getPrefPort(): String = preferences.getString(PORT_TITLE, PORT_DEFAULT)!!
|
||||||
private fun getPrefUsername(): String = preferences.getString(USERNAME_TITLE, USERNAME_DEFAULT)!!
|
private fun getPrefUsername(): String = preferences.getString(USERNAME_TITLE, USERNAME_DEFAULT)!!
|
||||||
private fun getPrefPassword(): String = preferences.getString(PASSWORD_TITLE, PASSWORD_DEFAULT)!!
|
private fun getPrefPassword(): String = preferences.getString(PASSWORD_TITLE, PASSWORD_DEFAULT)!!
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
private const val ADDRESS_TITLE = "Address"
|
private const val ADDRESS_TITLE = "Address"
|
||||||
private const val ADDRESS_DEFAULT = ""
|
private const val ADDRESS_DEFAULT = ""
|
||||||
|
private const val PORT_TITLE = "Server Port Number"
|
||||||
|
private const val PORT_DEFAULT = "9000"
|
||||||
private const val USERNAME_TITLE = "Username"
|
private const val USERNAME_TITLE = "Username"
|
||||||
private const val USERNAME_DEFAULT = ""
|
private const val USERNAME_DEFAULT = "admin"
|
||||||
private const val PASSWORD_TITLE = "Password"
|
private const val PASSWORD_TITLE = "Password"
|
||||||
private const val PASSWORD_DEFAULT = ""
|
private const val PASSWORD_DEFAULT = ""
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue