Skip to content

Commit

Permalink
Merge pull request #41 from micahmo/release/v1.7.4
Browse files Browse the repository at this point in the history
Release/v1.7.4
  • Loading branch information
micahmo authored Apr 23, 2022
2 parents 3d07472 + 55b0e95 commit f13fa60
Show file tree
Hide file tree
Showing 18 changed files with 549 additions and 40 deletions.
8 changes: 4 additions & 4 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<Project>
<PropertyGroup>
<!-- Keep in sync with WS4WSetupScript.iss and VersionInfo.xml -->
<AssemblyVersion>1.7.3.0</AssemblyVersion>
<FileVersion>1.7.3.0</FileVersion>
<InformationalVersion>1.7.3.0</InformationalVersion>
<AssemblyVersion>1.7.4.0</AssemblyVersion>
<FileVersion>1.7.4.0</FileVersion>
<InformationalVersion>1.7.4.0</InformationalVersion>
<Authors>Micah Morrison</Authors>
<Product>WS4W</Product>
</PropertyGroup>
</Project>
</Project>
61 changes: 61 additions & 0 deletions Installer/UpdateVersions.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# This script is intended to be run from the root of the repo, like .\Installer\UpdateVersions.ps1

$newVersion = Read-Host "Enter the new version number (without 'v' and without trailing '.0')"

# Directory.Build.props
$directoryBuildPropsFile = Get-Content "Directory.Build.props"
for ($i = 0; $i -lt $directoryBuildPropsFile.Length; $i += 1) {
$line = $directoryBuildPropsFile[$i]

if ($line -match "AssemblyVersion") {
$directoryBuildPropsFile[$i] = " <AssemblyVersion>$($newVersion).0</AssemblyVersion>"
}

if ($line -match "FileVersion") {
$directoryBuildPropsFile[$i] = " <FileVersion>$($newVersion).0</FileVersion>"
}

if ($line -match "InformationalVersion") {
$directoryBuildPropsFile[$i] = " <InformationalVersion>$($newVersion).0</InformationalVersion>"
}
}

Set-Content "Directory.Build.props" $directoryBuildPropsFile

# WS4WSetupScript.iss
$setupScript = Get-Content "Installer\WS4WSetupScript.iss"
for ($i = 0; $i -lt $setupScript.Length; $i += 1) {
$line = $setupScript[$i]

if ($line -match "#define MyAppVersion") {
$setupScript[$i] = "#define MyAppVersion ""$($newVersion)"""
}
}

Set-Content "Installer\WS4WSetupScript.iss" $setupScript

# VersionInfo2.xml
$versionInfo = Get-Content "WireGuardServerForWindows\VersionInfo2.xml"
for ($i = 0; $i -lt $versionInfo.Length; $i += 1) {
$line = $versionInfo[$i]

if ($line -match "<Version>") {
$versionInfo[$i] = " <Version>$($newVersion).0</Version>"
}

if ($line -match "ReleaseDate") {
$versionInfo[$i] = " <ReleaseDate>$(Get-Date -Format "yyyy-MM-dd")</ReleaseDate>"
}

if ($line -match "DownloadLink") {
$versionInfo[$i] = " <DownloadLink>https://github.com/micahmo/WireGuardServerForWindows/releases/download/v$($newVersion)/WS4WSetup-$($newVersion).exe</DownloadLink>"
}

if ($line -match "DownloadFileName") {
$versionInfo[$i] = " <DownloadFileName>WS4WSetup-$($newVersion).exe</DownloadFileName>"
}
}

Set-Content "WireGuardServerForWindows\VersionInfo2.xml" $versionInfo

Write-Host -ForegroundColor Red "Don't forget to update VersionNotes!"
2 changes: 1 addition & 1 deletion Installer/WS4WSetupScript.iss
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#define MyAppName "WireGuard Server for Windows"
#define MyAppVersion "1.7.3"
#define MyAppVersion "1.7.4"
#define MyAppPublisher "Micah Morrison"
#define MyAppURL "https://github.com/micahmo/WireGuardServerForWindows"
#define MyAppExeName "WireGuardServerForWindows.exe"
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Below are the tasks that can be performed automatically using this application.

## Before

![BeforeScreenshot](https://user-images.githubusercontent.com/7417301/163678624-fb766a71-5f45-470d-b1bd-2bc6112ed3af.png)
![BeforeScreenshot](https://user-images.githubusercontent.com/7417301/164948118-6353bec5-4693-41de-8209-f0d5230ae0c4.png)

### WireGuard.exe
This step downloads and runs the latest version of WireGuard for Windows from https://download.wireguard.com/windows-client/wireguard-installer.exe. Once installed, it can be uninstalled directly from WS4W, too.
Expand Down Expand Up @@ -109,7 +109,8 @@ Even with these workarounds, Internet Sharing can become disabled after a reboot
Once the tunnel is installed, the status of the WireGuard interface may be viewed. This is accomplished via the `wg show` command. It will be continually updated as long as `Update Live` is checked.

## After
![AfterScreenshot](https://user-images.githubusercontent.com/7417301/163678848-0de1b82b-0616-4e91-bac7-5419d8f5ec9a.png)

![AfterScreenshot](https://user-images.githubusercontent.com/7417301/164948126-f207ce7e-5365-47a5-90cd-cc541874ad65.png)

## CLI
There is also a CLI bundled in the portable download called `ws4w.exe` which can be invoked from a terminal or called from a script. In addition to messages written to standard out, the CLI will also set the exit code based on the success of executing the given command. In PowerShell, for example, the exit code can be printed with `echo $lastexitcode`.
Expand Down
10 changes: 7 additions & 3 deletions WireGuardServerForWindows/Controls/PrerequisiteItemControl.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,15 @@
<Grid>
<!-- Keep these buttons in sync with the dropdown buttons below. -->
<Button Padding="5"
Content="{Binding ResolveText}"
Content="{Binding ResolveText}"
HorizontalContentAlignment="Left"
Command="{Binding Commands.ResolveCommand}"
Visibility="{c:Binding '!Fulfilled'}"
IsEnabled="{Binding CanResolve}"
ToolTip="{Binding ErrorMessage}"/>
<Button Padding="5"
Content="{Binding ConfigureText}"
HorizontalContentAlignment="Left"
Command="{Binding Commands.ConfigureCommand}"
Visibility="{c:Binding 'Fulfilled'}"
IsEnabled="{Binding CanConfigure}"
Expand All @@ -105,13 +107,15 @@
<DataTemplate>
<Grid>
<Button Padding="5"
Content="{Binding ResolveText}"
Content="{Binding ResolveText}"
HorizontalContentAlignment="Left"
Command="{Binding Commands.ResolveCommand}"
Visibility="{c:Binding '!Fulfilled'}"
IsEnabled="{Binding CanResolve}"
ToolTip="{Binding ErrorMessage}"/>
<Button Padding="5"
Content="{Binding ConfigureText}"
Content="{Binding ConfigureText}"
HorizontalContentAlignment="Left"
Command="{Binding Commands.ConfigureCommand}"
Visibility="{c:Binding 'Fulfilled'}"
IsEnabled="{Binding CanConfigure}"
Expand Down
15 changes: 13 additions & 2 deletions WireGuardServerForWindows/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.ComponentModel;
using System.IO;
using System.Linq;
using System.Windows;
using System.Windows.Input;
Expand All @@ -16,14 +17,20 @@ public partial class MainWindow : Window
{
public MainWindow()
{
AppSettings.Instance.Load();

InitializeComponent();

// Never put quotes around config file values
Configuration.OutputRawStringValues = true;

var wireGuardExePrerequisite = new WireGuardExePrerequisite();
var serverConfigurationPrerequisite = new ServerConfigurationPrerequisite();
var clientConfigurationsPrerequisite = new ClientConfigurationsPrerequisite();
var openServerConfigDirectorySubCommand = new OpenServerConfigDirectorySubCommand();
var changeServerConfigDirectorySubCommand = new ChangeServerConfigDirectorySubCommand();
var serverConfigurationPrerequisite = new ServerConfigurationPrerequisite(openServerConfigDirectorySubCommand, changeServerConfigDirectorySubCommand);
var openClientConfigDirectorySubCommand = new OpenClientConfigDirectorySubCommand();
var changeClientConfigDirectorySubCommand = new ChangeClientConfigDirectorySubCommand();
var clientConfigurationsPrerequisite = new ClientConfigurationsPrerequisite(openClientConfigDirectorySubCommand, changeClientConfigDirectorySubCommand);
var tunnelServicePrerequisite = new TunnelServicePrerequisite();
var privateNetworkPrerequisite = new PrivateNetworkPrerequisite();
var netIpAddressTaskSubCommand = new NewNetIpAddressTaskSubCommand();
Expand Down Expand Up @@ -61,6 +68,10 @@ public MainWindow()
// Can't view server status unless tunnel is installed
serverStatusPrerequisite.CanConfigureFunc = () => tunnelServicePrerequisite.Fulfilled;

// Can't open server or folders unless they exist
openServerConfigDirectorySubCommand.CanConfigureFunc = () => Directory.Exists(ServerConfigurationPrerequisite.ServerConfigDirectory);
openClientConfigDirectorySubCommand.CanConfigureFunc = () => Directory.Exists(ClientConfigurationsPrerequisite.ClientConfigDirectory);

// Add the prereqs to the Model
MainWindowModel mainWindowModel = new MainWindowModel();
mainWindowModel.PrerequisiteItems.Add(wireGuardExePrerequisite);
Expand Down
58 changes: 58 additions & 0 deletions WireGuardServerForWindows/Models/AppSettings.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
using System;
using System.IO;
using GalaSoft.MvvmLight;
using Jot;
using Jot.Storage;

namespace WireGuardServerForWindows.Models
{
/// <summary>
/// Defines application-wide settings which will be persisted across sessions
/// </summary>
internal class AppSettings : ObservableObject
{
/// <summary>
/// Singleton instance
/// </summary>
public static AppSettings Instance { get; } = new AppSettings();

public void Load()
{
Tracker.Configure<AppSettings>()
.Property(a => a.CustomServerConfigDirectory)
.Property(a => a.CustomClientConfigDirectory)
.Track(this);
}

public void Save()
{
Tracker.Persist(this);
}

/// <summary>
/// The parent directory of the server configuration files
/// </summary>
public string CustomServerConfigDirectory
{
get => _customServerConfigDirectory;
set => Set(nameof(CustomServerConfigDirectory), ref _customServerConfigDirectory, value);
}
private string _customServerConfigDirectory;

/// <summary>
/// The parent directory of the client configuration files
/// </summary>
public string CustomClientConfigDirectory
{
get => _customClientConfigDirectory;
set => Set(nameof(CustomClientConfigDirectory), ref _customClientConfigDirectory, value);
}
private string _customClientConfigDirectory;

#region Private fields

private static readonly Tracker Tracker = new Tracker(new JsonFileStore(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "WS4W")));

#endregion
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
using System;
using System.IO;
using System.Windows.Input;
using Microsoft.WindowsAPICodePack.Dialogs;
using WireGuardServerForWindows.Properties;

namespace WireGuardServerForWindows.Models
{
public class ChangeClientConfigDirectorySubCommand : PrerequisiteItem
{
public ChangeClientConfigDirectorySubCommand() : base
(
title: string.Empty,
successMessage: string.Empty,
errorMessage: string.Empty,
resolveText: string.Empty,
configureText: Resources.ChangeClientConfigDirectoryConfigureText
)
{
AppSettings.Instance.PropertyChanged += (_, args) =>
{
if (args.PropertyName == nameof(AppSettings.Instance.CustomClientConfigDirectory))
{
RaisePropertyChanged(nameof(SuccessMessage));
}
};
}

#region PrerequisiteItem members

public override string SuccessMessage
{
get => string.Format(Resources.ChangeClientConfigDirectorySuccessMessage, ClientConfigurationsPrerequisite.ClientConfigDirectory);
set { }
}

public override void Configure()
{
using CommonOpenFileDialog commonOpenFileDialog = new CommonOpenFileDialog
{
IsFolderPicker = true,
InitialDirectory = ClientConfigurationsPrerequisite.ClientConfigDirectory
};

if (commonOpenFileDialog.ShowDialog() == CommonFileDialogResult.Ok
&& Directory.Exists(commonOpenFileDialog.FileName)
&& !commonOpenFileDialog.FileName.Equals(ClientConfigurationsPrerequisite.ClientConfigDirectory, StringComparison.OrdinalIgnoreCase))
{
Mouse.OverrideCursor = Cursors.Wait;

if (Directory.Exists(ClientConfigurationsPrerequisite.ClientWGDirectory))
{
Directory.Move(ClientConfigurationsPrerequisite.ClientWGDirectory, Path.Combine(commonOpenFileDialog.FileName, Path.GetFileName(ClientConfigurationsPrerequisite.ClientWGDirectory)));
}

if (Directory.Exists(ClientConfigurationsPrerequisite.ClientDataDirectory))
{
Directory.Move(ClientConfigurationsPrerequisite.ClientDataDirectory, Path.Combine(commonOpenFileDialog.FileName, Path.GetFileName(ClientConfigurationsPrerequisite.ClientDataDirectory)));
}

AppSettings.Instance.CustomClientConfigDirectory = commonOpenFileDialog.FileName;
AppSettings.Instance.Save();

Mouse.OverrideCursor = null;
}
}

#endregion
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
using System;
using System.IO;
using System.Windows.Input;
using Microsoft.WindowsAPICodePack.Dialogs;
using WireGuardServerForWindows.Properties;

namespace WireGuardServerForWindows.Models
{
public class ChangeServerConfigDirectorySubCommand : PrerequisiteItem
{
public ChangeServerConfigDirectorySubCommand() : base
(
title: string.Empty,
successMessage: string.Empty,
errorMessage: string.Empty,
resolveText: string.Empty,
configureText: Resources.ChangeServerConfigDirectoryConfigureText
)
{
AppSettings.Instance.PropertyChanged += (_, args) =>
{
if (args.PropertyName == nameof(AppSettings.Instance.CustomServerConfigDirectory))
{
RaisePropertyChanged(nameof(SuccessMessage));
}
};
}

#region PrerequisiteItem members

public override string SuccessMessage
{
get => string.Format(Resources.ChangeServerConfigDirectorySuccessMessage, ServerConfigurationPrerequisite.ServerConfigDirectory);
set { }
}

public override void Configure()
{
using CommonOpenFileDialog commonOpenFileDialog = new CommonOpenFileDialog
{
IsFolderPicker = true,
InitialDirectory = ServerConfigurationPrerequisite.ServerConfigDirectory
};

if (commonOpenFileDialog.ShowDialog() == CommonFileDialogResult.Ok
&& Directory.Exists(commonOpenFileDialog.FileName)
&& !commonOpenFileDialog.FileName.Equals(ServerConfigurationPrerequisite.ServerConfigDirectory, StringComparison.OrdinalIgnoreCase))
{
Mouse.OverrideCursor = Cursors.Wait;

if (Directory.Exists(ServerConfigurationPrerequisite.ServerWGDirectory))
{
Directory.Move(ServerConfigurationPrerequisite.ServerWGDirectory, Path.Combine(commonOpenFileDialog.FileName, Path.GetFileName(ServerConfigurationPrerequisite.ServerWGDirectory)));
}

if (Directory.Exists(ServerConfigurationPrerequisite.ServerDataDirectory))
{
Directory.Move(ServerConfigurationPrerequisite.ServerDataDirectory, Path.Combine(commonOpenFileDialog.FileName, Path.GetFileName(ServerConfigurationPrerequisite.ServerDataDirectory)));
}

AppSettings.Instance.CustomServerConfigDirectory = commonOpenFileDialog.FileName;
AppSettings.Instance.Save();

Mouse.OverrideCursor = null;
}
}

#endregion
}
}
Loading

0 comments on commit f13fa60

Please sign in to comment.