2024-09-30 23:53:35 +05:30
|
|
|
import { default as axios } from "axios";
|
|
|
|
|
|
2024-10-02 23:41:08 +05:30
|
|
|
export const sendProxyConfig = async (proxyConfig: { server_url: string, username?: string, password?: string }): Promise<boolean> => {
|
2024-09-30 23:53:35 +05:30
|
|
|
try {
|
2024-09-30 23:55:37 +05:30
|
|
|
const response = await axios.post(`http://localhost:8080/proxy/config`, proxyConfig);
|
|
|
|
|
if (response.status === 200) {
|
|
|
|
|
return response.data;
|
|
|
|
|
} else {
|
|
|
|
|
throw new Error(`Failed to submit proxy configuration. Try again.`);
|
|
|
|
|
}
|
|
|
|
|
} catch (error: any) {
|
|
|
|
|
console.log(error);
|
|
|
|
|
return false;
|
2024-09-30 23:53:35 +05:30
|
|
|
}
|
2024-10-26 05:32:44 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const getProxyConfig = async (): Promise<{ proxy_url: string, auth: boolean }> => {
|
|
|
|
|
try {
|
|
|
|
|
const response = await axios.get(`http://localhost:8080/proxy/config`);
|
|
|
|
|
if (response.status === 200) {
|
|
|
|
|
return response.data;
|
|
|
|
|
} else {
|
|
|
|
|
throw new Error(`Failed to fetch proxy configuration. Try again.`);
|
|
|
|
|
}
|
|
|
|
|
} catch (error: any) {
|
|
|
|
|
console.log(error);
|
|
|
|
|
return { proxy_url: '', auth: false };
|
|
|
|
|
}
|
2024-10-26 05:34:19 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const testProxyConfig = async (): Promise<{ success: boolean}> => {
|
|
|
|
|
try {
|
|
|
|
|
const response = await axios.get(`http://localhost:8080/proxy/test`);
|
|
|
|
|
if (response.status === 200) {
|
|
|
|
|
return response.data;
|
|
|
|
|
} else {
|
|
|
|
|
throw new Error(`Failed to test proxy configuration. Try again.`);
|
|
|
|
|
}
|
|
|
|
|
} catch (error: any) {
|
|
|
|
|
console.log(error);
|
|
|
|
|
return { success: false };
|
|
|
|
|
}
|
2024-09-30 23:55:37 +05:30
|
|
|
}
|