Simplify proxy routing and configuration
This commit is contained in:
31
src/web/utils/clientControls.js
Normal file
31
src/web/utils/clientControls.js
Normal file
@@ -0,0 +1,31 @@
|
||||
export function connectionAction({ connected, selectedTag, configExists }) {
|
||||
if (connected) return { type: 'stop' };
|
||||
if (selectedTag) return { type: 'apply', selectedTag };
|
||||
if (configExists) return { type: 'restart' };
|
||||
return null;
|
||||
}
|
||||
|
||||
export function formatConnectionDuration(startedAt, now = Date.now()) {
|
||||
const started = Date.parse(startedAt);
|
||||
const totalSeconds = Number.isFinite(started)
|
||||
? Math.max(0, Math.floor((now - started) / 1000))
|
||||
: 0;
|
||||
const hours = Math.floor(totalSeconds / 3600);
|
||||
const minutes = Math.floor((totalSeconds % 3600) / 60);
|
||||
const seconds = totalSeconds % 60;
|
||||
|
||||
return [hours, minutes, seconds]
|
||||
.map((part) => String(part).padStart(2, '0'))
|
||||
.join(':');
|
||||
}
|
||||
|
||||
export function subscriptionDomain(subscriptionHost) {
|
||||
return String(subscriptionHost || '').split('/')[0];
|
||||
}
|
||||
|
||||
export function localProxyUrls(port = 8082) {
|
||||
return {
|
||||
socks5: `socks5://127.0.0.1:${port}`,
|
||||
http: `http://127.0.0.1:${port}`,
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user