Compare commits

...
12 Commits
Author SHA1 Message Date
kislovdm ec80bea024 maxconn
.NET Core Desktop / build (Debug) (push) Has been cancelled
2026-04-27 01:14:42 +03:00
kislovdm b88006f02d maxconn
.NET Core Desktop / build (Debug) (push) Has been cancelled
2026-04-27 01:11:03 +03:00
kislovdm c5ac1681f2 maxconn
.NET Core Desktop / build (Debug) (push) Has been cancelled
2026-04-27 01:04:30 +03:00
kislovdm 06f2ebb1ac maxconn
.NET Core Desktop / build (Debug) (push) Has been cancelled
2026-04-27 01:02:02 +03:00
kislovdm 9912ca8ba4 maxconn
.NET Core Desktop / build (Debug) (push) Has been cancelled
2026-04-27 00:57:20 +03:00
kislovdm 427f16cde0 maxconn
.NET Core Desktop / build (Debug) (push) Has been cancelled
2026-04-27 00:53:56 +03:00
kislovdm fe8abb589f maxconn
.NET Core Desktop / build (Debug) (push) Has been cancelled
2026-04-27 00:49:24 +03:00
kislovdm ae787373dc releases
.NET Core Desktop / build (Debug) (push) Has been cancelled
2026-04-27 00:48:17 +03:00
kislovdm 4f2fe7b292 releases
.NET Core Desktop / build (Debug) (push) Has been cancelled
2026-04-27 00:47:40 +03:00
kislovdm 635a489cc1 releases
.NET Core Desktop / build (Debug) (push) Has been cancelled
2026-04-27 00:44:39 +03:00
kislovdm 5b82edb9ee releases
.NET Core Desktop / build (Debug) (push) Has been cancelled
2026-04-27 00:44:01 +03:00
kislovdm 84e0fbb959 releases
.NET Core Desktop / build (Debug) (push) Has been cancelled
2026-04-27 00:36:21 +03:00
8 changed files with 84 additions and 25 deletions
-1
View File
@@ -1,5 +1,4 @@
name: .NET Core Desktop
permissions: write-all
on:
push:
+1 -1
View File
@@ -1 +1 @@
1.0.4
1.0.16
+3
View File
@@ -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}"
};
+4 -4
View File
@@ -6,10 +6,10 @@
<LangVersion>7.3</LangVersion>
<RootNamespace>MonsterMonitor</RootNamespace>
<AssemblyName>MonsterMonitor</AssemblyName>
<AssemblyVersion>1.0.4</AssemblyVersion>
<Version>1.0.4</Version>
<FileVersion>1.0.4</FileVersion>
<InformationalVersion>1.0.4</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);
@@ -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();
+37 -3
View File
@@ -13,6 +13,7 @@ namespace MonsterMonitor.UI
private readonly Button _btnSettings = new Button();
private readonly Button _btnExit = new Button();
private readonly NotifyIcon _notifyIcon = new NotifyIcon();
private readonly Timer _updateTimer = new Timer();
private readonly Icon _trayIcon;
private readonly LogService _log = new LogService();
private readonly PowerManagementService _power = new PowerManagementService();
@@ -20,6 +21,7 @@ namespace MonsterMonitor.UI
private AppController _controller;
private AppSettings _settings;
private bool _allowClose;
private bool _isUpdateCheckRunning;
public MainForm()
{
@@ -41,9 +43,10 @@ namespace MonsterMonitor.UI
_settings = AppSettings.Load();
_controller = new AppController(_log, _power);
_updateService = new GitHubUpdateService(_log);
_updateService = new GitHubUpdateService(_log, _settings);
RestartServices();
_ = RunUpdateCheckAsync();
ConfigureUpdateTimer();
_ = RunUpdateCheckAsync(true);
}
private void BuildUi()
@@ -148,6 +151,8 @@ namespace MonsterMonitor.UI
}
_notifyIcon.Visible = false;
_updateTimer.Stop();
_updateTimer.Dispose();
_controller?.Dispose();
_trayIcon?.Dispose();
}
@@ -168,12 +173,41 @@ namespace MonsterMonitor.UI
_console.ScrollToCaret();
}
private async Task RunUpdateCheckAsync()
private void ConfigureUpdateTimer()
{
_updateTimer.Interval = (int)TimeSpan.FromHours(1).TotalMilliseconds;
_updateTimer.Tick += async (_, __) => await RunUpdateCheckAsync(false);
_updateTimer.Start();
_log.Info("Автопроверка обновлений включена (раз в 1 час).");
}
private async Task RunUpdateCheckAsync(bool isInitialCheck)
{
if (_isUpdateCheckRunning)
{
return;
}
try
{
_isUpdateCheckRunning = true;
if (isInitialCheck)
{
// Небольшая задержка, чтобы окно и лог уже успели инициализироваться.
await Task.Delay(1000);
}
else
{
_log.Info("Плановая проверка обновлений...");
}
await _updateService.CheckAndPrepareUpdateAsync();
}
finally
{
_isUpdateCheckRunning = false;
}
}
private static Color GetColor(LogLevel level)
{
+11 -7
View File
@@ -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();