Compare commits

...

3 commits

Author SHA1 Message Date
maximilionus
916055d8bd
Linux proxy control script improvement (#7558)
Some checks failed
release Linux / build (Release) (push) Has been cancelled
release macOS / build (Release) (push) Has been cancelled
release Windows desktop (Avalonia UI) / build (Release) (push) Has been cancelled
release Windows / build (Release) (push) Has been cancelled
* Proper Unix files new-line termination

* Fallback for proxy configuration on Linux

This introduces a special fallback for platform detection that helps
with configuring the proxy settings on minimal (DE-less) setups.

Also unifies the check for proper $MODE value.
2025-07-09 20:59:24 +08:00
happytrudy
683ca8af14
add shadowquic (#7554) 2025-07-09 20:41:20 +08:00
2dust
70151db91b Add tray menu to display the main window
https://github.com/2dust/v2rayN/issues/7549
2025-07-09 20:31:37 +08:00
7 changed files with 58 additions and 17 deletions

View file

@ -14,5 +14,6 @@ public enum ECoreType
hysteria2 = 26, hysteria2 = 26,
brook = 27, brook = 27,
overtls = 28, overtls = 28,
shadowquic = 29,
v2rayN = 99 v2rayN = 99
} }

View file

@ -507,6 +507,7 @@ public class Global
{ ECoreType.juicity, "juicity/juicity" }, { ECoreType.juicity, "juicity/juicity" },
{ ECoreType.brook, "txthinking/brook" }, { ECoreType.brook, "txthinking/brook" },
{ ECoreType.overtls, "ShadowsocksR-Live/overtls" }, { ECoreType.overtls, "ShadowsocksR-Live/overtls" },
{ ECoreType.shadowquic, "spongebob888/shadowquic" },
{ ECoreType.v2rayN, "2dust/v2rayN" }, { ECoreType.v2rayN, "2dust/v2rayN" },
}; };

View file

@ -200,6 +200,15 @@ public sealed class CoreInfoHandler
Arguments = "-r client -c {0}", Arguments = "-r client -c {0}",
Url = GetCoreUrl(ECoreType.overtls), Url = GetCoreUrl(ECoreType.overtls),
AbsolutePath = false, AbsolutePath = false,
},
new CoreInfo
{
CoreType = ECoreType.shadowquic,
CoreExes = [ "shadowquic", "shadowquic"],
Arguments = "-c {0}",
Url = GetCoreUrl(ECoreType.shadowquic),
AbsolutePath = false,
} }
]; ];

View file

@ -29,9 +29,6 @@ set_gnome_proxy() {
echo "Ignored Hosts: $IGNORE_HOSTS" echo "Ignored Hosts: $IGNORE_HOSTS"
elif [ "$MODE" == "none" ]; then elif [ "$MODE" == "none" ]; then
echo "GNOME: Proxy disabled." echo "GNOME: Proxy disabled."
else
echo "GNOME: Invalid mode. Use 'none' or 'manual'."
exit 1
fi fi
} }
@ -69,9 +66,6 @@ set_kde_proxy() {
# Disable proxy # Disable proxy
$KWRITECONFIG --file kioslaverc --group "Proxy Settings" --key ProxyType 0 $KWRITECONFIG --file kioslaverc --group "Proxy Settings" --key ProxyType 0
echo "KDE: Proxy disabled." echo "KDE: Proxy disabled."
else
echo "KDE: Invalid mode. Use 'none' or 'manual'."
exit 1
fi fi
# Apply changes by restarting KDE's network settings # Apply changes by restarting KDE's network settings
@ -117,6 +111,15 @@ detect_desktop_environment() {
return return
fi fi
done done
# Fallback to GNOME method if CLI utility is available. This solves the
# proxy configuration issues on minimal installation systems, like setups
# with only window managers, that borrow some parts from big DEs.
if command -v gsettings >/dev/null 2>&1; then
echo "gnome"
return
fi
echo "unsupported" echo "unsupported"
} }
@ -134,6 +137,11 @@ PROXY_IP=$2
PROXY_PORT=$3 PROXY_PORT=$3
IGNORE_HOSTS=$4 IGNORE_HOSTS=$4
if ! [[ "$MODE" =~ ^(manual|none)$ ]]; then
echo "Invalid mode. Use 'none' or 'manual'." >&2
exit 1
fi
# Detect desktop environment # Detect desktop environment
DE=$(detect_desktop_environment) DE=$(detect_desktop_environment)
@ -144,6 +152,6 @@ elif [ "$DE" == "kde" ]; then
set_gnome_proxy "$MODE" "$PROXY_IP" "$PROXY_PORT" "$IGNORE_HOSTS" set_gnome_proxy "$MODE" "$PROXY_IP" "$PROXY_PORT" "$IGNORE_HOSTS"
set_kde_proxy "$MODE" "$PROXY_IP" "$PROXY_PORT" "$IGNORE_HOSTS" set_kde_proxy "$MODE" "$PROXY_IP" "$PROXY_PORT" "$IGNORE_HOSTS"
else else
echo "Unsupported desktop environment: $DE" echo "Unsupported desktop environment: $DE" >&2
exit 1 exit 1
fi fi

View file

@ -34,6 +34,8 @@ public class StatusBarViewModel : MyReactiveObject
public ReactiveCommand<Unit, Unit> SubUpdateViaProxyCmd { get; } public ReactiveCommand<Unit, Unit> SubUpdateViaProxyCmd { get; }
public ReactiveCommand<Unit, Unit> CopyProxyCmdToClipboardCmd { get; } public ReactiveCommand<Unit, Unit> CopyProxyCmdToClipboardCmd { get; }
public ReactiveCommand<Unit, Unit> NotifyLeftClickCmd { get; } public ReactiveCommand<Unit, Unit> NotifyLeftClickCmd { get; }
public ReactiveCommand<Unit, Unit> ShowWindowCmd { get; }
public ReactiveCommand<Unit, Unit> HideWindowCmd { get; }
#region System Proxy #region System Proxy
@ -91,6 +93,9 @@ public class StatusBarViewModel : MyReactiveObject
[Reactive] [Reactive]
public bool EnableTun { get; set; } public bool EnableTun { get; set; }
[Reactive]
public bool BlIsNonWindows { get; set; }
#endregion UI #endregion UI
public StatusBarViewModel(Func<EViewAction, object?, Task<bool>>? updateView) public StatusBarViewModel(Func<EViewAction, object?, Task<bool>>? updateView)
@ -100,6 +105,7 @@ public class StatusBarViewModel : MyReactiveObject
SelectedServer = new(); SelectedServer = new();
RunningServerToolTipText = "-"; RunningServerToolTipText = "-";
BlSystemProxyPacVisible = Utils.IsWindows(); BlSystemProxyPacVisible = Utils.IsWindows();
BlIsNonWindows = Utils.IsNonWindows();
if (_config.TunModeItem.EnableTun && AllowEnableTun()) if (_config.TunModeItem.EnableTun && AllowEnableTun())
{ {
@ -143,11 +149,21 @@ public class StatusBarViewModel : MyReactiveObject
Locator.Current.GetService<MainWindowViewModel>()?.ShowHideWindow(null); Locator.Current.GetService<MainWindowViewModel>()?.ShowHideWindow(null);
await Task.CompletedTask; await Task.CompletedTask;
}); });
ShowWindowCmd = ReactiveCommand.CreateFromTask(async () =>
{
Locator.Current.GetService<MainWindowViewModel>()?.ShowHideWindow(true);
await Task.CompletedTask;
});
HideWindowCmd = ReactiveCommand.CreateFromTask(async () =>
{
Locator.Current.GetService<MainWindowViewModel>()?.ShowHideWindow(false);
await Task.CompletedTask;
});
AddServerViaClipboardCmd = ReactiveCommand.CreateFromTask(async () => AddServerViaClipboardCmd = ReactiveCommand.CreateFromTask(async () =>
{ {
await AddServerViaClipboard(); await AddServerViaClipboard();
}); });
AddServerViaScanCmd = ReactiveCommand.CreateFromTask(async () => AddServerViaScanCmd = ReactiveCommand.CreateFromTask(async () =>
{ {
await AddServerViaScan(); await AddServerViaScan();

View file

@ -32,7 +32,15 @@
ToolTipText="{Binding RunningServerToolTipText}"> ToolTipText="{Binding RunningServerToolTipText}">
<TrayIcon.Menu> <TrayIcon.Menu>
<NativeMenu> <NativeMenu>
<NativeMenuItem Command="{Binding NotifyLeftClickCmd}" Header="{x:Static resx:ResUI.menuShowOrHideMainWindow}" /> <NativeMenuItem
Command="{Binding ShowWindowCmd}"
Header="{x:Static resx:ResUI.TbDisplayGUI}"
IsVisible="{Binding BlIsNonWindows}" />
<NativeMenuItem
Command="{Binding NotifyLeftClickCmd}"
Header="{x:Static resx:ResUI.menuShowOrHideMainWindow}"
IsVisible="{Binding BlIsNonWindows}" />
<NativeMenuItem Command="{Binding CopyProxyCmdToClipboardCmd}" Header="{x:Static resx:ResUI.menuCopyProxyCmdToClipboard}" />
<NativeMenuItemSeparator /> <NativeMenuItemSeparator />
<NativeMenuItem <NativeMenuItem
Command="{Binding SystemProxyClearCmd}" Command="{Binding SystemProxyClearCmd}"
@ -60,8 +68,6 @@
<NativeMenuItem Command="{Binding SubUpdateCmd}" Header="{x:Static resx:ResUI.menuSubUpdate}" /> <NativeMenuItem Command="{Binding SubUpdateCmd}" Header="{x:Static resx:ResUI.menuSubUpdate}" />
<NativeMenuItem Command="{Binding SubUpdateViaProxyCmd}" Header="{x:Static resx:ResUI.menuSubUpdateViaProxy}" /> <NativeMenuItem Command="{Binding SubUpdateViaProxyCmd}" Header="{x:Static resx:ResUI.menuSubUpdateViaProxy}" />
<NativeMenuItemSeparator /> <NativeMenuItemSeparator />
<NativeMenuItem Command="{Binding CopyProxyCmdToClipboardCmd}" Header="{x:Static resx:ResUI.menuCopyProxyCmdToClipboard}" />
<NativeMenuItemSeparator />
<NativeMenuItem Click="MenuExit_Click" Header="{x:Static resx:ResUI.menuExit}" /> <NativeMenuItem Click="MenuExit_Click" Header="{x:Static resx:ResUI.menuExit}" />
</NativeMenu> </NativeMenu>
</TrayIcon.Menu> </TrayIcon.Menu>