mirror of
https://gitlab.futo.org/videostreaming/grayjay.git
synced 2025-08-09 01:29:25 +00:00
SLD domain checking fix, download notification if on metered, check for unstarted downloads on opening ui, minor fixes/imrpovements
This commit is contained in:
parent
9e2041521e
commit
697b3bc5f5
7 changed files with 39 additions and 11 deletions
|
@ -14,7 +14,6 @@ import java.text.DecimalFormat
|
|||
import java.time.OffsetDateTime
|
||||
import java.time.temporal.ChronoUnit
|
||||
import kotlin.math.abs
|
||||
import kotlin.math.roundToInt
|
||||
import kotlin.math.roundToLong
|
||||
|
||||
|
||||
|
@ -376,14 +375,19 @@ private val slds = hashSetOf(".com.ac", ".net.ac", ".gov.ac", ".org.ac", ".mil.a
|
|||
fun String.matchesDomain(queryDomain: String): Boolean {
|
||||
|
||||
if(queryDomain.startsWith(".")) {
|
||||
|
||||
val parts = queryDomain.lowercase().split(".");
|
||||
if(parts.size < 3)
|
||||
val parts = this.lowercase().split(".");
|
||||
val queryParts = queryDomain.lowercase().trimStart("."[0]).split(".");
|
||||
if(queryParts.size < 2)
|
||||
throw IllegalStateException("Illegal use of wildcards on First-Level-Domain (" + queryDomain + ")");
|
||||
if(parts.size >= 3){
|
||||
val isSLD = slds.contains("." + parts[parts.size - 2] + "." + parts[parts.size - 1]);
|
||||
if(isSLD && parts.size <= 3)
|
||||
else {
|
||||
val possibleDomain = "." + queryParts.joinToString(".");
|
||||
if(slds.contains(possibleDomain))
|
||||
throw IllegalStateException("Illegal use of wildcards on Second-Level-Domain (" + queryDomain + ")");
|
||||
/*
|
||||
val isSLD = slds.contains("." + queryParts[queryParts.size - 2] + "." + queryParts[queryParts.size - 1]);
|
||||
if(isSLD && queryParts.size <= 3)
|
||||
throw IllegalStateException("Illegal use of wildcards on Second-Level-Domain (" + queryDomain + ")");
|
||||
*/
|
||||
}
|
||||
|
||||
//TODO: Should be safe, but double verify if can't be exploited
|
||||
|
|
|
@ -684,6 +684,10 @@ class UISlideOverlays {
|
|||
}
|
||||
}
|
||||
}
|
||||
if(!Settings.instance.downloads.shouldDownload()) {
|
||||
UIDialogs.appToast("Download will start when you're back on wifi.\n" +
|
||||
"(You can change this in settings)", true);
|
||||
}
|
||||
}
|
||||
};
|
||||
return menu.apply { show() };
|
||||
|
|
|
@ -14,10 +14,14 @@ import androidx.core.widget.addTextChangedListener
|
|||
import androidx.lifecycle.lifecycleScope
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.futo.platformplayer.R
|
||||
import com.futo.platformplayer.Settings
|
||||
import com.futo.platformplayer.UIDialogs
|
||||
import com.futo.platformplayer.downloads.VideoDownload
|
||||
import com.futo.platformplayer.downloads.VideoLocal
|
||||
import com.futo.platformplayer.logging.Logger
|
||||
import com.futo.platformplayer.models.Playlist
|
||||
import com.futo.platformplayer.services.DownloadService
|
||||
import com.futo.platformplayer.states.StateApp
|
||||
import com.futo.platformplayer.states.StateDownloads
|
||||
import com.futo.platformplayer.states.StatePlayer
|
||||
import com.futo.platformplayer.states.StatePlaylists
|
||||
|
@ -54,6 +58,15 @@ class DownloadsFragment : MainFragment() {
|
|||
super.onResume()
|
||||
_view?.reloadUI();
|
||||
|
||||
if(StateDownloads.instance.getDownloading().any { it.state == VideoDownload.State.QUEUED } &&
|
||||
!StateDownloads.instance.getDownloading().any { it.state == VideoDownload.State.DOWNLOADING } &&
|
||||
Settings.instance.downloads.shouldDownload()) {
|
||||
Logger.w(TAG, "Detected queued download, while not downloading, attempt recreating service");
|
||||
StateApp.withContext {
|
||||
DownloadService.getOrCreateService(it);
|
||||
}
|
||||
}
|
||||
|
||||
StateDownloads.instance.onDownloadsChanged.subscribe(this) {
|
||||
lifecycleScope.launch(Dispatchers.Main) {
|
||||
try {
|
||||
|
|
|
@ -194,7 +194,10 @@ class StateSync {
|
|||
addOrUpdate(service.serviceName, if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
|
||||
service.hostAddresses.toTypedArray()
|
||||
} else {
|
||||
arrayOf(service.host)
|
||||
if(service.host != null)
|
||||
arrayOf(service.host);
|
||||
else
|
||||
arrayOf();
|
||||
}, service.port, service.attributes)
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/gray_1d">
|
||||
android:background="#101010">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
|
|
|
@ -339,7 +339,7 @@
|
|||
<string name="configure_if_background_download_should_be_used">Configure if background download should be used</string>
|
||||
<string name="configure_the_auto_updater">Configure the auto updater</string>
|
||||
<string name="configure_when_updates_should_be_downloaded">Configure when updates should be downloaded</string>
|
||||
<string name="configure_when_videos_should_be_downloaded">Configure when videos should be downloaded</string>
|
||||
<string name="configure_when_videos_should_be_downloaded">Configure when videos should be downloaded, if they should only be downloaded on unmetered networks (wifi/ethernet)</string>
|
||||
<string name="creates_a_zip_file_with_your_data_which_can_be_imported_by_opening_it_with_grayjay">Creates a zip file with your data which can be imported by opening it with Grayjay</string>
|
||||
<string name="default_audio_quality">Default Audio Quality</string>
|
||||
<string name="default_playback_speed">Default Playback Speed</string>
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.futo.platformplayer
|
||||
|
||||
/*
|
||||
import com.futo.platformplayer.mdns.DnsOpcode
|
||||
import com.futo.platformplayer.mdns.DnsPacket
|
||||
import com.futo.platformplayer.mdns.DnsPacketHeader
|
||||
|
@ -12,6 +13,7 @@ import com.futo.platformplayer.mdns.QuestionClass
|
|||
import com.futo.platformplayer.mdns.QuestionType
|
||||
import com.futo.platformplayer.mdns.ResourceRecordClass
|
||||
import com.futo.platformplayer.mdns.ResourceRecordType
|
||||
*/
|
||||
import junit.framework.TestCase.assertEquals
|
||||
import junit.framework.TestCase.assertTrue
|
||||
import java.io.ByteArrayOutputStream
|
||||
|
@ -20,8 +22,9 @@ import kotlin.test.Test
|
|||
import kotlin.test.assertContentEquals
|
||||
|
||||
|
||||
//TODO: Update tests.
|
||||
class MdnsTests {
|
||||
|
||||
/*
|
||||
@Test
|
||||
fun `BasicOperation`() {
|
||||
val expectedData = byteArrayOf(
|
||||
|
@ -391,4 +394,5 @@ class MdnsTests {
|
|||
|
||||
assertContentEquals(data, writer.toByteArray())
|
||||
}
|
||||
*/
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue