qs: add an option to force networkfetch use ipv4

This commit is contained in:
2026-01-18 01:05:18 +01:00
parent 98a80c7cbc
commit 44d7546d05
3 changed files with 43 additions and 37 deletions
@@ -39,7 +39,7 @@ Singleton {
} else {
Logger.error("IpService", "Failed to fetch IP");
}
});
}, true);
}
function fetchGeoInfo(notify) {
@@ -4,31 +4,35 @@ import Quickshell.Io
import qs.Utils
Item {
// function fakeFetch(resp, callback, forceIPv4 = false) {
// if (curlProcess.running) {
// Logger.warn("NetworkFetch", "A fetch operation is already in progress.");
// return ;
// }
// fetchedData = "";
// fetchingCallback = callback;
// curlProcess.command = ["echo", resp];
// curlProcess.running = true;
// }
id: root
property real fetchTimeout: 10 // in seconds
property string fetchedData: ""
property var fetchingCallback: null
function fetch(url, callback) {
function fetch(url, callback, forceIPv4 = false) {
if (curlProcess.running) {
Logger.warn("NetworkFetch", "A fetch operation is already in progress.");
return ;
}
fetchedData = "";
fetchingCallback = callback;
curlProcess.command = ["curl", "-s", "-L", "-m", fetchTimeout.toString(), url];
curlProcess.running = true;
}
curlProcess.command = ["curl", "-s", "-L", "-m", fetchTimeout.toString()];
if (forceIPv4)
curlProcess.command.push("-4");
function fakeFetch(resp, callback) {
if (curlProcess.running) {
Logger.warn("NetworkFetch", "A fetch operation is already in progress.");
return ;
}
fetchedData = "";
fetchingCallback = callback;
curlProcess.command = ["echo", resp];
curlProcess.command.push(url);
curlProcess.running = true;
}