fixed endless loading while proxies offline
This commit is contained in:
parent
7f97ee4890
commit
38fbf51489
@ -9,7 +9,13 @@ export async function searchCrunchy(q: string) {
|
||||
isProxyActive = result
|
||||
})
|
||||
|
||||
const { data: proxies } = await getProxies()
|
||||
var proxies;
|
||||
|
||||
if (isProxyActive) {
|
||||
const { data: prox } = await getProxies()
|
||||
|
||||
proxies = prox.value
|
||||
}
|
||||
|
||||
const { data: token, error: tokenerror } = await crunchyLogin('LOCAL')
|
||||
|
||||
@ -35,8 +41,8 @@ export async function searchCrunchy(q: string) {
|
||||
throw new Error(JSON.stringify(error.value))
|
||||
}
|
||||
|
||||
if (proxies.value && isProxyActive) {
|
||||
for (const p of proxies.value) {
|
||||
if (proxies && isProxyActive) {
|
||||
for (const p of proxies) {
|
||||
if (p.status !== 'offline') {
|
||||
const { data: tokeng, error: tokenerrorg } = await crunchyLogin(p.code)
|
||||
|
||||
|
@ -172,14 +172,19 @@ export async function checkProxiesController(request: FastifyRequest, reply: Fas
|
||||
]
|
||||
|
||||
for (const p of proxies) {
|
||||
const response = await fetch(p.url + 'health', {
|
||||
method: 'GET'
|
||||
})
|
||||
try {
|
||||
const response: Response = await Promise.race([
|
||||
fetch(p.url + 'health', { method: 'GET' }),
|
||||
new Promise<Response>((_, reject) => setTimeout(() => reject(new Error('Timeout')), 500))
|
||||
]);
|
||||
|
||||
if (response.ok) {
|
||||
p.status = 'online'
|
||||
} else {
|
||||
p.status = 'offline'
|
||||
if (response.ok) {
|
||||
p.status = 'online';
|
||||
} else {
|
||||
p.status = 'offline';
|
||||
}
|
||||
} catch (error) {
|
||||
p.status = 'offline';
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1293,32 +1293,22 @@ export async function checkProxies() {
|
||||
}
|
||||
]
|
||||
|
||||
console.log('ok')
|
||||
|
||||
for (const p of proxies) {
|
||||
const response = await fetch(p.url + 'health', {
|
||||
method: 'GET'
|
||||
})
|
||||
|
||||
if (response.ok) {
|
||||
p.status = 'online'
|
||||
server.logger.log({
|
||||
level: 'info',
|
||||
message: 'Proxy fetch successful, marking as online',
|
||||
proxy: p.name,
|
||||
timestamp: new Date().toISOString(),
|
||||
section: 'checkProxyFetch'
|
||||
})
|
||||
} else {
|
||||
const data = await response.text()
|
||||
try {
|
||||
const response: Response = await Promise.race([
|
||||
fetch(p.url + 'health', { method: 'GET' }),
|
||||
new Promise<Response>((_, reject) => setTimeout(() => reject(new Error('Timeout')), 500))
|
||||
])
|
||||
|
||||
if (response.ok) {
|
||||
p.status = 'online'
|
||||
} else {
|
||||
p.status = 'offline'
|
||||
}
|
||||
} catch (error) {
|
||||
p.status = 'offline'
|
||||
server.logger.log({
|
||||
level: 'error',
|
||||
message: 'Proxy fetch failed, marking as offline',
|
||||
proxy: p.name,
|
||||
error: data,
|
||||
timestamp: new Date().toISOString(),
|
||||
section: 'checkProxyFetch'
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
31
src/api/services/msl.ts
Normal file
31
src/api/services/msl.ts
Normal file
@ -0,0 +1,31 @@
|
||||
function getRandomInt(ca: BigInt) {
|
||||
return BigInt(Math.floor(Math.random() * Number(ca)));
|
||||
}
|
||||
|
||||
function randomHex(length: number) {
|
||||
const characters = '0123456789ABCDEF';
|
||||
let result = '';
|
||||
for (let i = 0; i < length; i++) {
|
||||
result += characters.charAt(Math.floor(Math.random() * characters.length));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
function getESN() {
|
||||
return `NFANDROID1-PRV-P-SAMSUSM-G950F-7169-${randomHex(30)}`
|
||||
}
|
||||
|
||||
export function encryptNetflixMSL(body: any) {
|
||||
|
||||
var headers = {
|
||||
sender: getESN(),
|
||||
handshake: true,
|
||||
nonreplayable: 2,
|
||||
capabilities: {"languages": [], "compressionalgos": []},
|
||||
recipient: "Netflix",
|
||||
renewable: true,
|
||||
messageid: getRandomInt(BigInt(2) ** BigInt(52)),
|
||||
timestamp: Date.now() / 1000
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user