Temp fixes to timeouts on Android
This commit is contained in:
Generated
+1
-1
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_21" project-jdk-name="jbr-17" project-jdk-type="JavaSDK">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_21" default="true" project-jdk-name="jbr-21" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||
</component>
|
||||
<component name="ProjectType">
|
||||
|
||||
@@ -7,8 +7,8 @@ android {
|
||||
applicationId "us.materialio.app"
|
||||
minSdkVersion rootProject.ext.minSdkVersion
|
||||
targetSdkVersion rootProject.ext.targetSdkVersion
|
||||
versionCode 104
|
||||
versionName "1.8.0"
|
||||
versionCode 105
|
||||
versionName "1.8.1"
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
aaptOptions {
|
||||
// Files and dirs to omit from the packaged assets dir, modified to accommodate modern web apps.
|
||||
|
||||
@@ -65,6 +65,10 @@
|
||||
|
||||
|
||||
|
||||
|
||||
<release version="1.8.1" date="2025-5-03">
|
||||
<url>https://github.com/Materialious/Materialious/releases/tag/1.8.1</url>
|
||||
</release>
|
||||
<release version="1.8.0" date="2025-4-30">
|
||||
<url>https://github.com/Materialious/Materialious/releases/tag/1.8.0</url>
|
||||
</release>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "Materialious",
|
||||
"version": "1.8.0",
|
||||
"version": "1.8.1",
|
||||
"description": "Modern material design for Invidious.",
|
||||
"author": {
|
||||
"name": "Ward Pearce",
|
||||
|
||||
Generated
+2
-2
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "materialious",
|
||||
"version": "1.8.0",
|
||||
"version": "1.8.1",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "materialious",
|
||||
"version": "1.8.0",
|
||||
"version": "1.8.1",
|
||||
"hasInstallScript": true,
|
||||
"dependencies": {
|
||||
"@capacitor-community/electron": "^5.0.1",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "materialious",
|
||||
"version": "1.8.0",
|
||||
"version": "1.8.1",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "vite dev",
|
||||
|
||||
@@ -101,13 +101,12 @@ export class HttpFetchPlugin {
|
||||
|
||||
const timeoutMs = request.retryParameters.timeout;
|
||||
if (timeoutMs) {
|
||||
const timer = new shaka.util.Timer(() => {
|
||||
abortStatus.timedOut = true;
|
||||
controller.abort();
|
||||
});
|
||||
|
||||
timer.tickAfter(timeoutMs / 1000);
|
||||
op.finally(() => timer.stop());
|
||||
// const timer = new shaka.util.Timer(() => {
|
||||
// abortStatus.timedOut = true;
|
||||
// controller.abort();
|
||||
// });
|
||||
// timer.tickAfter(timeoutMs / 1000);
|
||||
// op.finally(() => timer.stop());
|
||||
}
|
||||
|
||||
return op;
|
||||
|
||||
@@ -25,6 +25,7 @@ const CORS_HEADERS = [
|
||||
'Referer',
|
||||
'Cookie'
|
||||
].join(', ');
|
||||
|
||||
const CORS_ORIGIN = 'https://www.youtube.com';
|
||||
const USER_AGENT =
|
||||
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36(KHTML, like Gecko)';
|
||||
@@ -37,122 +38,111 @@ function setCorsHeaders(res) {
|
||||
res.setHeader('Access-Control-Allow-Credentials', 'true');
|
||||
}
|
||||
|
||||
function fetchWithRedirects(targetUrl, options, bodyChunks, redirectCount = 0) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const httpClient = targetUrl.protocol.startsWith('https') ? https : http;
|
||||
function proxyRequest(clientReq, clientRes, parsedUrl, bodyChunks = [], redirectCount = 0) {
|
||||
if (redirectCount > MAX_REDIRECTS) {
|
||||
clientRes.writeHead(508, { 'Content-Type': 'text/plain' });
|
||||
return clientRes.end('Too many redirects');
|
||||
}
|
||||
|
||||
const req = httpClient.request(targetUrl, options, (res) => {
|
||||
if (res.statusCode >= 300 && res.statusCode < 400 && res.headers.location) {
|
||||
if (redirectCount >= MAX_REDIRECTS) {
|
||||
req.end();
|
||||
return reject(new Error('Too many redirects'));
|
||||
}
|
||||
const isHttps = parsedUrl.protocol === 'https:';
|
||||
const httpClient = isHttps ? https : http;
|
||||
|
||||
try {
|
||||
// Attempt to create the redirect URL
|
||||
const redirectUrl = new URL(res.headers.location, targetUrl);
|
||||
return resolve(fetchWithRedirects(redirectUrl, options, bodyChunks, redirectCount + 1));
|
||||
} catch (error) {
|
||||
req.end();
|
||||
return reject(new Error(`Invalid URL in redirect: ${error.message}`));
|
||||
}
|
||||
}
|
||||
resolve(res); // Resolve with the final response if not a redirect
|
||||
});
|
||||
const proxyOptions = {
|
||||
method: clientReq.method,
|
||||
headers: {
|
||||
...clientReq.headers,
|
||||
host: parsedUrl.host,
|
||||
origin: parsedUrl.origin,
|
||||
'user-agent': USER_AGENT,
|
||||
connection: 'close'
|
||||
}
|
||||
};
|
||||
|
||||
// For POST and PUT methods, pass the body to the outgoing request
|
||||
if (bodyChunks && (req.method === 'POST' || req.method === 'PUT')) {
|
||||
const buffer = Buffer.concat(bodyChunks);
|
||||
options.headers['Content-Length'] = buffer.length;
|
||||
// Remove headers that may cause issues or be auto-managed
|
||||
for (const key of [
|
||||
'referer',
|
||||
'x-forwarded-for',
|
||||
'x-requested-with',
|
||||
'sec-ch-ua-mobile',
|
||||
'sec-ch-ua',
|
||||
'sec-ch-ua-platform'
|
||||
]) {
|
||||
delete proxyOptions.headers[key];
|
||||
}
|
||||
|
||||
req.write(buffer);
|
||||
const proxyReq = httpClient.request(parsedUrl, proxyOptions, (proxyRes) => {
|
||||
// Handle redirects
|
||||
if (proxyRes.statusCode >= 300 && proxyRes.statusCode < 400 && proxyRes.headers.location) {
|
||||
proxyRes.resume(); // discard response data
|
||||
const newUrl = new URL(proxyRes.headers.location, parsedUrl);
|
||||
return proxyRequest(clientReq, clientRes, newUrl, bodyChunks, redirectCount + 1);
|
||||
}
|
||||
|
||||
req.setTimeout(10000, () => reject(new Error('Request timeout')), req.end());
|
||||
req.on('error', (error) => reject(error), req.end());
|
||||
req.end();
|
||||
clientRes.writeHead(proxyRes.statusCode, {
|
||||
...proxyRes.headers,
|
||||
'Access-Control-Allow-Origin': CORS_ORIGIN,
|
||||
'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE, OPTIONS',
|
||||
'Access-Control-Allow-Headers': CORS_HEADERS,
|
||||
'Access-Control-Allow-Credentials': 'true'
|
||||
});
|
||||
|
||||
proxyRes.pipe(clientRes);
|
||||
});
|
||||
|
||||
// Timeout handler
|
||||
proxyReq.setTimeout(120000, () => {
|
||||
proxyReq.destroy(new Error('Proxy request timed out'));
|
||||
});
|
||||
|
||||
proxyReq.on('error', (err) => {
|
||||
console.error('Proxy request error:', err.message);
|
||||
if (!clientRes.headersSent) {
|
||||
clientRes.writeHead(500, { 'Content-Type': 'text/plain' });
|
||||
}
|
||||
clientRes.end(`Proxy error: ${err.message}`);
|
||||
});
|
||||
|
||||
clientReq.on('aborted', () => proxyReq.destroy());
|
||||
|
||||
// Write buffered body if present
|
||||
if (bodyChunks.length > 0) {
|
||||
proxyReq.write(Buffer.concat(bodyChunks));
|
||||
}
|
||||
|
||||
proxyReq.end();
|
||||
}
|
||||
|
||||
const server = http.createServer(async (req, res) => {
|
||||
const server = http.createServer((req, res) => {
|
||||
setCorsHeaders(res);
|
||||
|
||||
if (req.method === 'OPTIONS') {
|
||||
res.writeHead(200, { 'Content-Type': 'text/plain' });
|
||||
res.writeHead(204);
|
||||
return res.end();
|
||||
}
|
||||
|
||||
if (!req.url || req.url === '/') {
|
||||
res.writeHead(400, { 'Content-Type': 'text/plain' });
|
||||
return res.end('No URL provided to fetch.');
|
||||
return res.end('No URL provided.');
|
||||
}
|
||||
|
||||
let targetUrl = req.url.slice(1);
|
||||
if (!targetUrl.startsWith('http')) {
|
||||
targetUrl = 'http://' + targetUrl;
|
||||
}
|
||||
|
||||
let targetUrl = req.url.slice(1); // Remove leading '/'
|
||||
let parsedTarget;
|
||||
try {
|
||||
// Ensure protocol (http) is added if missing
|
||||
if (!targetUrl.startsWith('http')) {
|
||||
targetUrl = 'http://' + targetUrl;
|
||||
}
|
||||
parsedTarget = new URL(targetUrl);
|
||||
} catch (error) {
|
||||
} catch (err) {
|
||||
res.writeHead(400, { 'Content-Type': 'text/plain' });
|
||||
return res.end(`Invalid URL: ${error.message}`);
|
||||
return res.end(`Invalid URL: ${err.message}`);
|
||||
}
|
||||
|
||||
let chunks = [];
|
||||
req.on('data', (chunk) => {
|
||||
chunks.push(chunk);
|
||||
});
|
||||
|
||||
req.on('end', async () => {
|
||||
const options = {
|
||||
method: req.method,
|
||||
headers: Object.fromEntries(
|
||||
Object.entries(req.headers).filter(
|
||||
([key]) =>
|
||||
![
|
||||
'referer',
|
||||
'x-forwarded-for',
|
||||
'x-requested-with',
|
||||
'sec-ch-ua-mobile',
|
||||
'sec-ch-ua',
|
||||
'sec-ch-ua-platform'
|
||||
].includes(key.toLowerCase())
|
||||
)
|
||||
)
|
||||
};
|
||||
|
||||
options.headers.host = parsedTarget.host;
|
||||
options.headers.origin = parsedTarget.origin;
|
||||
options.headers['user-agent'] = USER_AGENT;
|
||||
|
||||
try {
|
||||
const proxyRes = await fetchWithRedirects(parsedTarget, options, chunks);
|
||||
|
||||
req.on('close', () => {
|
||||
console.log('Request canceled by the client.');
|
||||
proxyRes.destroy();
|
||||
});
|
||||
|
||||
res.writeHead(proxyRes.statusCode, {
|
||||
...proxyRes.headers,
|
||||
'Access-Control-Allow-Origin': CORS_ORIGIN,
|
||||
'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE, OPTIONS',
|
||||
'Access-Control-Allow-Headers': CORS_HEADERS,
|
||||
'Access-Control-Allow-Credentials': 'true'
|
||||
});
|
||||
|
||||
// Pipe response data back to the client
|
||||
proxyRes.pipe(res);
|
||||
} catch (error) {
|
||||
console.error('Proxy error:', error);
|
||||
res.writeHead(500, { 'Content-Type': 'text/plain' });
|
||||
res.end(`Error: ${error.message}`);
|
||||
}
|
||||
});
|
||||
const bodyChunks = [];
|
||||
req.on('data', (chunk) => bodyChunks.push(chunk));
|
||||
req.on('end', () => proxyRequest(req, res, parsedTarget, bodyChunks));
|
||||
});
|
||||
|
||||
server.listen(PORT, () => {
|
||||
console.log(`Server is running on http://${HOST}:${PORT}`);
|
||||
console.log(`Proxy server running at http://${HOST}:${PORT}`);
|
||||
});
|
||||
|
||||
+10
-10
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "cors-patch",
|
||||
"version": "0.0.1",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "cors-patch",
|
||||
"version": "0.0.1"
|
||||
}
|
||||
}
|
||||
"name": "cors-patch",
|
||||
"version": "0.0.2",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "cors-patch",
|
||||
"version": "0.0.2"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"name": "cors-patch",
|
||||
"version": "0.0.1",
|
||||
"main": "./index.js"
|
||||
"name": "cors-patch",
|
||||
"version": "0.0.2",
|
||||
"main": "./index.js"
|
||||
}
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@ import os
|
||||
import re
|
||||
from datetime import datetime
|
||||
|
||||
LATEST_VERSION = "1.8.0"
|
||||
LATEST_VERSION = "1.8.1"
|
||||
RELEASE_DATE = datetime.now().strftime("%Y-%-m-%d") # Format: YYYY-M-D
|
||||
|
||||
WORKING_DIR = os.path.join(
|
||||
|
||||
Reference in New Issue
Block a user