mirror of
https://github.com/kiddin9/op-packages.git
synced 2026-10-30 04:55:13 +08:00
🎨 Sync 2026-09-15 11:19:33
This commit is contained in:
1 parent
a9e0557b71
commit
ac76f4cbc9
106 files changed
+17125
-19121
No files matched your search
Regular → Executable
+18
-21
@@ -66,37 +66,34 @@ export function getTime(epoch) {
|
||||
|
||||
};
|
||||
|
||||
export function wGET(url, ua) {
|
||||
const result = wGETResult(url, ua);
|
||||
return result?.stdout;
|
||||
};
|
||||
|
||||
export function wGETResult(url, ua) {
|
||||
export function wGETResponse(url, ua) {
|
||||
if (!url || type(url) !== 'string')
|
||||
return null;
|
||||
|
||||
if (!ua)
|
||||
ua = 'Wget/1.21 (HomeProxy, like v2rayN)';
|
||||
|
||||
let last_result = null;
|
||||
const output = executeCommand(`/usr/bin/wget -O- -S --user-agent ${shellQuote(ua)} --timeout=10 ${shellQuote(url)}`) || {};
|
||||
return {
|
||||
body: trim(output.stdout),
|
||||
headers: output.stderr || '',
|
||||
exitcode: output.exitcode
|
||||
};
|
||||
};
|
||||
|
||||
for (let extra in [ '', '-4' ]) {
|
||||
const output = executeCommand(`/usr/bin/wget -q ${extra} -O- --user-agent ${shellQuote(ua)} --timeout=10 ${shellQuote(url)}`) || {};
|
||||
export function wGET(url, ua) {
|
||||
return wGETResponse(url, ua)?.body;
|
||||
};
|
||||
|
||||
output.stdout = trim(output.stdout);
|
||||
output.stderr = trim(output.stderr);
|
||||
last_result = output;
|
||||
export function wGETHeaders(url, ua) {
|
||||
if (!url || type(url) !== 'string')
|
||||
return null;
|
||||
|
||||
if (output.exitcode === 0 && output.stdout)
|
||||
return output;
|
||||
}
|
||||
if (!ua)
|
||||
ua = 'clash.meta';
|
||||
|
||||
if (last_result) {
|
||||
last_result.stdout = trim(last_result.stdout);
|
||||
last_result.stderr = trim(last_result.stderr);
|
||||
}
|
||||
|
||||
return last_result;
|
||||
const output = executeCommand(`/usr/bin/wget -O /dev/null -S --user-agent ${shellQuote(ua)} --timeout=10 ${shellQuote(url)}`) || {};
|
||||
return output.stderr || '';
|
||||
};
|
||||
/* Utilities end */
|
||||
|
||||
|
||||
Reference in new issue
Block a user