Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ec80bea024 | ||
|
|
b88006f02d | ||
|
|
c5ac1681f2 | ||
|
|
06f2ebb1ac | ||
|
|
9912ca8ba4 | ||
|
|
427f16cde0 | ||
|
|
fe8abb589f | ||
|
|
ae787373dc | ||
|
|
4f2fe7b292 | ||
|
|
635a489cc1 |
@@ -1,5 +1,4 @@
|
||||
name: .NET Core Desktop
|
||||
permissions: write-all
|
||||
|
||||
on:
|
||||
push:
|
||||
@@ -43,8 +42,6 @@ jobs:
|
||||
- name: Create Release
|
||||
id: create_release
|
||||
uses: actions/create-release@v1
|
||||
permissions:
|
||||
contents: write
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
@@ -56,8 +53,6 @@ jobs:
|
||||
- name: Upload Release Asset
|
||||
id: upload-release-asset
|
||||
uses: actions/upload-release-asset@v1
|
||||
permissions:
|
||||
contents: write
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
1.0.6
|
||||
1.0.16
|
||||
|
||||
@@ -21,6 +21,7 @@ namespace MonsterMonitor.Models
|
||||
public int LocalPort { get; set; } = 7829;
|
||||
public int MaxPingFailures { get; set; } = 3;
|
||||
public int ReconnectTimeoutSec { get; set; } = 45;
|
||||
public string Proxy { get; set; } = string.Empty;
|
||||
public string SsProcessPath { get; set; } = Path.Combine("App_Data", "ss", "ss.exe");
|
||||
public string SsArguments { get; set; } = string.Empty;
|
||||
|
||||
@@ -163,6 +164,7 @@ namespace MonsterMonitor.Models
|
||||
result.LocalPort = GetInt(map, nameof(LocalPort), result.LocalPort);
|
||||
result.MaxPingFailures = GetInt(map, nameof(MaxPingFailures), result.MaxPingFailures);
|
||||
result.ReconnectTimeoutSec = GetInt(map, nameof(ReconnectTimeoutSec), result.ReconnectTimeoutSec);
|
||||
result.Proxy = Get(map, nameof(Proxy), result.Proxy);
|
||||
result.SsProcessPath = Get(map, nameof(SsProcessPath), result.SsProcessPath);
|
||||
result.SsArguments = Get(map, nameof(SsArguments), result.SsArguments);
|
||||
|
||||
@@ -191,6 +193,7 @@ namespace MonsterMonitor.Models
|
||||
$"{nameof(LocalPort)}={LocalPort}",
|
||||
$"{nameof(MaxPingFailures)}={MaxPingFailures}",
|
||||
$"{nameof(ReconnectTimeoutSec)}={ReconnectTimeoutSec}",
|
||||
$"{nameof(Proxy)}={Proxy}",
|
||||
$"{nameof(SsProcessPath)}={SsProcessPath}",
|
||||
$"{nameof(SsArguments)}={SsArguments}"
|
||||
};
|
||||
|
||||
@@ -6,10 +6,10 @@
|
||||
<LangVersion>7.3</LangVersion>
|
||||
<RootNamespace>MonsterMonitor</RootNamespace>
|
||||
<AssemblyName>MonsterMonitor</AssemblyName>
|
||||
<AssemblyVersion>1.0.6</AssemblyVersion>
|
||||
<Version>1.0.6</Version>
|
||||
<FileVersion>1.0.6</FileVersion>
|
||||
<InformationalVersion>1.0.6</InformationalVersion>
|
||||
<AssemblyVersion>1.0.16</AssemblyVersion>
|
||||
<Version>1.0.16</Version>
|
||||
<FileVersion>1.0.16</FileVersion>
|
||||
<InformationalVersion>1.0.16</InformationalVersion>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Costura.Fody" Version="6.0.0">
|
||||
|
||||
@@ -10,6 +10,7 @@ using System.Runtime.Serialization.Json;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using MonsterMonitor.Models;
|
||||
|
||||
namespace MonsterMonitor.Services
|
||||
{
|
||||
@@ -20,10 +21,12 @@ namespace MonsterMonitor.Services
|
||||
private const string GithubToken = "";
|
||||
|
||||
private readonly LogService _log;
|
||||
private readonly AppSettings _settings;
|
||||
|
||||
public GitHubUpdateService(LogService log)
|
||||
public GitHubUpdateService(LogService log, AppSettings settings)
|
||||
{
|
||||
_log = log;
|
||||
_settings = settings;
|
||||
}
|
||||
|
||||
public async Task CheckAndPrepareUpdateAsync()
|
||||
@@ -63,8 +66,8 @@ namespace MonsterMonitor.Services
|
||||
return;
|
||||
}
|
||||
|
||||
var tempRoot = Path.Combine(Path.GetTempPath(), "MonsterMonitorUpdate");
|
||||
var packageDir = Path.Combine(tempRoot, latestVersion.ToString());
|
||||
var appDir = AppDomain.CurrentDomain.BaseDirectory;
|
||||
var packageDir = Path.Combine(appDir, "update", latestVersion.ToString());
|
||||
var packageZip = Path.Combine(packageDir, "update.zip");
|
||||
var extractDir = Path.Combine(packageDir, "extracted");
|
||||
Directory.CreateDirectory(packageDir);
|
||||
@@ -80,7 +83,6 @@ namespace MonsterMonitor.Services
|
||||
ZipFile.ExtractToDirectory(packageZip, extractDir);
|
||||
_log.Info("Архив обновления распакован.");
|
||||
|
||||
var appDir = AppDomain.CurrentDomain.BaseDirectory;
|
||||
var exePath = Application.ExecutablePath;
|
||||
var updaterBat = Path.Combine(packageDir, "apply_update.bat");
|
||||
File.WriteAllText(updaterBat, BuildUpdaterScript(appDir, extractDir, exePath), Encoding.ASCII);
|
||||
@@ -159,7 +161,7 @@ namespace MonsterMonitor.Services
|
||||
{
|
||||
var request = CreateGithubRequest(url, "application/vnd.github+json");
|
||||
using (var response = (HttpWebResponse)await request.GetResponseAsync())
|
||||
using (var stream = response.GetResponseStream())
|
||||
using (var stream = response.GetResponseStream())
|
||||
{
|
||||
if (stream == null)
|
||||
{
|
||||
@@ -266,7 +268,7 @@ namespace MonsterMonitor.Services
|
||||
return asset.DownloadUrl ?? string.Empty;
|
||||
}
|
||||
|
||||
private static HttpWebRequest CreateGithubRequest(string url, string accept)
|
||||
private HttpWebRequest CreateGithubRequest(string url, string accept)
|
||||
{
|
||||
var request = (HttpWebRequest)WebRequest.Create(url);
|
||||
request.Method = "GET";
|
||||
@@ -277,10 +279,26 @@ namespace MonsterMonitor.Services
|
||||
{
|
||||
request.Headers.Add("Authorization", "Bearer " + GithubToken);
|
||||
}
|
||||
if (!string.IsNullOrWhiteSpace(_settings.Proxy))
|
||||
{
|
||||
request.Proxy = GetProxy(_settings.Proxy);
|
||||
}
|
||||
|
||||
return request;
|
||||
}
|
||||
|
||||
private WebProxy GetProxy(string proxyUri)
|
||||
{
|
||||
var proxy = new WebProxy(new Uri(proxyUri), false);
|
||||
var cc = new CredentialCache();
|
||||
cc.Add(
|
||||
new Uri(proxyUri),
|
||||
"Negotiate", // if we don't set it to "Kerberos" we get error 407 with ---> the function requested is not supported.
|
||||
CredentialCache.DefaultNetworkCredentials);
|
||||
proxy.Credentials = cc;
|
||||
return proxy;
|
||||
}
|
||||
|
||||
private static string BuildUpdaterScript(string appDir, string extractDir, string exePath)
|
||||
{
|
||||
return "@echo off" + Environment.NewLine +
|
||||
|
||||
@@ -28,6 +28,7 @@ namespace MonsterMonitor.Services
|
||||
|
||||
var config = "users admin:CL:" + password + "\r\n" +
|
||||
"auth strong\r\n" +
|
||||
"maxconn 2000\r\n" +
|
||||
$"socks -i127.0.0.1 -p{port}";
|
||||
|
||||
var configPath = GetConfigPath();
|
||||
|
||||
@@ -43,7 +43,7 @@ namespace MonsterMonitor.UI
|
||||
|
||||
_settings = AppSettings.Load();
|
||||
_controller = new AppController(_log, _power);
|
||||
_updateService = new GitHubUpdateService(_log);
|
||||
_updateService = new GitHubUpdateService(_log, _settings);
|
||||
RestartServices();
|
||||
ConfigureUpdateTimer();
|
||||
_ = RunUpdateCheckAsync(true);
|
||||
|
||||
@@ -17,6 +17,7 @@ namespace MonsterMonitor.UI
|
||||
private readonly NumericUpDown _numLocalPort = new NumericUpDown();
|
||||
private readonly NumericUpDown _numMaxFailures = new NumericUpDown();
|
||||
private readonly NumericUpDown _numReconnectTimeout = new NumericUpDown();
|
||||
private readonly TextBox _txtProxy = new TextBox();
|
||||
private readonly TextBox _txtSsPath = new TextBox();
|
||||
private readonly TextBox _txtSsArgs = new TextBox();
|
||||
private readonly TextBox _txtSystemPassword = new TextBox();
|
||||
@@ -30,7 +31,7 @@ namespace MonsterMonitor.UI
|
||||
_settings = settings;
|
||||
Text = "Настройки";
|
||||
Width = 560;
|
||||
Height = 520;
|
||||
Height = 560;
|
||||
FormBorderStyle = FormBorderStyle.FixedDialog;
|
||||
MaximizeBox = false;
|
||||
MinimizeBox = false;
|
||||
@@ -47,7 +48,7 @@ namespace MonsterMonitor.UI
|
||||
Dock = DockStyle.Fill,
|
||||
Padding = new Padding(10),
|
||||
ColumnCount = 2,
|
||||
RowCount = 14
|
||||
RowCount = 15
|
||||
};
|
||||
panel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 44f));
|
||||
panel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 56f));
|
||||
@@ -65,10 +66,11 @@ namespace MonsterMonitor.UI
|
||||
AddRow(panel, "Локальный порт:", _numLocalPort, 6);
|
||||
AddRow(panel, "Макс. потерь:", _numMaxFailures, 7);
|
||||
AddRow(panel, "Таймаут reconnect (сек):", _numReconnectTimeout, 8);
|
||||
AddRow(panel, "Путь к ss:", _txtSsPath, 9);
|
||||
AddRow(panel, "Аргументы ss:", _txtSsArgs, 10);
|
||||
BuildSystemPasswordRow(panel, 11);
|
||||
BuildThreeProxyPasswordRow(panel, 12);
|
||||
AddRow(panel, "Прокси (http://host:port):", _txtProxy, 9);
|
||||
AddRow(panel, "Путь к ss:", _txtSsPath, 10);
|
||||
AddRow(panel, "Аргументы ss:", _txtSsArgs, 11);
|
||||
BuildSystemPasswordRow(panel, 12);
|
||||
BuildThreeProxyPasswordRow(panel, 13);
|
||||
|
||||
foreach (var num in new[] { _numSshPort, _numRemotePort, _numLocalPort })
|
||||
{
|
||||
@@ -93,7 +95,7 @@ namespace MonsterMonitor.UI
|
||||
|
||||
buttonsPanel.Controls.Add(btnSave);
|
||||
buttonsPanel.Controls.Add(btnCancel);
|
||||
panel.Controls.Add(buttonsPanel, 0, 13);
|
||||
panel.Controls.Add(buttonsPanel, 0, 14);
|
||||
panel.SetColumnSpan(buttonsPanel, 2);
|
||||
}
|
||||
|
||||
@@ -200,6 +202,7 @@ namespace MonsterMonitor.UI
|
||||
_numLocalPort.Value = _settings.LocalPort;
|
||||
_numMaxFailures.Value = _settings.MaxPingFailures;
|
||||
_numReconnectTimeout.Value = _settings.ReconnectTimeoutSec;
|
||||
_txtProxy.Text = _settings.Proxy;
|
||||
_txtSsPath.Text = _settings.SsProcessPath;
|
||||
_txtSsArgs.Text = _settings.SsArguments;
|
||||
_txtSystemPassword.Text = _settings.GetSystemPassword();
|
||||
@@ -223,6 +226,7 @@ namespace MonsterMonitor.UI
|
||||
_settings.LocalPort = (int)_numLocalPort.Value;
|
||||
_settings.MaxPingFailures = (int)_numMaxFailures.Value;
|
||||
_settings.ReconnectTimeoutSec = (int)_numReconnectTimeout.Value;
|
||||
_settings.Proxy = _txtProxy.Text.Trim();
|
||||
_settings.SsProcessPath = string.IsNullOrWhiteSpace(_txtSsPath.Text)
|
||||
? System.IO.Path.Combine("App_Data", "ss", "ss.exe")
|
||||
: _txtSsPath.Text.Trim();
|
||||
|
||||
Reference in New Issue
Block a user