├── icon.ico
├── tray-off.ico
├── tray-on.ico
├── screens
├── screen_en.png
└── screen_ru.png
├── .gitignore
├── .editorconfig
├── FodyWeavers.xml
├── src
├── JsonSerializer.cs
├── ProxiFyreConfig.cs
├── AutorunManager.cs
├── HotkeyTextBox.cs
├── Logger.cs
├── Localization.cs
├── DpiScaler.cs
├── Program.cs
├── RoundButton.cs
├── HotkeyManager.cs
├── AppSettings.cs
├── ProcessManager.cs
├── MainForm.cs
├── ProxyTestManager.cs
└── SettingsForm.cs
├── proxytest
├── domains.txt
└── strategies.txt
├── bdmanager.csproj
├── README.en.md
├── README.md
├── locale
├── en.json
├── ru.json
└── tr.json
└── LICENSE
/icon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/romanvht/ByeDPIManager/HEAD/icon.ico
--------------------------------------------------------------------------------
/tray-off.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/romanvht/ByeDPIManager/HEAD/tray-off.ico
--------------------------------------------------------------------------------
/tray-on.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/romanvht/ByeDPIManager/HEAD/tray-on.ico
--------------------------------------------------------------------------------
/screens/screen_en.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/romanvht/ByeDPIManager/HEAD/screens/screen_en.png
--------------------------------------------------------------------------------
/screens/screen_ru.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/romanvht/ByeDPIManager/HEAD/screens/screen_ru.png
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | bin/
2 | obj/
3 | .vs/
4 | .vscode/
5 | Thumbs.db
6 | ehthumbs.db
7 | Desktop.ini
8 | $RECYCLE.BIN/
9 | *.tmp
10 | *.log
11 | *.sln
12 | FodyWeavers.xsd
--------------------------------------------------------------------------------
/.editorconfig:
--------------------------------------------------------------------------------
1 | [*]
2 | indent_style = space
3 | indent_size = 2
4 | charset = utf-8
5 | trim_trailing_whitespace = true
6 | insert_final_newline = true
7 |
8 | [*.cs]
9 | csharp_new_line_before_open_brace = none
10 |
--------------------------------------------------------------------------------
/FodyWeavers.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/src/JsonSerializer.cs:
--------------------------------------------------------------------------------
1 | namespace bdmanager {
2 | public static class JsonSerializer {
3 | public static string Serialize(object obj) {
4 | var serializer = new System.Web.Script.Serialization.JavaScriptSerializer();
5 | string json = serializer.Serialize(obj);
6 |
7 | return json;
8 | }
9 |
10 | public static T Deserialize(string json) where T : new() {
11 | var serializer = new System.Web.Script.Serialization.JavaScriptSerializer();
12 | return serializer.Deserialize(json);
13 | }
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/proxytest/domains.txt:
--------------------------------------------------------------------------------
1 | youtu.be
2 | youtube.com
3 | i.ytimg.com
4 | i9.ytimg.com
5 | yt3.ggpht.com
6 | yt4.ggpht.com
7 | googleapis.com
8 | jnn-pa.googleapis.com
9 | googleusercontent.com
10 | signaler-pa.youtube.com
11 | youtubei.googleapis.com
12 | manifest.googlevideo.com
13 | yt3.googleusercontent.com
14 | rr1---sn-4axm-n8vs.googlevideo.com
15 | rr1---sn-gvnuxaxjvh-o8ge.googlevideo.com
16 | rr1---sn-ug5onuxaxjvh-p3ul.googlevideo.com
17 | rr1---sn-ug5onuxaxjvh-n8v6.googlevideo.com
18 | rr4---sn-q4flrnsl.googlevideo.com
19 | rr10---sn-gvnuxaxjvh-304z.googlevideo.com
20 | rr14---sn-n8v7kn7r.googlevideo.com
21 | rr16---sn-axq7sn76.googlevideo.com
22 | rr1---sn-8ph2xajvh-5xge.googlevideo.com
23 | rr1---sn-gvnuxaxjvh-5gie.googlevideo.com
24 | rr12---sn-gvnuxaxjvh-bvwz.googlevideo.com
25 | rr5---sn-n8v7knez.googlevideo.com
26 | rr1---sn-u5uuxaxjvhg0-ocje.googlevideo.com
27 | rr2---sn-q4fl6ndl.googlevideo.com
28 | rr5---sn-gvnuxaxjvh-n8vk.googlevideo.com
29 | rr4---sn-jvhnu5g-c35d.googlevideo.com
30 | rr1---sn-q4fl6n6y.googlevideo.com
31 | rr2---sn-hgn7ynek.googlevideo.com
32 | rr1---sn-xguxaxjvh-gufl.googlevideo.com
--------------------------------------------------------------------------------
/src/ProxiFyreConfig.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.IO;
3 |
4 | namespace bdmanager {
5 | public class ProxyConfig {
6 | public List appNames { get; set; } = new List();
7 | public string socks5ProxyEndpoint { get; set; } = "127.0.0.1:1080";
8 | public List supportedProtocols { get; set; } = new List { "TCP", "UDP" };
9 | }
10 |
11 | public class ProxiFyreConfig {
12 | public string logLevel { get; set; } = "error";
13 | public List proxies { get; set; } = new List();
14 | public List excludes { get; set; } = new List();
15 |
16 | public static ProxiFyreConfig Load(string filePath) {
17 | if (File.Exists(filePath)) {
18 | string json = File.ReadAllText(filePath);
19 | return JsonSerializer.Deserialize(json);
20 | }
21 | return new ProxiFyreConfig();
22 | }
23 |
24 | public void Save(string filePath) {
25 | string json = JsonSerializer.Serialize(this);
26 | File.WriteAllText(filePath, json);
27 | }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/AutorunManager.cs:
--------------------------------------------------------------------------------
1 | using System.Windows.Forms;
2 | using Microsoft.Win32;
3 |
4 | namespace bdmanager {
5 | public class AutorunManager {
6 | private const string RunKey = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run";
7 | private readonly string _appName;
8 | private readonly string _appPath;
9 |
10 | public AutorunManager() {
11 | _appName = Program.appName;
12 | _appPath = Application.ExecutablePath;
13 | }
14 |
15 | public bool IsAutorunEnabled() {
16 | using (RegistryKey key = Registry.CurrentUser.OpenSubKey(RunKey, false)) {
17 | string expectedValue = $"\"{_appPath}\" --autorun";
18 | object value = key?.GetValue(_appName);
19 | return value != null && value.ToString() == expectedValue;
20 | }
21 | }
22 |
23 | public void SetAutorun(bool enabled) {
24 | using (RegistryKey key = Registry.CurrentUser.OpenSubKey(RunKey, true)) {
25 | if (key == null) return;
26 |
27 | if (enabled) {
28 | key.SetValue(_appName, $"\"{_appPath}\" --autorun");
29 | } else {
30 | key.DeleteValue(_appName, false);
31 | }
32 | }
33 | }
34 | }
35 | }
--------------------------------------------------------------------------------
/bdmanager.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | WinExe
5 | net472
6 | true
7 | bdmanager
8 | ByeDPI Manager
9 | ByeDPI Manager
10 | romanvht
11 | Менеджер для ByeDPI и ProxiFyre
12 | icon.ico
13 | 0.3.8
14 | romanvht
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 | Always
37 |
38 |
39 |
40 |
41 |
--------------------------------------------------------------------------------
/src/HotkeyTextBox.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Windows.Forms;
4 |
5 | namespace bdmanager {
6 | public class HotkeyTextBox : TextBox {
7 | private Keys _hotkey;
8 | public Keys Hotkey => _hotkey;
9 |
10 | public HotkeyTextBox() {
11 | KeyDown += HotkeyTextBox_KeyDown;
12 | KeyUp += HotkeyTextBox_KeyUp;
13 | GotFocus += HotkeyTextBox_GotFocus;
14 | LostFocus += HotkeyTextBox_LostFocus;
15 | }
16 |
17 | private void HotkeyTextBox_GotFocus(object sender, EventArgs e) {
18 | Text = Program.localization.GetString("hotkey.wait_input");
19 | }
20 |
21 | private void HotkeyTextBox_LostFocus(object sender, EventArgs e) {
22 | if (string.IsNullOrWhiteSpace(Text) || Text == Program.localization.GetString("hotkey.wait_input")) {
23 | Text = Program.settings.Hotkey;
24 | }
25 | }
26 |
27 | private void HotkeyTextBox_KeyDown(object sender, KeyEventArgs e) {
28 | e.SuppressKeyPress = true;
29 |
30 | var modifiers = new List();
31 | if (e.Control) modifiers.Add("Ctrl");
32 | if (e.Alt) modifiers.Add("Alt");
33 | if (e.Shift) modifiers.Add("Shift");
34 |
35 | if (e.KeyCode != Keys.ControlKey &&
36 | e.KeyCode != Keys.ShiftKey &&
37 | e.KeyCode != Keys.Menu) {
38 | modifiers.Add(e.KeyCode.ToString());
39 | }
40 |
41 | _hotkey = e.KeyData;
42 | Text = string.Join("+", modifiers);
43 | }
44 |
45 | private void HotkeyTextBox_KeyUp(object sender, KeyEventArgs e) {
46 |
47 | }
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/src/Logger.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace bdmanager {
7 | public class Logger {
8 | private readonly string _logsDir;
9 | private string _logFilePath;
10 |
11 | public event EventHandler LogAdded;
12 |
13 | public Logger() {
14 | _logsDir = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "logs");
15 |
16 | if (!Directory.Exists(_logsDir)) {
17 | Directory.CreateDirectory(_logsDir);
18 | }
19 |
20 | InitLogFile();
21 | CleanupOldLogs();
22 | }
23 |
24 | private void InitLogFile() {
25 | try {
26 | string date = DateTime.Now.ToString("dd-MM-yyyy");
27 | _logFilePath = Path.Combine(_logsDir, $"bdmanager_{date}.log");
28 |
29 | if (!File.Exists(_logFilePath)) {
30 | File.WriteAllText(_logFilePath, $"=== bdmanager Log started at {DateTime.Now} ===\r\n", Encoding.UTF8);
31 | }
32 | else {
33 | File.AppendAllText(_logFilePath, $"\r\n=== bdmanager Log continued at {DateTime.Now} ===\r\n", Encoding.UTF8);
34 | }
35 | }
36 | catch (Exception ex) {
37 | Console.WriteLine($"Error initializing log file: {ex.Message}");
38 | }
39 | }
40 |
41 | private void CleanupOldLogs() {
42 | try {
43 | if (!Directory.Exists(_logsDir)) return;
44 |
45 | var files = Directory.GetFiles(_logsDir, "bdmanager_*.log").OrderByDescending(File.GetCreationTime).ToList();
46 |
47 | if (files.Count > 10) {
48 | foreach (var file in files.Skip(10)) {
49 | try {
50 | File.Delete(file);
51 | Console.WriteLine($"Deleted old log: {file}");
52 | }
53 | catch (Exception ex) {
54 | Console.WriteLine($"Error deleting file {file}: {ex.Message}");
55 | }
56 | }
57 | }
58 | }
59 | catch (Exception ex) {
60 | Console.WriteLine($"Error cleaning up old logs: {ex.Message}");
61 | }
62 | }
63 |
64 | public void Log(string message) {
65 | WriteToFile(message);
66 | LogAdded?.Invoke(this, message);
67 | }
68 |
69 | private void WriteToFile(string message) {
70 | try {
71 | string date = DateTime.Now.ToString("dd-MM-yyyy");
72 | string logFilePath = Path.Combine(_logsDir, $"bdmanager_{date}.log");
73 |
74 | if (string.IsNullOrEmpty(_logFilePath) || _logFilePath != logFilePath) {
75 | InitLogFile();
76 | }
77 |
78 | string timestamp = DateTime.Now.ToString("HH:mm:ss");
79 | string logLine = $"[{timestamp}] {message}\r\n";
80 |
81 | File.AppendAllText(_logFilePath, logLine, Encoding.UTF8);
82 | }
83 | catch (Exception ex) {
84 | Console.WriteLine($"Error writing to log: {ex.Message}");
85 | }
86 | }
87 | }
88 | }
89 |
--------------------------------------------------------------------------------
/src/Localization.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using System.Windows.Forms;
5 | using System.Linq;
6 |
7 | namespace bdmanager
8 | {
9 | public class Localization
10 | {
11 | private Dictionary _localeStrings;
12 |
13 | public event EventHandler LanguageChanged;
14 | public static readonly string[] AvailableLanguages = { "ru", "en", "tr" };
15 | public string CurrentLanguage { get; private set; } = "ru";
16 |
17 | public Localization()
18 | {
19 | LoadLanguage(Program.settings.Language);
20 | }
21 |
22 | public string GetString(string key)
23 | {
24 | if (_localeStrings.TryGetValue(key, out string value))
25 | {
26 | return value;
27 | }
28 | return key;
29 | }
30 |
31 | public string GetLanguageName(string languageCode)
32 | {
33 | return GetString($"language.{languageCode}");
34 | }
35 |
36 | private void LoadLanguage(string languageCode)
37 | {
38 | if (!AvailableLanguages.Contains(languageCode))
39 | {
40 | languageCode = "ru";
41 | }
42 |
43 | CurrentLanguage = languageCode;
44 | LoadLanguageFile(languageCode);
45 | }
46 |
47 | public void ChangeLanguage(string languageCode)
48 | {
49 | if (CurrentLanguage != languageCode)
50 | {
51 | LoadLanguage(languageCode);
52 | LanguageChanged?.Invoke(this, EventArgs.Empty);
53 | }
54 | }
55 |
56 | private void LoadLanguageFile(string languageCode)
57 | {
58 | try
59 | {
60 | string resourceName = $"bdmanager.locale.{languageCode}.json";
61 | var assembly = System.Reflection.Assembly.GetExecutingAssembly();
62 |
63 | using (Stream stream = assembly.GetManifestResourceStream(resourceName))
64 | {
65 | if (stream != null)
66 | {
67 | using (StreamReader reader = new StreamReader(stream))
68 | {
69 | string json = reader.ReadToEnd();
70 | _localeStrings = JsonSerializer.Deserialize>(json);
71 | }
72 | }
73 | else
74 | {
75 | MessageBox.Show($"Файл локализации {resourceName} не найден", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
76 | }
77 | }
78 | }
79 | catch (Exception ex)
80 | {
81 | MessageBox.Show($"Ошибка загрузки языка: {ex.Message}", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
82 | }
83 | }
84 | }
85 | }
86 |
--------------------------------------------------------------------------------
/proxytest/strategies.txt:
--------------------------------------------------------------------------------
1 | -d1 -d3+s -s6+s -d9+s -s12+s -d15+s -s20+s -d25+s -s30+s -d35+s -r1+s -S -a1 -As -d1 -d3+s -s6+s -d9+s -s12+s -d15+s -s20+s -d25+s -s30+s -d35+s -S -a1
2 | -o1 -d1 -a1 -At,r,s -s1 -d1 -s5+s -s10+s -s15+s -s20+s -r1+s -S -a1 -As -s1 -d1 -s5+s -s10+s -s15+s -s20+s -S -a1
3 | -n ya.ru -Qr -f-204 -s1:5+sm -a1 -As -d1 -s3+s -s5+s -q7 -a1 -As -o2 -f-43 -a1 -As -r5 -Mh -s1:5+s -s3:7+sm -a1
4 | -d1+s -s50+s -a1 -As -f20 -r2+s -a1 -At -d2 -s1+s -s5+s -s10+s -s15+s -s25+s -s35+s -s50+s -s60+s -a1
5 | -o1 -a1 -At,r,s -f-1 -a1 -At,r,s -d1:11+sm -S -a1 -At,r,s -n ya.ru -Qr -f1 -d1:11+sm -s1:11+sm -S -a1
6 | -d1 -s1 -q1 -Y -a1 -Ar -s5 -o1+s -d3+s -s6+s -d9+s -s12+s -d15+s -s20+s -d25+s -s30+s -d35+s -a1
7 | -s1 -o1 -a1 -Y -Ar -s5 -o1+s -a1 -At -f-1 -r1+s -a1 -As -s1 -o1+s -s-1 -a1
8 | -s1 -d1 -a1 -Y -Ar -d5 -o1+s -a1 -At -f-1 -r1+s -a1 -As -d1 -o1+s -s-1 -a1
9 | -d1 -s1+s -d3+s -s6+s -d9+s -s12+s -d15+s -s20+s -d25+s -s30+s -d35+s -a1
10 | -s1 -q1 -a1 -Y -Ar -a1 -s5 -o2 -At -f-1 -r1+s -a1 -As -s1 -o1+s -s-1 -a1
11 | -s1 -q1 -a1 -Ar -s5 -o1+s -a1 -At -f-1 -d1+s -a1 -As -s1 -o1+s -s-1 -a1
12 | -s1 -q1 -a1 -Ar -s5 -o2 -a1 -At -f-1 -r1+s -a1 -As -s1 -o1+s -s-1 -a1
13 | -d1 -s1+s -d1+s -s3+s -d6+s -s12+s -d14+s -s20+s -d24+s -s30+s -a1
14 | -s1 -q1 -a1 -Y -At -a1 -S -f-1 -r1+s -a1 -As -d1+s -O1 -s29+s -a1
15 | -o1 -a1 -At,r,s -f-1 -a1 -Ar,s -o1 -a1 -At -r1+s -f-1 -t6 -a1
16 | -d1 -s1+s -s3+s -s6+s -s9+s -s12+s -s15+s -s20+s -s30+s -a1
17 | -n ya.ru -d2:5:2+h -f-3 -r2+sm -o2 -o50+s -r2+s -f-4 -a1
18 | -o1 -r-5+se -a1 -At,r,s -d1 -n ya.ru -Qr -f-1 -a1
19 | -s1 -d1 -r1+s -a1 -Ar -o1 -a1 -At -f-1 -r1+s -a1
20 | -s1 -q1 -r1+s -a1 -Ar -o1 -a1 -At -f-1 -r1+s -a1
21 | -s1 -o1 -r1+s -a1 -Ar -o1 -a1 -At -f-1 -r1+s -a1
22 | -n ya.ru -Qr -f6+nr -d2 -d11 -f9+hm -o3 -t7 -a1
23 | -s1 -d1 -o1 -a1 -Ar -o3 -a1 -At -f-1 -r1+s -a1
24 | -d9+s -q20+s -s25+s -t5 -a1 -At,r,s -r1+h -a1
25 | -q1+s -s29+s -s30+s -s14+s -o5+s -f-1 -S -a1
26 | -d9+s -q20+s -s 25+s -t5 -At,r,s -r1+h -a1
27 | -s1 -o1 -a1 -Ar -o1 -a1 -At -f-1 -r1+s -a1
28 | -d1 -o1 -a1 -Ar -o1 -a1 -At -f-1 -r1+s -a1
29 | -d1 -s4 -d8 -s1+s -d5+s -s10+s -d20+s -a1
30 | -n ya.ru -Qr -d5+sm -f3+sm -o2 -t4 -a1
31 | -o1 -a1 -Ar -q1 -a1 -At -f-1 -r1+s -a1
32 | -q1 -a1 -Ar -o1 -a1 -At -f-1 -r1+s -a1
33 | -s1 -q1 -Y -a1 -At,r,s -f-1 -r1+s -a1
34 | -s1 -o1 -Y -a1 -At,r,s -f-1 -r1+s -a1
35 | -s1 -d1 -Y -a1 -At,r,s -f-1 -r1+s -a1
36 | -n ya.ru -Qr -f209 -s1+sm -R1-3 -a1
37 | -s1 -q1 -a1 -At,r,s -f-1 -r1+s -a1
38 | -s1 -o1 -a1 -At,r,s -f-1 -r1+s -a1
39 | -s1 -d1 -a1 -At,r,s -f-1 -r1+s -a1
40 | -o1 -d1 -r1+s -S -s1+s -d3+s -a1
41 | -d1 -r1+s -f-1 -S -t8 -o3+s -a1
42 | -q1+s -s29+s -o5+s -f-1 -S -a1
43 | -d1 -s1+s -r1+s -f-1 -t8 -a1
44 | -n ya.ru -Qr -f-1 -r1+s -a1
45 | -n ya.ru -Qr -d1:3 -f-1 -a1
46 | -s1 -d3+s -a1 -At -r1+s -a1
47 | -o1 -a1 -At,r,s -d1 -a1
48 | -q1 -a1 -At,r,s -d1 -a1
49 | -n ya.ru -Qr -d1 -f-1
50 | -d1+s -o2 -s5 -r5 -a1
51 | -r8 -o2 -s7 -q4+s -a1
52 | -d6+s -q4+hm -o2 -a1
53 | -s1+s -d3+s -a1
54 | -s1 -f-1 -S -a1
55 | -o1+s -d3+s -a1
56 | -o1 -s4 -s6 -a1
57 | -q1 -r25+s -a1
58 | -d1 -s3+s -a1
59 | -o3 -d7 -a1
60 | -d7 -s2 -a1
--------------------------------------------------------------------------------
/src/DpiScaler.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Drawing;
3 | using System.Windows.Forms;
4 | using System.Collections.Generic;
5 |
6 | namespace bdmanager {
7 | public static class DpiScaler {
8 | private static readonly HashSet _scaledForms = new HashSet();
9 |
10 | public static void Scale(Form form) {
11 | string formId = $"{form.Name}_{form.GetHashCode()}";
12 |
13 | if (_scaledForms.Contains(formId))
14 | return;
15 |
16 | float scaleFactor;
17 | using (Graphics g = form.CreateGraphics()) {
18 | scaleFactor = g.DpiX / 96f;
19 | }
20 |
21 | if (Math.Abs(scaleFactor - 1.0f) < 0.01f)
22 | return;
23 |
24 | form.AutoScaleMode = AutoScaleMode.None;
25 |
26 | form.SuspendLayout();
27 |
28 | try {
29 | if (form.FormBorderStyle != FormBorderStyle.None) {
30 | Size originalSize = form.Size;
31 | Size newSize = new Size(
32 | (int)(originalSize.Width * scaleFactor),
33 | (int)(originalSize.Height * scaleFactor)
34 | );
35 | form.Size = newSize;
36 | }
37 |
38 | ScaleControlAndChildren(form, scaleFactor);
39 |
40 | _scaledForms.Add(formId);
41 | }
42 | finally {
43 | form.ResumeLayout(true);
44 | }
45 | }
46 |
47 | private static void ScaleControlAndChildren(Control control, float scaleFactor) {
48 | if (control is ToolStrip || control is MenuStrip || control is StatusStrip)
49 | return;
50 |
51 | if (control is RoundButton roundButton) {
52 | roundButton.BorderRadius = (int)(roundButton.BorderRadius * scaleFactor);
53 | roundButton.BorderSize = Math.Max(1, (int)(roundButton.BorderSize * scaleFactor));
54 | }
55 |
56 | if (!(control is Form) && control.Dock == DockStyle.None) {
57 | control.Size = new Size(
58 | (int)(control.Size.Width * scaleFactor),
59 | (int)(control.Size.Height * scaleFactor)
60 | );
61 | }
62 |
63 | if (!control.MinimumSize.IsEmpty) {
64 | control.MinimumSize = new Size(
65 | (int)Math.Round(control.MinimumSize.Width * scaleFactor * 0.85f),
66 | (int)Math.Round(control.MinimumSize.Height * scaleFactor * 0.85f)
67 | );
68 | }
69 |
70 | if (control is TableLayoutPanel tablePanel) {
71 | foreach (ColumnStyle columnStyle in tablePanel.ColumnStyles) {
72 | if (columnStyle.SizeType == SizeType.Absolute) {
73 | columnStyle.Width = columnStyle.Width * scaleFactor;
74 | }
75 | }
76 | }
77 |
78 | if (control is TextBoxBase textBox) {
79 | if (textBox.Multiline) {
80 | if (textBox.Dock == DockStyle.None) {
81 | textBox.Size = new Size(
82 | (int)(textBox.Size.Width * scaleFactor),
83 | (int)(textBox.Size.Height * scaleFactor)
84 | );
85 | }
86 | }
87 | }
88 |
89 | foreach (Control child in control.Controls) {
90 | ScaleControlAndChildren(child, scaleFactor);
91 | }
92 | }
93 | }
94 | }
95 |
--------------------------------------------------------------------------------
/src/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq;
3 | using System.Threading;
4 | using System.Windows.Forms;
5 | using System.Runtime.InteropServices;
6 |
7 | namespace bdmanager {
8 | static class Program {
9 | private static Mutex _mutex = null;
10 |
11 | public static string appName = null;
12 | public static bool isAutorun = false;
13 |
14 | public static AppSettings settings = null;
15 | public static ProcessManager processManager = null;
16 | public static AutorunManager autorunManager = null;
17 | public static ProxyTestManager proxyTestManager = null;
18 | public static Localization localization = null;
19 | public static Logger logger = null;
20 |
21 | [STAThread]
22 | static void Main(string[] args) {
23 | SetProcessDPIAware();
24 |
25 | appName = System.Reflection.Assembly.GetExecutingAssembly().GetName().Name;
26 | isAutorun = args.Any(arg => arg.ToLower() == "--autorun");
27 |
28 | Application.EnableVisualStyles();
29 | Application.SetCompatibleTextRenderingDefault(false);
30 |
31 | Application.ApplicationExit += Application_ApplicationExit;
32 | Application.ThreadException += Application_ThreadException;
33 | AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
34 |
35 | try {
36 | logger = new Logger();
37 | settings = AppSettings.Load();
38 | localization = new Localization();
39 |
40 | if (IsRunning()) {
41 | MessageBox.Show(
42 | localization.GetString("program.already_running"),
43 | localization.GetString("app_name"),
44 | MessageBoxButtons.OK,
45 | MessageBoxIcon.Information
46 | );
47 | return;
48 | }
49 |
50 | processManager = new ProcessManager();
51 | autorunManager = new AutorunManager();
52 | Application.Run(new MainForm());
53 | }
54 | catch (Exception ex) {
55 | MessageBox.Show(
56 | string.Format(localization.GetString("program.error"), ex.Message),
57 | localization.GetString("app_name"),
58 | MessageBoxButtons.OK,
59 | MessageBoxIcon.Error
60 | );
61 | }
62 | }
63 |
64 | [DllImport("user32.dll")]
65 | static extern bool SetProcessDPIAware();
66 |
67 | private static bool IsRunning() {
68 | _mutex = new Mutex(true, appName, out bool createdNew);
69 | return !createdNew;
70 | }
71 |
72 | private static void Application_ApplicationExit(object sender, EventArgs e) {
73 | ShutdownProcesses();
74 | if (_mutex != null) {
75 | _mutex.ReleaseMutex();
76 | _mutex.Dispose();
77 | }
78 | }
79 |
80 | private static void Application_ThreadException(object sender, ThreadExceptionEventArgs e) {
81 | ShutdownProcesses();
82 | }
83 |
84 | private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) {
85 | ShutdownProcesses();
86 | }
87 |
88 | public static void ShutdownProcesses() {
89 | if (processManager != null && processManager.IsRunning) {
90 | processManager.Stop();
91 | }
92 | }
93 | }
94 | }
95 |
--------------------------------------------------------------------------------
/src/RoundButton.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Drawing;
3 | using System.Drawing.Drawing2D;
4 | using System.Windows.Forms;
5 |
6 | namespace bdmanager {
7 | public class RoundButton : Button {
8 | private Color _borderColor = Color.FromArgb(80, 80, 80);
9 | private Color _hoverColor = Color.FromArgb(70, 70, 70);
10 | private Color _pressedColor = Color.FromArgb(50, 50, 50);
11 | private int _borderSize = 1;
12 | private int _borderRadius = 15;
13 |
14 | public RoundButton() {
15 | FlatStyle = FlatStyle.Flat;
16 | FlatAppearance.BorderSize = 0;
17 | BackColor = Color.FromArgb(50, 50, 50);
18 | ForeColor = Color.White;
19 | Font = new Font("Segoe UI", 10F, FontStyle.Bold);
20 | }
21 |
22 | public Color BorderColor {
23 | get => _borderColor;
24 | set { _borderColor = value; Invalidate(); }
25 | }
26 |
27 | public Color HoverColor {
28 | get => _hoverColor;
29 | set { _hoverColor = value; Invalidate(); }
30 | }
31 |
32 | public Color PressedColor {
33 | get => _pressedColor;
34 | set { _pressedColor = value; Invalidate(); }
35 | }
36 |
37 | public int BorderSize {
38 | get => _borderSize;
39 | set { _borderSize = value; Invalidate(); }
40 | }
41 |
42 | public int BorderRadius {
43 | get => _borderRadius;
44 | set { _borderRadius = value; Invalidate(); }
45 | }
46 |
47 | protected override void OnPaint(PaintEventArgs e) {
48 | base.OnPaint(e);
49 |
50 | Rectangle rectSurface = this.ClientRectangle;
51 | Rectangle rectBorder = Rectangle.Inflate(rectSurface, -_borderSize, -_borderSize);
52 | int smoothSize = _borderRadius > 0 ? _borderRadius : 1;
53 |
54 | using (GraphicsPath pathSurface = GetFigurePath(rectSurface, smoothSize))
55 | using (GraphicsPath pathBorder = GetFigurePath(rectBorder, smoothSize - _borderSize))
56 | using (Pen penSurface = new Pen(Parent.BackColor, _borderSize))
57 | using (Pen penBorder = new Pen(_borderColor, _borderSize)) {
58 | penBorder.Alignment = PenAlignment.Inset;
59 |
60 | e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
61 |
62 | Region = new Region(pathSurface);
63 | e.Graphics.DrawPath(penSurface, pathSurface);
64 | if (_borderSize > 0) e.Graphics.DrawPath(penBorder, pathBorder);
65 | }
66 | }
67 |
68 | private GraphicsPath GetFigurePath(Rectangle rect, int radius) {
69 | GraphicsPath path = new GraphicsPath();
70 | float curveSize = radius * 2F;
71 |
72 | path.StartFigure();
73 | path.AddArc(rect.X, rect.Y, curveSize, curveSize, 180, 90);
74 | path.AddArc(rect.Right - curveSize, rect.Y, curveSize, curveSize, 270, 90);
75 | path.AddArc(rect.Right - curveSize, rect.Bottom - curveSize, curveSize, curveSize, 0, 90);
76 | path.AddArc(rect.X, rect.Bottom - curveSize, curveSize, curveSize, 90, 90);
77 | path.CloseFigure();
78 |
79 | return path;
80 | }
81 |
82 | protected override void OnMouseEnter(EventArgs e) {
83 | base.OnMouseEnter(e);
84 | BackColor = _hoverColor;
85 | }
86 |
87 | protected override void OnMouseDown(MouseEventArgs e) {
88 | base.OnMouseDown(e);
89 | BackColor = _pressedColor;
90 | }
91 |
92 | protected override void OnMouseUp(MouseEventArgs e) {
93 | base.OnMouseUp(e);
94 | BackColor = _hoverColor;
95 | }
96 | }
97 | }
98 |
--------------------------------------------------------------------------------
/src/HotkeyManager.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Runtime.InteropServices;
3 | using System.Windows.Forms;
4 |
5 | namespace bdmanager {
6 | public class HotkeyManager : IDisposable {
7 | private const int WM_HOTKEY = 0x0312;
8 | private const int MOD_ALT = 0x0001;
9 | private const int MOD_CONTROL = 0x0002;
10 | private const int MOD_SHIFT = 0x0004;
11 | private const int MOD_WIN = 0x0008;
12 |
13 | private int _currentHotkeyId = 0;
14 | private readonly IntPtr _windowHandle;
15 | private readonly Action _hotkeyAction;
16 |
17 | [DllImport("user32.dll")]
18 | private static extern bool RegisterHotKey(IntPtr hWnd, int id, int fsModifiers, int vk);
19 |
20 | [DllImport("user32.dll")]
21 | private static extern bool UnregisterHotKey(IntPtr hWnd, int id);
22 |
23 | public HotkeyManager(IntPtr windowHandle, Action hotkeyAction) {
24 | _windowHandle = windowHandle;
25 | _hotkeyAction = hotkeyAction;
26 | }
27 |
28 | public bool RegisterHotkey(string hotkeyCombination) {
29 | UnregisterCurrentHotkey();
30 |
31 | if (string.IsNullOrWhiteSpace(hotkeyCombination))
32 | return false;
33 |
34 | try {
35 | _currentHotkeyId = GetHashCode();
36 | var (modifiers, vk) = ParseHotkeyCombination(hotkeyCombination);
37 | bool registered = RegisterHotKey(_windowHandle, _currentHotkeyId, modifiers, vk);
38 |
39 | if (!registered) {
40 | int error = Marshal.GetLastWin32Error();
41 | Program.logger.Log(string.Format(Program.localization.GetString("hotkey.error"), $"{hotkeyCombination}, WinAPI {error}"));
42 | return false;
43 | }
44 |
45 | return true;
46 | }
47 | catch (Exception ex) {
48 | Program.logger.Log(string.Format(Program.localization.GetString("hotkey.error"), ex.Message));
49 | return false;
50 | }
51 | }
52 |
53 | public void UnregisterCurrentHotkey() {
54 | if (_currentHotkeyId != 0) {
55 | UnregisterHotKey(_windowHandle, _currentHotkeyId);
56 | _currentHotkeyId = 0;
57 | }
58 | }
59 |
60 | public void ProcessMessage(Message m) {
61 | if (m.Msg == WM_HOTKEY && m.WParam.ToInt32() == _currentHotkeyId)
62 | _hotkeyAction?.Invoke();
63 | }
64 |
65 | private (int modifiers, int vk) ParseHotkeyCombination(string combination) {
66 | int modifiers = 0;
67 | Keys mainKey = Keys.None;
68 |
69 | string[] parts = combination.Split(new[] { '+' }, StringSplitOptions.RemoveEmptyEntries);
70 | foreach (var raw in parts) {
71 | var part = raw.Trim();
72 | Keys parsed;
73 |
74 | switch (part.ToUpperInvariant()) {
75 | case "CTRL":
76 | case "CONTROL":
77 | parsed = Keys.ControlKey;
78 | break;
79 | case "ALT":
80 | parsed = Keys.Menu;
81 | break;
82 | case "SHIFT":
83 | parsed = Keys.ShiftKey;
84 | break;
85 | case "WIN":
86 | case "WINDOWS":
87 | parsed = Keys.LWin;
88 | break;
89 | default:
90 | if (!Enum.TryParse(part, true, out parsed))
91 | throw new ArgumentException($"{combination}");
92 | break;
93 | }
94 |
95 | if (parsed == Keys.ControlKey)
96 | modifiers |= MOD_CONTROL;
97 | else if (parsed == Keys.Menu)
98 | modifiers |= MOD_ALT;
99 | else if (parsed == Keys.ShiftKey)
100 | modifiers |= MOD_SHIFT;
101 | else if (parsed == Keys.LWin || parsed == Keys.RWin)
102 | modifiers |= MOD_WIN;
103 | else {
104 | if (mainKey != Keys.None)
105 | throw new ArgumentException($"{combination}");
106 |
107 | mainKey = parsed;
108 | }
109 | }
110 |
111 | if (mainKey == Keys.None)
112 | throw new ArgumentException($"{combination}");
113 |
114 | return (modifiers, (int)mainKey);
115 | }
116 |
117 | public void Dispose() {
118 | UnregisterCurrentHotkey();
119 | GC.SuppressFinalize(this);
120 | }
121 | }
122 | }
123 |
--------------------------------------------------------------------------------
/README.en.md:
--------------------------------------------------------------------------------
1 | # ByeDPI Manager
2 |
3 | [Русский](README.md) | English
4 |
5 | A mini utility for running ByeDPI and ProxiFyre.
6 |
7 | 
8 |
9 | ## Requirements
10 |
11 | 1. Windows 7+, [.NET Framework 4.7.2+](https://dotnet.microsoft.com/en-us/download/dotnet-framework/thank-you/net472-offline-installer)
12 | 2. [ProxiFyre](https://github.com/wiresock/proxifyre), [Windows Packet Filter](https://github.com/wiresock/ndisapi), [Visual C++ Redist 2022](https://learn.microsoft.com/en-us/cpp/windows/latest-supported-vc-redist?view=msvc-170#latest-microsoft-visual-c-redistributable-version)
13 | 3. [ByeDPI](https://github.com/hufrea/byedpi)
14 |
15 | ## Installation
16 |
17 | * Instructions from the community [ByeDPI Manager Manual](https://github.com/BDManual/ByeDPIManager-Manual)
18 |
19 | ### Option 1: All-in-One (Recommended for beginners)
20 |
21 | This option includes all necessary components in a single archive.
22 |
23 | 1. **Download:**
24 |
25 | * Go to the release page: [https://github.com/romanvht/ByeDPIManager/releases/latest](https://github.com/romanvht/ByeDPIManager/releases/latest)
26 | * Download the `All_In_One_w64.zip` file
27 |
28 | 2. **Extraction:**
29 |
30 | * Locate the downloaded file on your computer
31 | * Right-click and select “Extract All…”
32 | * Choose an installation folder (e.g., `C:\APPS\ByeDPIManager`)
33 |
34 | 3. **Installing dependencies:**
35 |
36 | * Open the `redist` folder inside the extracted archive
37 | * Install both apps from this folder:
38 |
39 | * Windows Packet Filter (required for ProxiFyre)
40 | * Visual C++ Redistributable 2022
41 |
42 | ### Option 2: Manual Installation (For advanced users)
43 |
44 | If you prefer managing components separately:
45 |
46 | 1. **Download components separately:**
47 |
48 | * [Manager](https://github.com/romanvht/ByeDPIManager/releases/latest)
49 | * [ByeDPI](https://github.com/hufrea/byedpi)
50 | * [ProxiFyre](https://github.com/wiresock/proxifyre)
51 |
52 | 2. **Install dependencies:**
53 |
54 | * [Windows Packet Filter](https://github.com/wiresock/ndisapi) (Required for ProxiFyre)
55 | * [Visual C++ Redistributable 2022](https://learn.microsoft.com/en-us/cpp/windows/latest-supported-vc-redist?view=msvc-170#latest-microsoft-visual-c-redistributable-version)
56 |
57 | 3. **Extract all components into convenient folders**
58 |
59 | 4. **Run and set paths:**
60 |
61 | * Specify the correct path to `ciadpi.exe` in the ByeDPI tab
62 | * Specify the correct path to `proxifyre.exe` in the ProxiFyre tab
63 |
64 | ## Configuration
65 |
66 | ### Initial Setup
67 |
68 | 1. **Launch the program:**
69 |
70 | * Run `ByeDPI Manager.exe`
71 | * Click the "Settings" button
72 |
73 | 2. **ProxiFyre setup:**
74 |
75 | * Go to the “ProxiFyre” tab
76 | * Specify applications to be bypassed (e.g., Chrome, Firefox, etc.)
77 |
78 | ### Strategy Configuration
79 |
80 | #### Using a predefined strategy
81 |
82 | * Enter the desired strategy in the “Arguments” field on the “ByeDPI” tab
83 |
84 | #### Strategy testing (optional)
85 |
86 | If you don’t have a predefined strategy, you can use the built-in tester:
87 |
88 | 1. **Go to the tester tab:**
89 |
90 | * Open the “Strategy Test (Beta)” tab
91 |
92 | 2. **Start test:**
93 |
94 | * Click “Start”
95 | * The first time you run it, you’ll be asked to allow `ciadpi.exe` network access – click “Allow”
96 |
97 | 3. **Select a strategy:**
98 |
99 | * After the test completes, strategies with over 50% success will be listed in the log
100 | * Select the best one and copy it (Ctrl+C)
101 |
102 | 4. **Apply the strategy:**
103 |
104 | * Go back to the “ByeDPI” tab
105 | * Paste the copied strategy into the “Arguments” field (Ctrl+V)
106 |
107 | 5. **Customize testing (optional):**
108 |
109 | * Edit the files in the `proxytest` folder:
110 |
111 | * `sites.txt` – add your own sites to test
112 | * `cmds.txt` – add your own strategies to check
113 |
114 | ### Launch and Test
115 |
116 | 1. **Activate:**
117 |
118 | * In the main window, click “Connect”
119 | * The first time, ProxiFyre will ask for network access – click “Allow”
120 |
121 | 2. **Verify it’s working:**
122 |
123 | * Open a browser or app you configured
124 | * Check if the resources are accessible
125 |
126 | ## Troubleshooting
127 |
128 | * If the app won’t start, ensure .NET Framework 4.7.2+ is installed
129 | * If bypassing doesn’t work, try a different strategy
130 | * If connection issues occur, ensure Windows Packet Filter is installed properly
131 | * Make sure your antivirus or firewall isn’t blocking the app
132 |
133 | ## Special Thanks
134 |
135 | * [ByeDPI](https://github.com/hufrea/byedpi)
136 | * [ProxiFyre](https://github.com/wiresock/proxifyre)
137 | * [Windows Packet Filter](https://github.com/wiresock/ndisapi)
138 | * [SocksSharp](https://github.com/extremecodetv/SocksSharp)
139 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # ByeDPI Manager
2 |
3 | Русский | [English](README.en.md)
4 |
5 | Мини утилита для запуска ByeDPI и ProxiFyre.
6 |
7 | 
8 |
9 | ## Требования
10 |
11 | 1. Windows 7+, [.NET Framework 4.7.2+](https://dotnet.microsoft.com/ru-ru/download/dotnet-framework/thank-you/net472-offline-installer)
12 | 2. [ProxiFyre](https://github.com/wiresock/proxifyre), [Windows Packet Filter](https://github.com/wiresock/ndisapi), [Visual C++ Redist 2022](https://learn.microsoft.com/en-us/cpp/windows/latest-supported-vc-redist?view=msvc-170#latest-microsoft-visual-c-redistributable-version)
13 | 3. [ByeDPI](https://github.com/hufrea/byedpi)
14 |
15 | ## Инструкции
16 |
17 | * Комплексная инструкция от комьюнити [ByeDPI Manager Manual](https://github.com/BDManual/ByeDPIManager-Manual)
18 |
19 | ### Вариант 1: All-in-One (Рекомендуется для начинающих)
20 | Этот вариант включает все необходимые компоненты в одном архиве.
21 |
22 | 1. **Скачивание:**
23 | - Перейдите на страницу релизов: https://github.com/romanvht/ByeDPIManager/releases/latest
24 | - Скачайте файл `All_In_One_w64.zip`
25 |
26 | 2. **Распаковка:**
27 | - Найдите скачанный файл на компьютере
28 | - Нажмите правой кнопкой мыши и выберите "Извлечь все…"
29 | - Укажите папку для установки (например, `C:\APPS\ByeDPIManager`)
30 |
31 | 3. **Установка зависимостей:**
32 | - Перейдите в папку `redist` внутри распакованного архива
33 | - Установите оба приложения из этой папки:
34 | - Windows Packet Filter (необходим для работы ProxiFyre)
35 | - Visual C++ Redistributable 2022
36 |
37 | ### Вариант 2: Раздельная установка (Для опытных пользователей)
38 | Если вы предпочитаете управлять компонентами отдельно:
39 |
40 | 1. **Скачайте компоненты отдельно:**
41 | - [Manager](https://github.com/romanvht/ByeDPIManager/releases/latest)
42 | - [ByeDPI](https://github.com/hufrea/byedpi)
43 | - [ProxiFyre](https://github.com/wiresock/proxifyre)
44 |
45 | 2. **Установите зависимости:**
46 | - [Windows Packet Filter](https://github.com/wiresock/ndisapi) (Необходим для работы ProxiFyre)
47 | - [Visual C++ Redistributable 2022](https://learn.microsoft.com/en-us/cpp/windows/latest-supported-vc-redist?view=msvc-170#latest-microsoft-visual-c-redistributable-version)
48 |
49 | 3. **Распакуйте все компоненты в удобные папки**
50 |
51 | 4. **Запустите и укажите пути**
52 | - Укажите правильный путь к файлу `ciadpi.exe` во вкладке ByeDPI
53 | - Укажите правильный путь к файлу `proxifyre.exe` во вкладке ProxiFyre
54 |
55 | ## Настройка
56 |
57 | ### Первоначальная настройка
58 |
59 | 1. **Запуск программы:**
60 | - Запустите файл `ByeDPI Manager.exe`
61 | - Нажмите кнопку "Настройки"
62 |
63 | 2. **Настройка ProxiFyre:**
64 | - Перейдите на вкладку "ProxiFyre"
65 | - Укажите приложения, для которых будет выполняться обход (например, Chrome, Firefox и т.д.)
66 |
67 | ### Настройка стратегии
68 |
69 | #### Использование готовой стратегии
70 | - В поле "Аргументы" на вкладке "ByeDPI" введите нужную стратегию
71 |
72 | #### Подбор стратегии (опционально)
73 | Если у вас нет готовой стратегии, вы можете воспользоваться подбором:
74 |
75 | 1. **Переход к тестированию:**
76 | - Перейдите на вкладку "Подбор стратегии (Beta)"
77 |
78 | 2. **Запуск теста:**
79 | - Нажмите кнопку "Старт"
80 | - При первом запуске появится запрос на разрешение доступа для `ciadpi.exe` к сети - нажмите "Разрешить"
81 |
82 | 3. **Выбор стратегии:**
83 | - После завершения теста в окне "Лог" будут показаны стратегии с успехом более 50%
84 | - Выделите лучшую стратегию мышкой и скопируйте её (Ctrl+C)
85 |
86 | 4. **Применение стратегии:**
87 | - Вернитесь на вкладку "ByeDPI"
88 | - В поле "Аргументы" вставьте скопированную стратегию (Ctrl+V)
89 |
90 | 5. **Настройка тестирования (опционально):**
91 | - Отредактируйте файлы в папке `proxytest`:
92 | - `sites.txt` - добавьте свои сайты для тестирования
93 | - `cmds.txt` - добавьте свои стратегии для проверки
94 |
95 | ### Запуск и проверка
96 |
97 | 1. **Активация:**
98 | - В главном окне нажмите кнопку "Подключить"
99 | - При первом запуске появится запрос на разрешение доступа для ProxiFyre к сети - нажмите "Разрешить"
100 |
101 | 2. **Проверка работы:**
102 | - Откройте браузер или приложение, которое указали в настройках
103 | - Проверьте доступ к ресурсам
104 |
105 | ## Решение проблем
106 |
107 | - Если программа не запускается, убедитесь, что установлен .NET Framework 4.7.2+
108 | - Если не работает обход блокировок, попробуйте другую стратегию
109 | - При проблемах с подключением проверьте, что Windows Packet Filter установлен корректно
110 | - Убедитесь, что антивирус или брандмауэр не блокирует работу программы
111 |
112 | ## Большое спасибо
113 |
114 | - [ByeDPI](https://github.com/hufrea/byedpi)
115 | - [ProxiFyre](https://github.com/wiresock/proxifyre)
116 | - [Windows Packet Filter](https://github.com/wiresock/ndisapi)
117 | - [SocksSharp](https://github.com/extremecodetv/SocksSharp)
118 |
--------------------------------------------------------------------------------
/src/AppSettings.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using System.Linq;
5 |
6 | namespace bdmanager {
7 | public class AppSettings {
8 | public bool AutoStart { get; set; } = false;
9 | public bool AutoConnect { get; set; } = false;
10 | public bool StartMinimized { get; set; } = false;
11 | public string Language { get; set; } = "ru";
12 | public string Hotkey { get; set; } = "Ctrl+Alt+B";
13 |
14 | public string ByeDpiArguments { get; set; } = "-Ku -a1 -An -o1 -At,r,s -d1";
15 |
16 | public bool DisableProxiFyre { get; set; } = false;
17 | public string ProxiFyreIp { get; set; } = "127.0.0.1";
18 | public int ProxiFyrePort { get; set; } = 1080;
19 | public List ProxifiedApps { get; set; } = new List();
20 |
21 | public int ProxyTestDelay { get; set; } = 0;
22 | public int ProxyTestRequestsCount { get; set; } = 1;
23 | public bool ProxyTestFullLog { get; set; } = false;
24 |
25 | public string ByeDpiPath { get; set; } = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "libs", "byedpi", "ciadpi.exe");
26 | public string ProxiFyrePath { get; set; } = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "libs", "proxifyre", "proxifyre.exe");
27 |
28 | private static readonly string SettingsPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "config", "settings.json");
29 |
30 | public static AppSettings Load() {
31 | try {
32 | if (File.Exists(SettingsPath)) {
33 | string json = File.ReadAllText(SettingsPath);
34 | return JsonSerializer.Deserialize(json);
35 | }
36 | }
37 | catch (Exception ex) {
38 | Program.logger.Log($"{ex.Message}");
39 | }
40 |
41 | return new AppSettings();
42 | }
43 |
44 | public void Save() {
45 | try {
46 | string directory = Path.GetDirectoryName(SettingsPath);
47 | if (!Directory.Exists(directory)) {
48 | Directory.CreateDirectory(directory);
49 | }
50 |
51 | string json = JsonSerializer.Serialize(this);
52 | File.WriteAllText(SettingsPath, json);
53 | }
54 | catch (Exception ex) {
55 | Program.logger.Log($"{ex.Message}");
56 | }
57 | }
58 |
59 | public bool UpdateProxiFyreConfig() {
60 | try {
61 | string ConfigPath = Path.Combine(Path.GetDirectoryName(ProxiFyrePath), "app-config.json");
62 |
63 | ProxiFyreConfig config = new ProxiFyreConfig();
64 | ProxyConfig proxyConfig = new ProxyConfig {
65 | appNames = ProxifiedApps.Count > 0 ? ProxifiedApps : new List { "" },
66 | socks5ProxyEndpoint = $"{ProxiFyreIp}:{ProxiFyrePort}",
67 | supportedProtocols = new List { "TCP", "UDP" }
68 | };
69 |
70 | string byeDpi = Path.GetFileNameWithoutExtension(ByeDpiPath);
71 |
72 | config.proxies.Add(proxyConfig);
73 | config.excludes.Add(byeDpi);
74 | config.Save(ConfigPath);
75 |
76 | return true;
77 | }
78 | catch (Exception ex) {
79 | Program.logger.Log($"ProxiFyre: {ex.Message}");
80 | return false;
81 | }
82 | }
83 |
84 | public static List ShellSplit(string input) {
85 | var tokens = new List();
86 | var quoteChar = ' ';
87 | var quoting = false;
88 | var lastCloseQuoteIndex = int.MinValue;
89 | var current = new System.Text.StringBuilder();
90 |
91 | for (int i = 0; i < input.Length; i++) {
92 | var c = input[i];
93 |
94 | if (quoting && c == quoteChar) {
95 | current.Append('"');
96 | quoting = false;
97 | lastCloseQuoteIndex = i;
98 | }
99 | else if (!quoting && (c == '\'' || c == '"')) {
100 | current.Append('"');
101 | quoting = true;
102 | quoteChar = c;
103 | }
104 | else if (!quoting && char.IsWhiteSpace(c)) {
105 | if (current.Length > 0 || lastCloseQuoteIndex == i - 1) {
106 | tokens.Add(current.ToString());
107 | current.Clear();
108 | }
109 | }
110 | else {
111 | current.Append(c);
112 | }
113 | }
114 |
115 | if (current.Length > 0 || lastCloseQuoteIndex == input.Length - 1) {
116 | tokens.Add(current.ToString());
117 | }
118 |
119 | return tokens;
120 | }
121 |
122 | public static IEnumerable FilterLinuxOnlyArgs(IEnumerable args) {
123 | var linuxOnlyArgs = new HashSet
124 | {
125 | "-D", "--daemon",
126 | "-w", "--pidfile",
127 | "-E", "--transparent",
128 | "-k", "--ip-opt",
129 | "-S", "--md5sig",
130 | "-Y", "--drop-sack",
131 | "-F", "--tfo"
132 | };
133 |
134 | return args.Where(arg => !linuxOnlyArgs.Contains(arg));
135 | }
136 |
137 | public string GetByeDpiArguments() {
138 | try {
139 | if (string.IsNullOrWhiteSpace(ByeDpiArguments)) {
140 | return string.Empty;
141 | }
142 |
143 | var args = ShellSplit(ByeDpiArguments);
144 | var result = FilterLinuxOnlyArgs(args);
145 |
146 | return string.Join(" ", result);
147 | }
148 | catch (Exception ex) {
149 | Program.logger.Log($"ByeDPI: {ex.Message}");
150 | return ByeDpiArguments;
151 | }
152 | }
153 | }
154 | }
155 |
--------------------------------------------------------------------------------
/locale/en.json:
--------------------------------------------------------------------------------
1 | {
2 | "app_name": "ByeDPI Manager",
3 | "main_form.connect": "Connect",
4 | "main_form.disconnect": "Disconnect",
5 | "main_form.settings": "Settings",
6 | "main_form.connected": "Connected",
7 | "main_form.disconnected": "Disconnected",
8 | "main_form.disconnect_first": "Disconnect first to access settings",
9 | "main_form.app_minimized": "Application minimized to tray",
10 | "main_form.app_started": "Application started",
11 | "main_form.quiet_mode": "Starting in quiet mode",
12 | "main_form.auto_connect": "Auto-connecting",
13 | "main_form.settings_saved": "Settings saved",
14 | "settings_form.title": "Settings",
15 | "settings_form.byedpi.tab": "ByeDPI",
16 | "settings_form.byedpi.group": "ByeDPI Settings",
17 | "settings_form.byedpi.path_label": "ByeDPI path:",
18 | "settings_form.byedpi.hotkey_label": "Hotkey:",
19 | "settings_form.byedpi.args_label": "Arguments:",
20 | "settings_form.byedpi.browse_title": "Select ByeDPI executable",
21 | "settings_form.byedpi.not_found": "ByeDPI file not found: {0}",
22 | "settings_form.byedpi.start_error": "Error starting ByeDPI: {0}",
23 | "settings_form.byedpi.stop_error": "Error stopping ByeDPI: {0}",
24 | "settings_form.proxifyre.tab": "ProxiFyre",
25 | "settings_form.proxifyre.group": "ProxiFyre Settings",
26 | "settings_form.proxifyre.disable": "Disable ProxiFyre",
27 | "settings_form.proxifyre.path_label": "ProxiFyre path:",
28 | "settings_form.proxifyre.port_label": "Port:",
29 | "settings_form.proxifyre.browse_title": "Select ProxiFyre executable",
30 | "settings_form.proxifyre.not_found": "ProxiFyre file not found: {0}",
31 | "settings_form.apps.group": "Applications to route through proxy",
32 | "settings_form.apps.name_label": "Application name or path:",
33 | "settings_form.apps.browse_title": "Select application",
34 | "settings_form.apps.add": "Add",
35 | "settings_form.apps.remove": "Remove",
36 | "settings_form.apps.already_added": "This application is already in the list.",
37 | "settings_form.autorun.tab": "Autorun",
38 | "settings_form.autorun.group": "Autorun Settings",
39 | "settings_form.autorun.auto_start": "Start with Windows",
40 | "settings_form.autorun.auto_connect": "Auto-connect on startup",
41 | "settings_form.autorun.start_minimized": "Start minimized to tray",
42 | "settings_form.proxy_test.tab": "Strategy Testing (Beta)",
43 | "settings_form.proxy_test.settings_group": "Test Settings",
44 | "settings_form.proxy_test.delay_label": "Delay between commands in seconds:",
45 | "settings_form.proxy_test.requests_label": "Number of domain requests:",
46 | "settings_form.proxy_test.full_log": "Extended log with host responses",
47 | "settings_form.proxy_test.files_group": "Files",
48 | "settings_form.proxy_test.edit_domains": "Edit domains",
49 | "settings_form.proxy_test.edit_commands": "Edit strategies",
50 | "settings_form.proxy_test.logs_group": "Log (proxytest.log)",
51 | "settings_form.proxy_test.start": "Start",
52 | "settings_form.proxy_test.stop": "Stop",
53 | "settings_form.proxy_test.warning": "Please stop the command testing first.",
54 | "settings_form.proxy_test.cancel_error": "Error canceling operations: {0}",
55 | "settings_form.proxy_test.stop_error": "Error stopping testing: {0}",
56 | "settings_form.about.tab": "About",
57 | "settings_form.about.group": "About Program",
58 | "settings_form.about.version_label": "Version:",
59 | "settings_form.about.developer_label": "Developer:",
60 | "settings_form.about.github_label": "GitHub:",
61 | "settings_form.about.github_link": "https://github.com/romanvht/ByeDPIManager",
62 | "settings_form.buttons.ok": "OK",
63 | "settings_form.buttons.cancel": "Cancel",
64 | "process_manager.byedpi.started": "Start ByeDPI: {0}",
65 | "process_manager.byedpi.start_error": "Error starting ByeDPI: {0}",
66 | "process_manager.byedpi.stopped": "ByeDPI process stopped",
67 | "process_manager.byedpi.stop_error": "Error stopping ByeDPI: {0}",
68 | "process_manager.proxifyre.started": "Start ProxiFyre",
69 | "process_manager.proxifyre.start_error": "Error starting ProxiFyre: {0}",
70 | "process_manager.proxifyre.stopped": "ProxiFyre process stopped",
71 | "process_manager.proxifyre.stop_error": "Error stopping ProxiFyre: {0}",
72 | "process_manager.byedpi.output": "ByeDPI: {0}",
73 | "process_manager.proxifyre.output": "ProxiFyre: {0}",
74 | "process_manager.cleanup.byedpi_stopped": "Stopped running ByeDPI process",
75 | "process_manager.cleanup.byedpi_error": "Error stopping ByeDPI process: {0}",
76 | "process_manager.cleanup.proxifyre_stopped": "Stopped running ProxiFyre process",
77 | "process_manager.cleanup.proxifyre_error": "Error stopping ProxiFyre process: {0}",
78 | "process_manager.cleanup.error": "Error cleaning up processes on startup: {0}",
79 | "proxy_test.sites_file_not_found": "Sites list file not found. Create domains.txt in the proxytest folder and add a list of domains to check.",
80 | "proxy_test.sites_file_read_error": "Error reading sites list file.",
81 | "proxy_test.cmds_file_not_found": "Commands file not found. Create strategies.txt in the proxytest folder and add required ByeDPI commands.",
82 | "proxy_test.cmds_file_read_error": "Error reading commands file.",
83 | "proxy_test.already_running": "Testing is already running.",
84 | "proxy_test.commands_success_over_50": "Strategies with the greatest success, apply from the most to the least",
85 | "proxy_test.no_commands_over_50": "No strategy produced acceptable results.",
86 | "proxy_test.stopped": "Test stopped.",
87 | "proxy_test.error_occurred": "Proxy test stopped. An error occurred: {0}",
88 | "proxy_test.domain_check_error": "Error checking domain: {0}",
89 | "proxy_test.command_test_error": "Error testing command {0}: {1}",
90 | "tray_menu.open": "Open",
91 | "tray_menu.exit": "Exit",
92 | "program.already_running": "Application is already running. Look for it in the tray.",
93 | "program.error": "An error occurred: {0}",
94 | "program.settings_load_error": "Error loading settings: {0}",
95 | "hotkey.wait_input": "Press the hotkey combination...",
96 | "hotkey.error": "Invalid hotkeys: {0}",
97 | "language.ru": "RU",
98 | "language.en": "EN",
99 | "language.tr": "TR"
100 | }
101 |
--------------------------------------------------------------------------------
/locale/ru.json:
--------------------------------------------------------------------------------
1 | {
2 | "app_name": "ByeDPI Manager",
3 | "main_form.connect": "Подключить",
4 | "main_form.disconnect": "Отключить",
5 | "main_form.settings": "Настройки",
6 | "main_form.connected": "Подключено",
7 | "main_form.disconnected": "Отключено",
8 | "main_form.disconnect_first": "Сначала отключитесь, чтобы зайти в настройки",
9 | "main_form.app_minimized": "Приложение свернуто в трей",
10 | "main_form.app_started": "Приложение запущено",
11 | "main_form.quiet_mode": "Запуск в тихом режиме",
12 | "main_form.auto_connect": "Автоматическое подключение",
13 | "main_form.settings_saved": "Настройки сохранены",
14 | "settings_form.title": "Настройки",
15 | "settings_form.byedpi.tab": "ByeDPI",
16 | "settings_form.byedpi.group": "Настройки ByeDPI",
17 | "settings_form.byedpi.path_label": "Путь к ByeDPI:",
18 | "settings_form.byedpi.hotkey_label": "Хоткей:",
19 | "settings_form.byedpi.args_label": "Аргументы:",
20 | "settings_form.byedpi.browse_title": "Выберите исполняемый файл ByeDPI",
21 | "settings_form.byedpi.not_found": "Файл ByeDPI не найден: {0}",
22 | "settings_form.byedpi.start_error": "Ошибка при запуске ByeDPI: {0}",
23 | "settings_form.byedpi.stop_error": "Ошибка при остановке ByeDPI: {0}",
24 | "settings_form.proxifyre.tab": "ProxiFyre",
25 | "settings_form.proxifyre.group": "Настройки ProxiFyre",
26 | "settings_form.proxifyre.disable": "Не запускать ProxiFyre, не перенаправлять трафик",
27 | "settings_form.proxifyre.path_label": "Путь к ProxiFyre:",
28 | "settings_form.proxifyre.port_label": "Порт:",
29 | "settings_form.proxifyre.browse_title": "Выберите исполняемый файл ProxiFyre",
30 | "settings_form.proxifyre.not_found": "Файл ProxiFyre не найден: {0}",
31 | "settings_form.apps.group": "Приложения, которые пойдут через прокси",
32 | "settings_form.apps.name_label": "Имя процесса или путь к приложению:",
33 | "settings_form.apps.browse_title": "Выберите приложение",
34 | "settings_form.apps.add": "Добавить",
35 | "settings_form.apps.remove": "Удалить",
36 | "settings_form.apps.already_added": "Это приложение уже добавлено в список.",
37 | "settings_form.autorun.tab": "Автозапуск",
38 | "settings_form.autorun.group": "Настройки автозапуска",
39 | "settings_form.autorun.auto_start": "Автозапуск при старте устройства",
40 | "settings_form.autorun.auto_connect": "Автоматическое подключение",
41 | "settings_form.autorun.start_minimized": "Запускать свернутым в трей",
42 | "settings_form.proxy_test.tab": "Подбор стратегий (Beta)",
43 | "settings_form.proxy_test.settings_group": "Настройки теста",
44 | "settings_form.proxy_test.delay_label": "Ожидание между командами в секундах:",
45 | "settings_form.proxy_test.requests_label": "Количество запросов к домену:",
46 | "settings_form.proxy_test.full_log": "Расширенный лог с выводом ответа хостов",
47 | "settings_form.proxy_test.files_group": "Файлы",
48 | "settings_form.proxy_test.edit_domains": "Изменить домены",
49 | "settings_form.proxy_test.edit_commands": "Изменить стратегии",
50 | "settings_form.proxy_test.logs_group": "Лог (proxytest.log)",
51 | "settings_form.proxy_test.start": "Старт",
52 | "settings_form.proxy_test.stop": "Стоп",
53 | "settings_form.proxy_test.warning": "Сначала остановите подбор команд.",
54 | "settings_form.proxy_test.cancel_error": "Ошибка при отмене операций: {0}",
55 | "settings_form.proxy_test.stop_error": "Ошибка при остановке тестирования: {0}",
56 | "settings_form.about.tab": "О программе",
57 | "settings_form.about.group": "О программе",
58 | "settings_form.about.version_label": "Версия:",
59 | "settings_form.about.developer_label": "Разработчик:",
60 | "settings_form.about.github_label": "GitHub:",
61 | "settings_form.about.github_link": "https://github.com/romanvht/ByeDPIManager",
62 | "settings_form.buttons.ok": "ОК",
63 | "settings_form.buttons.cancel": "Отмена",
64 | "process_manager.byedpi.started": "Запуск ByeDPI: {0}",
65 | "process_manager.byedpi.start_error": "Ошибка при запуске ByeDPI: {0}",
66 | "process_manager.byedpi.stopped": "ByeDPI остановлен",
67 | "process_manager.byedpi.stop_error": "Ошибка при остановке ByeDPI: {0}",
68 | "process_manager.proxifyre.started": "Запуск ProxiFyre",
69 | "process_manager.proxifyre.start_error": "Ошибка при запуске ProxiFyre: {0}",
70 | "process_manager.proxifyre.stopped": "ProxiFyre остановлен",
71 | "process_manager.proxifyre.stop_error": "Ошибка при остановке ProxiFyre: {0}",
72 | "process_manager.byedpi.output": "ByeDPI: {0}",
73 | "process_manager.proxifyre.output": "ProxiFyre: {0}",
74 | "process_manager.cleanup.byedpi_stopped": "Остановлен запущенный процесс ByeDPI",
75 | "process_manager.cleanup.byedpi_error": "Ошибка при остановке процесса ByeDPI: {0}",
76 | "process_manager.cleanup.proxifyre_stopped": "Остановлен запущенный процесс ProxiFyre",
77 | "process_manager.cleanup.proxifyre_error": "Ошибка при остановке процесса ProxiFyre: {0}",
78 | "process_manager.cleanup.error": "Ошибка при очистке процессов при запуске: {0}",
79 | "proxy_test.sites_file_not_found": "Файл со списком сайтов не найден. Создайте файл domains.txt в папке proxytest и добавьте в него список доменов для проверки.",
80 | "proxy_test.sites_file_read_error": "Ошибка при чтении файла со списком сайтов.",
81 | "proxy_test.cmds_file_not_found": "Файл со стратегиями не найден. Создайте файл strategies.txt в папке proxytest и добавьте в него нужные стратегии для ByeDPI.",
82 | "proxy_test.cmds_file_read_error": "Ошибка при чтении файла со стратегиями.",
83 | "proxy_test.already_running": "Тестирование уже запущено.",
84 | "proxy_test.commands_success_over_50": "Стратегии с наибольшим успехом, применяйте от большего к меньшему",
85 | "proxy_test.no_commands_over_50": "Ни одна стратегия не дала приемлемый результат",
86 | "proxy_test.stopped": "Тест остановлен.",
87 | "proxy_test.error_occurred": "Тест прокси остановлен. Произошла ошибка: {0}",
88 | "proxy_test.domain_check_error": "Ошибка при проверке домена: {0}",
89 | "proxy_test.command_test_error": "Ошибка при тестировании команды {0}: {1}",
90 | "tray_menu.open": "Открыть",
91 | "tray_menu.exit": "Выход",
92 | "program.already_running": "Приложение уже запущено. Ищите его в трее.",
93 | "program.error": "Произошла ошибка: {0}",
94 | "program.settings_load_error": "Ошибка при загрузке настроек: {0}",
95 | "hotkey.wait_input": "Нажмите комбинацию клавиш...",
96 | "hotkey.error": "Неверных хоткей: {0}",
97 | "language.ru": "RU",
98 | "language.en": "EN",
99 | "language.tr": "TR"
100 | }
101 |
--------------------------------------------------------------------------------
/locale/tr.json:
--------------------------------------------------------------------------------
1 | {
2 | "app_name": "ByeDPI Manager",
3 | "main_form.connect": "Bağlan",
4 | "main_form.disconnect": "Bağlantıyı Kes",
5 | "main_form.settings": "Ayarlar",
6 | "main_form.connected": "Bağlı",
7 | "main_form.disconnected": "Bağlı Değil",
8 | "main_form.disconnect_first": "Ayarlara ulaşmak için ilk önce bağlantıyı kes",
9 | "main_form.app_minimized": "Uygulama sistem tepsisinde",
10 | "main_form.app_started": "Uygulama çalışıyor",
11 | "main_form.quiet_mode": "Sessiz olarak başlatılıyor",
12 | "main_form.auto_connect": "Otomatik bağlanıyor",
13 | "main_form.settings_saved": "Ayarlar kaydedildi",
14 | "settings_form.title": "Ayarlar",
15 | "settings_form.byedpi.tab": "ByeDPI",
16 | "settings_form.byedpi.group": "ByeDPI Ayarları",
17 | "settings_form.byedpi.path_label": "ByeDPI yolu:",
18 | "settings_form.byedpi.hotkey_label": "Kısayol:",
19 | "settings_form.byedpi.args_label": "Parametreler:",
20 | "settings_form.byedpi.browse_title": "ByeDPI çalıştırılabilirini seçin",
21 | "settings_form.byedpi.not_found": "ByeDPI dosyası bulunamadı: {0}",
22 | "settings_form.byedpi.start_error": "ByeDPI başlatılırken hata: {0}",
23 | "settings_form.byedpi.stop_error": "ByeDPI durdurulurken hata: {0}",
24 | "settings_form.proxifyre.tab": "ProxiFyre",
25 | "settings_form.proxifyre.group": "ProxiFyre Ayarları",
26 | "settings_form.proxifyre.disable": "ProxiFyre'ı devre dışı bırak",
27 | "settings_form.proxifyre.path_label": "ProxiFyre yolu:",
28 | "settings_form.proxifyre.port_label": "Port:",
29 | "settings_form.proxifyre.browse_title": "ProxiFyre çalıştırılabilirini seçin",
30 | "settings_form.proxifyre.not_found": "ProxiFyre dosyası bulunamadı: {0}",
31 | "settings_form.apps.group": "Proxy üzerinden geçecek uygulamalar",
32 | "settings_form.apps.name_label": "Uygulama ismi veya yolu:",
33 | "settings_form.apps.browse_title": "Uygulama seç",
34 | "settings_form.apps.add": "Ekle",
35 | "settings_form.apps.remove": "Kaldır",
36 | "settings_form.apps.already_added": "Bu uygulama listede mevcut.",
37 | "settings_form.autorun.tab": "Otomatik Başlatma",
38 | "settings_form.autorun.group": "Otomatik Başlatma Ayarları",
39 | "settings_form.autorun.auto_start": "Başlangıçta Çalıştır",
40 | "settings_form.autorun.auto_connect": "Başlangıçta Bağlan",
41 | "settings_form.autorun.start_minimized": "Sistem Tepsisinde Başlat",
42 | "settings_form.proxy_test.tab": "Denemeler (Beta)",
43 | "settings_form.proxy_test.settings_group": "Test Ayarları",
44 | "settings_form.proxy_test.delay_label": "Komutlar arasındaki saniye cinsinden gecikme:",
45 | "settings_form.proxy_test.requests_label": "Etki alanı isteklerinin sayısı:",
46 | "settings_form.proxy_test.full_log": "Sunucu cevabını içeren kapsamlı günlük kaydı",
47 | "settings_form.proxy_test.files_group": "Dosyalar",
48 | "settings_form.proxy_test.edit_domains": "Alan adlarını düzenle",
49 | "settings_form.proxy_test.edit_commands": "Denemeleri düzenle",
50 | "settings_form.proxy_test.logs_group": "Günlük Kaydı (proxytest.log)",
51 | "settings_form.proxy_test.start": "Başlat",
52 | "settings_form.proxy_test.stop": "Durdur",
53 | "settings_form.proxy_test.warning": "Lütfen ilk önce komut testini durdurun.",
54 | "settings_form.proxy_test.cancel_error": "Test işlemlerini iptal ederken hata: {0}",
55 | "settings_form.proxy_test.stop_error": "Testi iptal ederken hata: {0}",
56 | "settings_form.about.tab": "Hakkıda",
57 | "settings_form.about.group": "Program Hakkında",
58 | "settings_form.about.version_label": "Versiyon:",
59 | "settings_form.about.developer_label": "Geliştirici:",
60 | "settings_form.about.github_label": "GitHub:",
61 | "settings_form.about.github_link": "https://github.com/romanvht/ByeDPIManager",
62 | "settings_form.buttons.ok": "Tamam",
63 | "settings_form.buttons.cancel": "İptal",
64 | "process_manager.byedpi.started": "ByeDPI'ı Başlat: {0}",
65 | "process_manager.byedpi.start_error": "ByeDPI başlatırken hata: {0}",
66 | "process_manager.byedpi.stopped": "ByeDPI işlemi durduruldu",
67 | "process_manager.byedpi.stop_error": "ByeDPI durdurulurken hata: {0}",
68 | "process_manager.proxifyre.started": "ProxiFyre'ı başlat",
69 | "process_manager.proxifyre.start_error": "ProxiFyre başlatılırken hata: {0}",
70 | "process_manager.proxifyre.stopped": "ProxiFyre işlemi durduruldu",
71 | "process_manager.proxifyre.stop_error": "ProxiFyre durdurulurken hata: {0}",
72 | "process_manager.byedpi.output": "ByeDPI: {0}",
73 | "process_manager.proxifyre.output": "ProxiFyre: {0}",
74 | "process_manager.cleanup.byedpi_stopped": "Çalışan ByeDPI işlemi durduruldu",
75 | "process_manager.cleanup.byedpi_error": "ByeDPI işlemi durdurulurken hata: {0}",
76 | "process_manager.cleanup.proxifyre_stopped": "Çalışan ProxiFyre işlemi durduruldu",
77 | "process_manager.cleanup.proxifyre_error": "ProxiFyre işlemi durdurulurken hata oluştu: {0}",
78 | "process_manager.cleanup.error": "Başlangıç işlemleri temizlenirken hata oluştu: {0}",
79 | "proxy_test.sites_file_not_found": "Site listesinin bulunduğu dosya bulunamadı. Proxytest klasöründe domains.txt adlı bir dosya oluşturun ve kontrol edilecek alan adlarını bu listeye ekleyin.",
80 | "proxy_test.sites_file_read_error": "Site listesi dosyası okunurken hata oluştu.",
81 | "proxy_test.cmds_file_not_found": "Komut dosyası bulunamadı. Proxytest klasöründe strategies.txt dosyasını oluşturun ve gerekli ByeDPI komutlarını ekleyin.",
82 | "proxy_test.cmds_file_read_error": "Komut dosyası okunurken hata oluştu.",
83 | "proxy_test.already_running": "Testler hala devam ediyor.",
84 | "proxy_test.commands_success_over_50": "En başarılı denemeler, en çoktan en aza doğru uygulanır",
85 | "proxy_test.no_commands_over_50": "Hiçbir deneme kabul edilebilir sonuç vermedi.",
86 | "proxy_test.stopped": "Test durdu.",
87 | "proxy_test.error_occurred": "Proxy testi durduruldu. Bir hata meydana geldi: {0}",
88 | "proxy_test.domain_check_error": "Alan adı kontrol edilirken hata: {0}",
89 | "proxy_test.command_test_error": "Komut test edilirken hata {0}: {1}",
90 | "tray_menu.open": "Aç",
91 | "tray_menu.exit": "Çık",
92 | "program.already_running": "Uygulama zaten çalışıyor. Sistem tepsisine göz atın.",
93 | "program.error": "Bir hata meydana geldi: {0}",
94 | "program.settings_load_error": "Ayarlar yüklenirken hata oluştu: {0}",
95 | "hotkey.wait_input": "Kısayol tuşu kombinasyonuna basın...",
96 | "hotkey.error": "Geçersiz kısayol tuşları: {0}",
97 | "language.ru": "RU",
98 | "language.en": "EN",
99 | "language.tr": "TR"
100 | }
101 |
--------------------------------------------------------------------------------
/src/ProcessManager.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Diagnostics;
3 | using System.IO;
4 |
5 | namespace bdmanager {
6 | public class ProcessManager {
7 | private Process _byeDpiProcess;
8 | private Process _proxifyreProcess;
9 | private AppSettings _settings;
10 |
11 | public bool IsRunning => _byeDpiProcess?.HasExited == false && (_settings.DisableProxiFyre || _proxifyreProcess?.HasExited == false);
12 | public event EventHandler StatusChanged;
13 |
14 | public ProcessManager() {
15 | _settings = Program.settings;
16 | }
17 |
18 | public void StartByeDpi(string arguments = null) {
19 | try {
20 | if (!File.Exists(_settings.ByeDpiPath)) {
21 | Program.logger.Log(string.Format(
22 | Program.localization.GetString("settings_form.byedpi.not_found"),
23 | _settings.ByeDpiPath
24 | ));
25 | return;
26 | }
27 |
28 | bool useCustomArgs = !string.IsNullOrWhiteSpace(arguments);
29 | string args = useCustomArgs ? arguments : _settings.GetByeDpiArguments();
30 |
31 | _byeDpiProcess = new Process {
32 | StartInfo = new ProcessStartInfo {
33 | FileName = _settings.ByeDpiPath,
34 | WorkingDirectory = Path.GetDirectoryName(_settings.ByeDpiPath),
35 | Arguments = args,
36 | UseShellExecute = false,
37 | CreateNoWindow = true,
38 | RedirectStandardOutput = true,
39 | RedirectStandardError = true
40 | },
41 | EnableRaisingEvents = true
42 | };
43 |
44 | if (!useCustomArgs) {
45 | _byeDpiProcess.OutputDataReceived += ByeDpiOutputHandler;
46 | _byeDpiProcess.ErrorDataReceived += ByeDpiOutputHandler;
47 | _byeDpiProcess.Exited += ProcessStopHandler;
48 | }
49 |
50 | _byeDpiProcess.Start();
51 | _byeDpiProcess.BeginOutputReadLine();
52 | _byeDpiProcess.BeginErrorReadLine();
53 |
54 | Program.logger.Log(string.Format(
55 | Program.localization.GetString("process_manager.byedpi.started"),
56 | args
57 | ));
58 | }
59 | catch (Exception ex) {
60 | Program.logger.Log(string.Format(
61 | Program.localization.GetString("process_manager.byedpi.start_error"),
62 | ex.Message
63 | ));
64 | StopByeDpi();
65 | throw;
66 | }
67 | }
68 |
69 | public void StartProxiFyre() {
70 | if (_settings.DisableProxiFyre) {
71 | return;
72 | }
73 |
74 | try {
75 | if (!File.Exists(_settings.ProxiFyrePath)) {
76 | Program.logger.Log(string.Format(
77 | Program.localization.GetString("settings_form.proxifyre.not_found"),
78 | _settings.ProxiFyrePath
79 | ));
80 | return;
81 | }
82 |
83 | if (!_settings.UpdateProxiFyreConfig()) {
84 | return;
85 | }
86 |
87 | _proxifyreProcess = new Process {
88 | StartInfo = new ProcessStartInfo {
89 | FileName = _settings.ProxiFyrePath,
90 | WorkingDirectory = Path.GetDirectoryName(_settings.ProxiFyrePath),
91 | UseShellExecute = false,
92 | CreateNoWindow = true,
93 | RedirectStandardOutput = true,
94 | RedirectStandardError = true
95 | },
96 | EnableRaisingEvents = true
97 | };
98 |
99 | _proxifyreProcess.OutputDataReceived += ProxifyreOutputHandler;
100 | _proxifyreProcess.ErrorDataReceived += ProxifyreOutputHandler;
101 | _proxifyreProcess.Exited += ProcessStopHandler;
102 |
103 | _proxifyreProcess.Start();
104 | _proxifyreProcess.BeginOutputReadLine();
105 | _proxifyreProcess.BeginErrorReadLine();
106 |
107 | Program.logger.Log(Program.localization.GetString("process_manager.proxifyre.started"));
108 | }
109 | catch (Exception ex) {
110 | Program.logger.Log(string.Format(
111 | Program.localization.GetString("process_manager.proxifyre.start_error"),
112 | ex.Message
113 | ));
114 | StopProxiFyre();
115 | throw;
116 | }
117 | }
118 |
119 | public void StopByeDpi() {
120 | if (_byeDpiProcess?.HasExited == false) {
121 | try {
122 | _byeDpiProcess.Kill();
123 | _byeDpiProcess = null;
124 | Program.logger.Log(Program.localization.GetString("process_manager.byedpi.stopped"));
125 | }
126 | catch (Exception ex) {
127 | Program.logger.Log(string.Format(
128 | Program.localization.GetString("process_manager.byedpi.stop_error"),
129 | ex.Message
130 | ));
131 | }
132 | }
133 | }
134 |
135 | public void StopProxiFyre() {
136 | if (_settings.DisableProxiFyre) {
137 | return;
138 | }
139 |
140 | if (_proxifyreProcess?.HasExited == false) {
141 | try {
142 | _proxifyreProcess.Kill();
143 | _proxifyreProcess = null;
144 | Program.logger.Log(Program.localization.GetString("process_manager.proxifyre.stopped"));
145 | }
146 | catch (Exception ex) {
147 | Program.logger.Log(string.Format(
148 | Program.localization.GetString("process_manager.proxifyre.stop_error"),
149 | ex.Message
150 | ));
151 | }
152 | }
153 | }
154 |
155 | public void Start() {
156 | try {
157 | StartByeDpi();
158 |
159 | if (_byeDpiProcess?.HasExited != false) {
160 | return;
161 | }
162 |
163 | StartProxiFyre();
164 |
165 | if (IsRunning) {
166 | RaiseStatusChanged(true);
167 | }
168 | else {
169 | Stop();
170 | }
171 | }
172 | catch (Exception ex) {
173 | Program.logger.Log(string.Format(
174 | Program.localization.GetString("settings_form.byedpi.start_error"),
175 | ex.Message
176 | ));
177 | Stop();
178 | }
179 | }
180 |
181 | public void Stop() {
182 | try {
183 | StopByeDpi();
184 | StopProxiFyre();
185 | RaiseStatusChanged(false);
186 | }
187 | catch (Exception ex) {
188 | Program.logger.Log($"{ex.Message}");
189 | }
190 | }
191 |
192 | private void ByeDpiOutputHandler(object sender, DataReceivedEventArgs e) {
193 | if (!string.IsNullOrEmpty(e.Data)) {
194 | Program.logger.Log(string.Format(
195 | Program.localization.GetString("process_manager.byedpi.output"),
196 | e.Data
197 | ));
198 | }
199 | }
200 |
201 | private void ProxifyreOutputHandler(object sender, DataReceivedEventArgs e) {
202 | if (!string.IsNullOrEmpty(e.Data)) {
203 | Program.logger.Log(string.Format(
204 | Program.localization.GetString("process_manager.proxifyre.output"),
205 | e.Data
206 | ));
207 | }
208 | }
209 |
210 | public void CleanupOnStartup() {
211 | try {
212 | bool processesFound = false;
213 |
214 | var byeDpiProcesses = Process.GetProcessesByName("ciadpi");
215 | if (byeDpiProcesses.Length > 0) {
216 | processesFound = true;
217 | foreach (var process in byeDpiProcesses) {
218 | try {
219 | process.Kill();
220 | Program.logger.Log(Program.localization.GetString("process_manager.cleanup.byedpi_stopped"));
221 | }
222 | catch (Exception ex) {
223 | Program.logger.Log(string.Format(
224 | Program.localization.GetString("process_manager.cleanup.byedpi_error"),
225 | ex.Message
226 | ));
227 | }
228 | }
229 | }
230 |
231 | var proxiFyreProcesses = Process.GetProcessesByName("ProxiFyre");
232 | if (proxiFyreProcesses.Length > 0) {
233 | processesFound = true;
234 | foreach (var process in proxiFyreProcesses) {
235 | try {
236 | process.Kill();
237 | Program.logger.Log(Program.localization.GetString("process_manager.cleanup.proxifyre_stopped"));
238 | }
239 | catch (Exception ex) {
240 | Program.logger.Log(string.Format(
241 | Program.localization.GetString("process_manager.cleanup.proxifyre_error"),
242 | ex.Message
243 | ));
244 | }
245 | }
246 | }
247 |
248 | if (processesFound) {
249 | RaiseStatusChanged(false);
250 | }
251 | }
252 | catch (Exception ex) {
253 | Program.logger.Log(string.Format(
254 | Program.localization.GetString("process_manager.cleanup.error"),
255 | ex.Message
256 | ));
257 | }
258 | }
259 | private void ProcessStopHandler(object sender, EventArgs e) {
260 | Stop();
261 | }
262 |
263 | private void RaiseStatusChanged(bool status) {
264 | StatusChanged?.Invoke(this, status);
265 | }
266 | }
267 | }
268 |
--------------------------------------------------------------------------------
/src/MainForm.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Drawing;
3 | using System.Windows.Forms;
4 | using System.Reflection;
5 | using System.IO;
6 | using System.Linq;
7 |
8 | namespace bdmanager {
9 | public partial class MainForm : Form {
10 | private bool _trayShow = false;
11 |
12 | private AppSettings _settings;
13 | private SettingsForm _settingsForm;
14 | private ProcessManager _processManager;
15 | private Logger _logger;
16 | private HotkeyManager _hotkeyManager;
17 |
18 | private RoundButton _toggleButton;
19 | private RoundButton _settingsButton;
20 | private TextBox _logBox;
21 | private NotifyIcon _notifyIcon;
22 | private MenuItem _toggleMenuItem;
23 | private Panel _languagePanel;
24 |
25 | public MainForm() {
26 | InitializeApplication();
27 | InitializeComponent();
28 | InitializeLanguage();
29 | InitializeTray();
30 |
31 | DpiScaler.Scale(this);
32 | }
33 |
34 | private void InitializeApplication() {
35 | _settings = Program.settings;
36 | _settingsForm = new SettingsForm();
37 |
38 | _logger = Program.logger;
39 | _logger.LogAdded += (s, message) => AddLogToUi(message);
40 |
41 | _processManager = Program.processManager;
42 | _processManager.StatusChanged += (s, isRunning) => UpdateStatus(isRunning);
43 |
44 | Program.localization.LanguageChanged += (s, e) => UpdateLocale();
45 | }
46 |
47 | private void InitializeComponent() {
48 | SuspendLayout();
49 |
50 | Text = Program.localization.GetString("app_name");
51 | Size = new Size(480, 400);
52 | StartPosition = FormStartPosition.CenterScreen;
53 | FormBorderStyle = FormBorderStyle.FixedSingle;
54 | MaximizeBox = false;
55 | FormClosing += MainForm_FormClosing;
56 | Load += MainForm_Load;
57 | Icon = GetIconFromResources();
58 |
59 | BackColor = Color.FromArgb(30, 30, 30);
60 | ForeColor = Color.White;
61 |
62 | TableLayoutPanel mainLayout = new TableLayoutPanel {
63 | Dock = DockStyle.Fill,
64 | ColumnCount = 1,
65 | RowCount = 4,
66 | ColumnStyles = {
67 | new ColumnStyle(SizeType.Percent, 100F)
68 | },
69 | RowStyles = {
70 | new RowStyle(SizeType.Percent, 30F),
71 | new RowStyle(SizeType.Percent, 15F),
72 | new RowStyle(SizeType.Percent, 50F),
73 | new RowStyle(SizeType.Percent, 5F)
74 | },
75 | Padding = new Padding(10)
76 | };
77 | Controls.Add(mainLayout);
78 |
79 | _toggleButton = new RoundButton {
80 | Text = Program.localization.GetString("main_form.connect"),
81 | Size = new Size(160, 80),
82 | BackColor = Color.FromArgb(45, 45, 45),
83 | ForeColor = Color.White,
84 | Font = new Font("Segoe UI", 11, FontStyle.Bold),
85 | BorderRadius = 30,
86 | BorderSize = 1,
87 | BorderColor = Color.FromArgb(100, 100, 100),
88 | Anchor = AnchorStyles.None
89 | };
90 | _toggleButton.Click += ToggleButton_Click;
91 | mainLayout.Controls.Add(_toggleButton, 0, 0);
92 |
93 | _settingsButton = new RoundButton {
94 | Text = Program.localization.GetString("main_form.settings"),
95 | Size = new Size(120, 40),
96 | BackColor = Color.FromArgb(60, 60, 60),
97 | ForeColor = Color.White,
98 | Font = new Font("Segoe UI", 9),
99 | BorderRadius = 20,
100 | BorderSize = 1,
101 | BorderColor = Color.FromArgb(100, 100, 100),
102 | Margin = new Padding(0, 0, 0, 5),
103 | Anchor = AnchorStyles.None
104 | };
105 | _settingsButton.Click += SettingsButton_Click;
106 | mainLayout.Controls.Add(_settingsButton, 0, 1);
107 |
108 | Panel logPanel = new Panel {
109 | Dock = DockStyle.Fill,
110 | BackColor = Color.FromArgb(20, 20, 20),
111 | BorderStyle = BorderStyle.FixedSingle,
112 | Margin = new Padding(0, 5, 0, 5)
113 | };
114 | mainLayout.Controls.Add(logPanel, 0, 2);
115 |
116 | _logBox = new TextBox {
117 | Dock = DockStyle.Fill,
118 | Multiline = true,
119 | ReadOnly = true,
120 | ScrollBars = ScrollBars.Vertical,
121 | Font = new Font("Consolas", 9),
122 | BackColor = Color.FromArgb(25, 25, 25),
123 | ForeColor = Color.LimeGreen,
124 | BorderStyle = BorderStyle.None,
125 | Margin = new Padding(5)
126 | };
127 | logPanel.Controls.Add(_logBox);
128 |
129 | _languagePanel = new TableLayoutPanel {
130 | Dock = DockStyle.Fill,
131 | BackColor = Color.FromArgb(30, 30, 30),
132 | ColumnCount = 1,
133 | RowCount = 1,
134 | Padding = new Padding(0),
135 | Margin = new Padding(0),
136 | ColumnStyles = { new ColumnStyle(SizeType.Percent, 100F) },
137 | RowStyles = { new RowStyle(SizeType.Percent, 100F) }
138 | };
139 | mainLayout.Controls.Add(_languagePanel, 0, 3);
140 |
141 | _notifyIcon = new NotifyIcon {
142 | Icon = GetIconFromResources(),
143 | Visible = true
144 | };
145 |
146 | ResumeLayout(false);
147 | }
148 |
149 | private void InitializeLanguage() {
150 | FlowLayoutPanel flowPanel = new FlowLayoutPanel {
151 | AutoSize = true,
152 | Anchor = AnchorStyles.None
153 | };
154 |
155 | foreach (string langCode in Localization.AvailableLanguages) {
156 | LinkLabel langLink = new LinkLabel {
157 | Text = Program.localization.GetLanguageName(langCode),
158 | LinkColor = Color.White,
159 | LinkBehavior = LinkBehavior.NeverUnderline,
160 | VisitedLinkColor = Color.White,
161 | ActiveLinkColor = Color.LightGray,
162 | AutoSize = true,
163 | Font = new Font("Segoe UI", 8),
164 | Tag = langCode,
165 | Margin = new Padding(0, 0, 2, 0)
166 | };
167 |
168 | langLink.Click += (s, e) => {
169 | if (Program.localization.CurrentLanguage != langCode) {
170 | Program.localization.ChangeLanguage(langCode);
171 | _settings.Language = langCode;
172 | _settings.Save();
173 | }
174 | };
175 |
176 | langLink.LinkColor = Program.localization.CurrentLanguage == langCode ?
177 | Color.LimeGreen :
178 | Color.White;
179 |
180 | flowPanel.Controls.Add(langLink);
181 |
182 | if (langCode != Localization.AvailableLanguages.Last()) {
183 | Label separator = new Label {
184 | Text = "|",
185 | ForeColor = Color.White,
186 | AutoSize = true,
187 | Font = new Font("Segoe UI", 8),
188 | Margin = new Padding(0, 0, 2, 0)
189 | };
190 | flowPanel.Controls.Add(separator);
191 | }
192 | }
193 |
194 | _languagePanel.Controls.Add(flowPanel);
195 | }
196 |
197 | private void UpdateLocale() {
198 | if (InvokeRequired) {
199 | Invoke(new Action(UpdateLocale));
200 | return;
201 | }
202 |
203 | Text = Program.localization.GetString("app_name");
204 |
205 | _toggleButton.Text = _processManager.IsRunning ?
206 | Program.localization.GetString("main_form.disconnect") :
207 | Program.localization.GetString("main_form.connect");
208 |
209 | _settingsButton.Text = Program.localization.GetString("main_form.settings");
210 |
211 | _notifyIcon.Text = Program.localization.GetString("app_name");
212 |
213 | _toggleMenuItem.Text = _processManager.IsRunning ?
214 | Program.localization.GetString("main_form.disconnect") :
215 | Program.localization.GetString("main_form.connect");
216 |
217 | if (_notifyIcon.ContextMenu != null) {
218 | _notifyIcon.ContextMenu.MenuItems[0].Text = Program.localization.GetString("tray_menu.open");
219 | _notifyIcon.ContextMenu.MenuItems[2].Text = Program.localization.GetString("tray_menu.exit");
220 | }
221 |
222 | foreach (Control control in _languagePanel.Controls) {
223 | if (control is FlowLayoutPanel flowPanel) {
224 | foreach (Control langControl in flowPanel.Controls) {
225 | if (langControl is LinkLabel link) {
226 | string langCode = (string)link.Tag;
227 | link.LinkColor = Program.localization.CurrentLanguage == langCode ? Color.LimeGreen : Color.White;
228 | }
229 | }
230 | }
231 | }
232 | }
233 |
234 | private void InitializeTray() {
235 | ContextMenu trayMenu = new ContextMenu();
236 |
237 | MenuItem openMenuItem = new MenuItem(Program.localization.GetString("tray_menu.open"));
238 | openMenuItem.Click += (s, e) => {
239 | Show();
240 | WindowState = FormWindowState.Normal;
241 | };
242 |
243 | _toggleMenuItem = new MenuItem(Program.localization.GetString("main_form.connect"));
244 | _toggleMenuItem.Click += (s, e) => {
245 | ToggleConnection();
246 | };
247 |
248 | MenuItem exitMenuItem = new MenuItem(Program.localization.GetString("tray_menu.exit"));
249 | exitMenuItem.Click += (s, e) => {
250 | _notifyIcon.Visible = false;
251 | Application.Exit();
252 | };
253 |
254 | trayMenu.MenuItems.Add(openMenuItem);
255 | trayMenu.MenuItems.Add(_toggleMenuItem);
256 | trayMenu.MenuItems.Add(exitMenuItem);
257 |
258 | _notifyIcon.ContextMenu = trayMenu;
259 | _notifyIcon.DoubleClick += (s, e) => {
260 | Show();
261 | Activate();
262 | WindowState = FormWindowState.Normal;
263 | };
264 | }
265 |
266 | private void MainForm_Load(object sender, EventArgs e) {
267 | _logger.Log(Program.localization.GetString("main_form.app_started"));
268 | _processManager.CleanupOnStartup();
269 |
270 | if (_settings.Hotkey != null && _settings.Hotkey != "") {
271 | _hotkeyManager = new HotkeyManager(Handle, ToggleConnection);
272 | _hotkeyManager.RegisterHotkey(_settings.Hotkey);
273 | }
274 |
275 | if (_settings.AutoStart && Program.isAutorun) {
276 | if (_settings.StartMinimized) {
277 | _logger.Log(Program.localization.GetString("main_form.quiet_mode"));
278 | WindowState = FormWindowState.Minimized;
279 | _trayShow = true;
280 | BeginInvoke(new Action(() => {
281 | Hide();
282 | }));
283 | }
284 |
285 | if (_settings.AutoConnect) {
286 | _logger.Log(Program.localization.GetString("main_form.auto_connect"));
287 | ToggleConnection();
288 | }
289 | }
290 |
291 | UpdateStatus(_processManager.IsRunning);
292 | }
293 |
294 | private void MainForm_FormClosing(object sender, FormClosingEventArgs e) {
295 | if (e.CloseReason == CloseReason.UserClosing) {
296 | e.Cancel = true;
297 | WindowState = FormWindowState.Minimized;
298 | Hide();
299 |
300 | if (!_trayShow) {
301 | _notifyIcon.ShowBalloonTip(3000, Program.localization.GetString("app_name"),
302 | Program.localization.GetString("main_form.app_minimized"), ToolTipIcon.Info);
303 | _trayShow = true;
304 | }
305 | }
306 | else {
307 | Application.Exit();
308 | }
309 | }
310 |
311 | private void ToggleButton_Click(object sender, EventArgs e) {
312 | ToggleConnection();
313 | }
314 |
315 | private void SettingsButton_Click(object sender, EventArgs e) {
316 | if (_processManager.IsRunning) {
317 | MessageBox.Show(
318 | Program.localization.GetString("main_form.disconnect_first"),
319 | Program.localization.GetString("app_name"),
320 | MessageBoxButtons.OK,
321 | MessageBoxIcon.Warning
322 | );
323 | return;
324 | }
325 |
326 | OpenSettings();
327 | }
328 |
329 | private void ToggleConnection() {
330 | _toggleButton.Enabled = false;
331 |
332 | if (_processManager.IsRunning) {
333 | _processManager.Stop();
334 | }
335 | else {
336 | _processManager.Start();
337 | }
338 |
339 | _toggleButton.Enabled = true;
340 | }
341 |
342 | private void OpenSettings() {
343 | _settingsForm = new SettingsForm();
344 |
345 | if (_settingsForm.ShowDialog() == DialogResult.OK) {
346 | _settings.Save();
347 | _logger.Log(Program.localization.GetString("main_form.settings_saved"));
348 |
349 | if (_settings.Hotkey != null && _settings.Hotkey != "") {
350 | _hotkeyManager.RegisterHotkey(_settings.Hotkey);
351 | }
352 | }
353 | }
354 |
355 | private void AddLogToUi(string message) {
356 | if (_logBox.IsDisposed) return;
357 |
358 | if (_logBox.InvokeRequired) {
359 | _logBox.Invoke(new Action(() => AddLogToUi(message)));
360 | return;
361 | }
362 |
363 | string timestamp = DateTime.Now.ToString("HH:mm:ss");
364 | string logLine = $"[{timestamp}] {message}\r\n";
365 |
366 | if (_logBox.Lines.Length > 500) {
367 | _logBox.Text = string.Join("\r\n", _logBox.Lines.Skip(_logBox.Lines.Length - 500));
368 | }
369 |
370 | _logBox.AppendText(logLine);
371 | _logBox.ScrollToCaret();
372 | }
373 |
374 | private void UpdateStatus(bool isRunning) {
375 | if (InvokeRequired) {
376 | Invoke(new Action(() => UpdateStatus(isRunning)));
377 | return;
378 | }
379 |
380 | _toggleButton.Text = isRunning ?
381 | Program.localization.GetString("main_form.disconnect") :
382 | Program.localization.GetString("main_form.connect");
383 |
384 | _toggleMenuItem.Text = isRunning ?
385 | Program.localization.GetString("main_form.disconnect") :
386 | Program.localization.GetString("main_form.connect");
387 |
388 | _notifyIcon.Text = isRunning ?
389 | Program.localization.GetString("main_form.connected") :
390 | Program.localization.GetString("main_form.disconnected");
391 |
392 | _notifyIcon.Icon = isRunning ? GetIconFromResources(true) : GetIconFromResources();
393 |
394 | if (isRunning) {
395 | _toggleButton.BackColor = Color.FromArgb(200, 50, 50);
396 | _toggleButton.HoverColor = Color.FromArgb(220, 60, 60);
397 | _toggleButton.PressedColor = Color.FromArgb(180, 40, 40);
398 | _toggleButton.BorderColor = Color.FromArgb(240, 70, 70);
399 | }
400 | else {
401 | _toggleButton.BackColor = Color.FromArgb(40, 120, 50);
402 | _toggleButton.HoverColor = Color.FromArgb(50, 140, 60);
403 | _toggleButton.PressedColor = Color.FromArgb(30, 100, 40);
404 | _toggleButton.BorderColor = Color.FromArgb(60, 160, 70);
405 | }
406 | }
407 |
408 | protected override void WndProc(ref Message m) {
409 | _hotkeyManager?.ProcessMessage(m);
410 | base.WndProc(ref m);
411 | }
412 |
413 | private Icon GetIconFromResources(bool isConnected = false) {
414 | Assembly assembly = Assembly.GetExecutingAssembly();
415 |
416 | string resourceName = isConnected ?
417 | "bdmanager.tray-on.ico" :
418 | "bdmanager.tray-off.ico";
419 |
420 | using (Stream stream = assembly.GetManifestResourceStream(resourceName)) {
421 | if (stream != null) {
422 | return new Icon(stream);
423 | }
424 | }
425 | return SystemIcons.Application;
426 | }
427 | }
428 | }
429 |
--------------------------------------------------------------------------------
/src/ProxyTestManager.cs:
--------------------------------------------------------------------------------
1 | using SocksSharp;
2 | using SocksSharp.Proxy;
3 | using System;
4 | using System.Collections.Generic;
5 | using System.IO;
6 | using System.Linq;
7 | using System.Net.Http;
8 | using System.Threading;
9 | using System.Threading.Tasks;
10 | using System.Windows.Forms;
11 |
12 | namespace bdmanager {
13 | public class ProxyTestManager {
14 | public static readonly string PROXY_TEST_FOLDER = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "proxytest");
15 | public static readonly string PROXY_TEST_CMDS = Path.Combine(PROXY_TEST_FOLDER, "strategies.txt");
16 | public static readonly string PROXY_TEST_SITES = Path.Combine(PROXY_TEST_FOLDER, "domains.txt");
17 | public static readonly string PROXY_TEST_LATEST_LOG = Path.Combine(PROXY_TEST_FOLDER, "proxytest.log");
18 |
19 | private readonly object _logLock = new object();
20 | public bool IsTesting { get; private set; }
21 |
22 | public Button ProxyTestStartButton { get; set; }
23 | public TextBox ProxyTestLogsBox { get; set; }
24 | public Label ProxyTestProgressLabel { get; set; }
25 |
26 | private AppSettings _settings;
27 | private ProcessManager _processManager;
28 | private CancellationTokenSource _cancellationTokenSource;
29 |
30 | public event EventHandler LogAdded;
31 |
32 | public ProxyTestManager() {
33 | _settings = Program.settings;
34 | _processManager = Program.processManager;
35 | }
36 |
37 | public static string GetLatestLogs() {
38 | try {
39 | if (!File.Exists(PROXY_TEST_LATEST_LOG))
40 | return string.Empty;
41 |
42 | return File.ReadAllText(PROXY_TEST_LATEST_LOG);
43 | }
44 | catch (Exception) {
45 | return string.Empty;
46 | }
47 | }
48 |
49 | private static void ClearLatestLogs() {
50 | try {
51 | if (File.Exists(PROXY_TEST_LATEST_LOG))
52 | File.Delete(PROXY_TEST_LATEST_LOG);
53 | }
54 | catch (Exception) { }
55 | }
56 |
57 | private string[] GetDomains() {
58 | try {
59 | if (!File.Exists(PROXY_TEST_SITES)) {
60 | AppendLogLine(Program.localization.GetString("proxy_test.sites_file_not_found"));
61 | return Array.Empty();
62 | }
63 |
64 | return File.ReadAllLines(PROXY_TEST_SITES);
65 | }
66 | catch (Exception) {
67 | AppendLogLine(Program.localization.GetString("proxy_test.sites_file_read_error"));
68 | return Array.Empty();
69 | }
70 | }
71 |
72 | private Task GetDomainsAsync() => Task.Run(() => GetDomains());
73 |
74 | private string[] GetCommands() {
75 | try {
76 | if (!File.Exists(PROXY_TEST_CMDS)) {
77 | AppendLogLine(Program.localization.GetString("proxy_test.cmds_file_not_found"));
78 | return Array.Empty();
79 | }
80 |
81 | return File.ReadAllLines(PROXY_TEST_CMDS);
82 | }
83 | catch (Exception) {
84 | AppendLogLine(Program.localization.GetString("proxy_test.cmds_file_read_error"));
85 | return Array.Empty();
86 | }
87 | }
88 |
89 | private Task GetCommandsAsync() => Task.Run(() => GetCommands());
90 |
91 | private static Uri GetValidUrl(string domain) {
92 | domain = domain.Trim();
93 | if (domain.StartsWith("http://") || domain.StartsWith("https://"))
94 | return new Uri(domain);
95 |
96 | return new Uri($"https://{domain}");
97 | }
98 |
99 | public async Task StartTesting() {
100 | try {
101 | if (IsTesting) {
102 | MessageBox.Show(
103 | Program.localization.GetString("proxy_test.already_running"),
104 | Program.localization.GetString("settings_form.title"),
105 | MessageBoxButtons.OK,
106 | MessageBoxIcon.Information
107 | );
108 | return;
109 | }
110 |
111 | IsTesting = true;
112 |
113 | Action updateUi = () => {
114 | try {
115 | ProxyTestStartButton.Text = "Стоп";
116 | ProxyTestLogsBox.Clear();
117 |
118 | if (ProxyTestProgressLabel != null) {
119 | ProxyTestProgressLabel.Text = "0/0";
120 | ProxyTestProgressLabel.Visible = true;
121 | }
122 | }
123 | catch { }
124 | };
125 |
126 | if (ProxyTestStartButton.InvokeRequired) {
127 | try {
128 | ProxyTestStartButton.BeginInvoke(updateUi);
129 | }
130 | catch { }
131 | }
132 | else {
133 | updateUi();
134 | }
135 |
136 | ClearLatestLogs();
137 | _cancellationTokenSource = new CancellationTokenSource();
138 |
139 | IEnumerable commands = await GetCommandsAsync();
140 | IEnumerable domains = await GetDomainsAsync();
141 |
142 | if (!commands.Any() || !domains.Any()) {
143 | StopTesting();
144 | return;
145 | }
146 |
147 | int totalTests = commands.Count();
148 | Action updateProgress = () => {
149 | try {
150 | if (ProxyTestProgressLabel != null) {
151 | ProxyTestProgressLabel.Text = $"0/{totalTests}";
152 | }
153 | }
154 | catch { }
155 | };
156 |
157 | if (ProxyTestProgressLabel != null && ProxyTestProgressLabel.InvokeRequired) {
158 | try {
159 | ProxyTestProgressLabel.BeginInvoke(updateProgress);
160 | }
161 | catch { }
162 | }
163 | else {
164 | updateProgress();
165 | }
166 |
167 | var commandsResults = await CheckDomainsAccessAsync(commands, domains, _cancellationTokenSource.Token);
168 |
169 | if (!IsTesting) return;
170 |
171 | var sortedResults = commandsResults.OrderByDescending(r => r.Value.Item3).ToArray();
172 |
173 | AppendLogLine("- - - - - - - - - - - - - - - - - - - - - - - - - - - -");
174 | AppendLogLine(string.Empty);
175 |
176 | AppendLogLine(Program.localization.GetString("proxy_test.commands_success_over_50"));
177 | AppendLogLine(string.Empty);
178 |
179 | for (int i = 0; i < sortedResults.Length; i++) {
180 | var result = sortedResults[i];
181 | int orderNumber = i + 1;
182 | AppendLogLine($"{result.Key}");
183 | AppendLogLine($"{result.Value.Item1}/{result.Value.Item2}");
184 | AppendLogLine(string.Empty);
185 | }
186 |
187 | if (sortedResults.Length == 0) {
188 | AppendLogLine(Program.localization.GetString("proxy_test.no_commands_over_50"));
189 | }
190 | }
191 | catch (OperationCanceledException) {
192 | AppendLogLine(Program.localization.GetString("proxy_test.stopped"));
193 | }
194 | catch (Exception ex) {
195 | AppendLogLine(string.Format(
196 | Program.localization.GetString("proxy_test.error_occurred"),
197 | ex.Message
198 | ));
199 | }
200 | finally {
201 | StopTesting();
202 | }
203 | }
204 |
205 | public void StopTesting() {
206 | try {
207 | if (!IsTesting) return;
208 |
209 | try {
210 | _cancellationTokenSource?.Cancel();
211 | }
212 | catch (Exception ex) {
213 | AppendLogLine(string.Format(
214 | Program.localization.GetString("settings_form.proxy_test.cancel_error"),
215 | ex.Message
216 | ));
217 | }
218 |
219 | try {
220 | _processManager.StopByeDpi();
221 | }
222 | catch (Exception ex) {
223 | AppendLogLine(string.Format(
224 | Program.localization.GetString("settings_form.byedpi.stop_error"),
225 | ex.Message
226 | ));
227 | }
228 | }
229 | catch (Exception ex) {
230 | AppendLogLine(string.Format(
231 | Program.localization.GetString("settings_form.proxy_test.stop_error"),
232 | ex.Message
233 | ));
234 | }
235 | finally {
236 | IsTesting = false;
237 |
238 | Action updateButtons = () => {
239 | try {
240 | if (ProxyTestStartButton != null && !ProxyTestStartButton.IsDisposed) {
241 | ProxyTestStartButton.Text = Program.localization.GetString("settings_form.proxy_test.start");
242 | }
243 |
244 | if (ProxyTestProgressLabel != null && !ProxyTestProgressLabel.IsDisposed) {
245 | ProxyTestProgressLabel.Visible = false;
246 | }
247 | }
248 | catch { }
249 | };
250 |
251 | if (ProxyTestStartButton != null && !ProxyTestStartButton.IsDisposed) {
252 | if (ProxyTestStartButton.InvokeRequired) {
253 | try {
254 | ProxyTestStartButton.BeginInvoke(updateButtons);
255 | }
256 | catch { }
257 | }
258 | else {
259 | updateButtons();
260 | }
261 | }
262 | }
263 | }
264 |
265 | private async Task>>> CheckDomainsAccessAsync(
266 | IEnumerable commands,
267 | IEnumerable domains,
268 | CancellationToken cancellationToken) {
269 | var commandsResults = new List>>();
270 | int requestsCount = _settings.ProxyTestRequestsCount;
271 | bool fullLog = _settings.ProxyTestFullLog;
272 | int totalTests = commands.Count();
273 | int completedTests = 0;
274 |
275 | var domainsList = domains.ToList();
276 |
277 | foreach (string command in commands) {
278 | cancellationToken.ThrowIfCancellationRequested();
279 |
280 | completedTests++;
281 |
282 | Action updateProgress = () => {
283 | try {
284 | if (ProxyTestProgressLabel != null) {
285 | ProxyTestProgressLabel.Text = $"{completedTests}/{totalTests}";
286 | }
287 | }
288 | catch { }
289 | };
290 |
291 | if (ProxyTestProgressLabel != null && ProxyTestProgressLabel.InvokeRequired) {
292 | try {
293 | ProxyTestProgressLabel.BeginInvoke(updateProgress);
294 | }
295 | catch { }
296 | }
297 | else {
298 | updateProgress();
299 | }
300 |
301 | var args = AppSettings.ShellSplit(command);
302 | var filtered = AppSettings.FilterLinuxOnlyArgs(args);
303 | var f_command = string.Join(" ", filtered);
304 |
305 | _processManager.StartByeDpi(f_command);
306 | AppendLogLine(f_command);
307 |
308 | try {
309 | using (var semaphore = new SemaphoreSlim(20)) {
310 | int totalSuccess = 0;
311 | int totalProcessed = 0;
312 | int totalDomains = domainsList.Count;
313 |
314 | var allTasks = new List();
315 | var domainResults = new List>();
316 |
317 | foreach (string domain in domainsList) {
318 | await semaphore.WaitAsync(cancellationToken);
319 |
320 | allTasks.Add(Task.Run(async () => {
321 | try {
322 | cancellationToken.ThrowIfCancellationRequested();
323 | string trimmedDomain = domain.Trim();
324 | int successCount = await CheckDomainAccessAsync(trimmedDomain, requestsCount, cancellationToken);
325 |
326 | if (fullLog) {
327 | AppendLogLine($"{trimmedDomain} - {successCount}/{requestsCount}");
328 | }
329 |
330 | lock (domainResults) {
331 | domainResults.Add(Tuple.Create(trimmedDomain, successCount));
332 | totalSuccess += successCount;
333 | totalProcessed++;
334 | }
335 | }
336 | catch (OperationCanceledException) { throw; }
337 | catch (Exception ex) {
338 | AppendLogLine(string.Format(
339 | Program.localization.GetString("proxy_test.domain_check_error"),
340 | ex.Message
341 | ));
342 | }
343 | finally {
344 | semaphore.Release();
345 | }
346 | }, cancellationToken));
347 | }
348 |
349 | await Task.WhenAll(allTasks);
350 |
351 | int totalRequests = requestsCount * totalDomains;
352 | int successPct = totalRequests == 0 ? 0 : totalSuccess * 100 / totalRequests;
353 |
354 | AppendLogLine($"{totalSuccess}/{totalRequests} ({successPct}%)");
355 |
356 | if (successPct > 50) {
357 | commandsResults.Add(new KeyValuePair>(command,
358 | new Tuple(totalSuccess, totalRequests, successPct)));
359 | }
360 |
361 | AppendLogLine(string.Empty);
362 | }
363 | }
364 | catch (OperationCanceledException) { throw; }
365 | catch (Exception ex) {
366 | AppendLogLine(string.Format(
367 | Program.localization.GetString("proxy_test.command_test_error"),
368 | command,
369 | ex.Message
370 | ));
371 | }
372 |
373 | _processManager.StopByeDpi();
374 |
375 | if (_settings.ProxyTestDelay > 0) {
376 | await Task.Delay(_settings.ProxyTestDelay * 1000, cancellationToken);
377 | }
378 | }
379 |
380 | return commandsResults;
381 | }
382 |
383 | private async Task CheckDomainAccessAsync(string domain, int requestsCount, CancellationToken cancellationToken) {
384 | Uri websiteUrl = GetValidUrl(domain);
385 | int successRequests = 0;
386 |
387 | ProxySettings proxySettings = new ProxySettings() {
388 | Host = "127.0.0.1",
389 | Port = 1080
390 | };
391 |
392 | try {
393 | using (var proxyClientHandler = new ProxyClientHandler(proxySettings))
394 | using (var httpClient = new HttpClient(proxyClientHandler) {
395 | Timeout = TimeSpan.FromSeconds(3)
396 | }) {
397 | for (int i = 0; i < requestsCount && !cancellationToken.IsCancellationRequested; i++) {
398 | try {
399 | using (var cts = new CancellationTokenSource(TimeSpan.FromSeconds(3)))
400 | using (var linkedCts = CancellationTokenSource.CreateLinkedTokenSource(cts.Token, cancellationToken)) {
401 | var response = await httpClient.GetAsync(websiteUrl, HttpCompletionOption.ResponseHeadersRead, linkedCts.Token);
402 | successRequests++;
403 | }
404 | }
405 | catch (TaskCanceledException) { }
406 | catch (HttpRequestException) { }
407 | catch (OperationCanceledException) {
408 | if (cancellationToken.IsCancellationRequested) throw;
409 | }
410 | catch (Exception) { }
411 | }
412 | }
413 | }
414 | catch (OperationCanceledException) {
415 | if (cancellationToken.IsCancellationRequested) throw;
416 | }
417 | catch (Exception) { }
418 |
419 | return successRequests;
420 | }
421 |
422 | private void AppendLogLine(string text) {
423 | try {
424 | try {
425 | Directory.CreateDirectory(Path.GetDirectoryName(PROXY_TEST_LATEST_LOG));
426 | File.AppendAllText(PROXY_TEST_LATEST_LOG, $"{text}{Environment.NewLine}");
427 | }
428 | catch (Exception) { }
429 |
430 | LogAdded?.Invoke(this, text);
431 |
432 | if (ProxyTestLogsBox == null || ProxyTestLogsBox.IsDisposed) return;
433 |
434 | Action updateUi = () => {
435 | try {
436 | lock (_logLock) {
437 | ProxyTestLogsBox.AppendText(text);
438 | ProxyTestLogsBox.AppendText(Environment.NewLine);
439 | ProxyTestLogsBox.ScrollToCaret();
440 | }
441 | }
442 | catch (Exception) { }
443 | };
444 |
445 | if (ProxyTestLogsBox.InvokeRequired) {
446 | try {
447 | ProxyTestLogsBox.BeginInvoke(updateUi);
448 | }
449 | catch (Exception) { }
450 | }
451 | else {
452 | updateUi();
453 | }
454 | }
455 | catch (Exception) { }
456 | }
457 | }
458 | }
459 |
--------------------------------------------------------------------------------
/src/SettingsForm.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 | using System.Reflection;
4 | using System.Drawing;
5 | using System.Windows.Forms;
6 |
7 | namespace bdmanager {
8 | public partial class SettingsForm : Form {
9 | private AppSettings _settings;
10 | private AutorunManager _autorunManager;
11 | private ProxyTestManager _proxyTestManager;
12 |
13 | private TabControl _tabControl;
14 |
15 | private TextBox _byeDpiPathTextBox;
16 | private HotkeyTextBox _hotkeyTextBox;
17 | private TextBox _byeDpiArgsTextBox;
18 |
19 | private CheckBox _disableProxiFyreCheckBox;
20 | private TextBox _proxiFyrePathTextBox;
21 | private NumericUpDown _proxiFyrePortNumBox;
22 | private ListBox _appListBox;
23 | private TextBox _appTextBox;
24 | private TextBox _proxyTestLogsBox;
25 | private Label _proxyTestProgressLabel;
26 |
27 | private CheckBox _autoStartCheckBox;
28 | private CheckBox _autoConnectCheckBox;
29 | private CheckBox _StartMinimizedCheckBox;
30 |
31 | private NumericUpDown _delayNumericUpDown;
32 | private NumericUpDown _requestsCountNumericUpDown;
33 | private CheckBox _fullLogCheckBox;
34 |
35 | public SettingsForm() {
36 | _settings = Program.settings;
37 | _autorunManager = Program.autorunManager;
38 | _proxyTestManager = new ProxyTestManager();
39 | InitializeComponent();
40 |
41 | DpiScaler.Scale(this);
42 | }
43 |
44 | private void InitializeComponent() {
45 | SuspendLayout();
46 |
47 | Text = Program.localization.GetString("settings_form.title");
48 | MinimumSize = new Size(550, 550);
49 | StartPosition = FormStartPosition.CenterParent;
50 | FormBorderStyle = FormBorderStyle.Sizable;
51 | MaximizeBox = true;
52 | MinimizeBox = true;
53 | ShowIcon = false;
54 | Load += SettingsForm_Load;
55 | FormClosing += SettingsForm_FormClosing;
56 | BackColor = SystemColors.Control;
57 | ForeColor = SystemColors.ControlText;
58 | Padding = new Padding(10);
59 |
60 | // Tabs
61 | _tabControl = new TabControl {
62 | Name = "tabControl",
63 | Dock = DockStyle.Fill
64 | };
65 | Controls.Add(_tabControl);
66 |
67 | // Init Tabs
68 | AddByeDPI();
69 | AddProxiFyre();
70 | AddAutorun();
71 | AddProxyTest();
72 | AddAbout();
73 |
74 | // Buttons
75 | FlowLayoutPanel formButtonsPanel = new FlowLayoutPanel {
76 | FlowDirection = FlowDirection.RightToLeft,
77 | Dock = DockStyle.Bottom,
78 | AutoSize = true,
79 | Padding = new Padding(0, 10, 0, 0),
80 | Name = "formButtonsPanel"
81 | };
82 | Controls.Add(formButtonsPanel);
83 |
84 | Button okButton = new Button {
85 | Text = Program.localization.GetString("settings_form.buttons.ok"),
86 | DialogResult = DialogResult.OK,
87 | Name = "okButton",
88 | Margin = new Padding(3),
89 | AutoSize = true
90 | };
91 | okButton.Click += OkButton_Click;
92 | formButtonsPanel.Controls.Add(okButton);
93 |
94 | Button cancelButton = new Button {
95 | Text = Program.localization.GetString("settings_form.buttons.cancel"),
96 | DialogResult = DialogResult.Cancel,
97 | Name = "cancelButton",
98 | Margin = new Padding(3),
99 | AutoSize = true
100 | };
101 | formButtonsPanel.Controls.Add(cancelButton);
102 |
103 |
104 | AcceptButton = okButton;
105 | CancelButton = cancelButton;
106 |
107 | ResumeLayout(false);
108 | PerformLayout();
109 | }
110 |
111 | private void AddByeDPI() {
112 | TabPage byeDpiTabPage = new TabPage {
113 | Text = Program.localization.GetString("settings_form.byedpi.tab"),
114 | Name = "byeDpiTabPage",
115 | BackColor = SystemColors.Control,
116 | Padding = new Padding(10)
117 | };
118 | _tabControl.TabPages.Add(byeDpiTabPage);
119 |
120 | GroupBox byeDpiGroupBox = new GroupBox {
121 | Text = Program.localization.GetString("settings_form.byedpi.group"),
122 | Name = "byeDpiGroupBox",
123 | Dock = DockStyle.Fill,
124 | ForeColor = SystemColors.ControlText,
125 | BackColor = SystemColors.Control,
126 | Padding = new Padding(10, 5, 10, 10)
127 | };
128 | byeDpiTabPage.Controls.Add(byeDpiGroupBox);
129 |
130 | TableLayoutPanel byeDpiLayout = new TableLayoutPanel {
131 | Dock = DockStyle.Fill,
132 | ColumnCount = 3,
133 | RowCount = 4,
134 | ColumnStyles = {
135 | new ColumnStyle(SizeType.AutoSize),
136 | new ColumnStyle(SizeType.Percent, 100F),
137 | new ColumnStyle(SizeType.Absolute, 30)
138 | },
139 | RowStyles = {
140 | new RowStyle(SizeType.AutoSize),
141 | new RowStyle(SizeType.AutoSize),
142 | new RowStyle(SizeType.AutoSize),
143 | new RowStyle(SizeType.Percent, 100F)
144 | },
145 | Name = "byeDpiLayout"
146 | };
147 | byeDpiGroupBox.Controls.Add(byeDpiLayout);
148 |
149 | Label byeDpiPathLabel = new Label {
150 | Text = Program.localization.GetString("settings_form.byedpi.path_label"),
151 | TextAlign = ContentAlignment.MiddleLeft,
152 | Name = "byeDpiPathLabel",
153 | Margin = new Padding(0),
154 | };
155 | byeDpiLayout.Controls.Add(byeDpiPathLabel, 0, 0);
156 |
157 | _byeDpiPathTextBox = new TextBox {
158 | Name = "byeDpiPathTextBox",
159 | Anchor = AnchorStyles.Left | AnchorStyles.Right,
160 | Margin = new Padding(0)
161 | };
162 | byeDpiLayout.Controls.Add(_byeDpiPathTextBox, 1, 0);
163 |
164 | Button byeDpiBrowseButton = new Button {
165 | Text = "...",
166 | Anchor = AnchorStyles.None,
167 | Name = "byeDpiBrowseButton",
168 | Margin = new Padding(0),
169 | };
170 | byeDpiBrowseButton.Click += (s, e) => BrowseForExe(_byeDpiPathTextBox, Program.localization.GetString("settings_form.byedpi.browse_title"));
171 | byeDpiLayout.Controls.Add(byeDpiBrowseButton, 2, 0);
172 |
173 | Label hotkeyLabel = new Label {
174 | Text = Program.localization.GetString("settings_form.byedpi.hotkey_label"),
175 | TextAlign = ContentAlignment.MiddleLeft,
176 | Name = "hotkeyLabel",
177 | Margin = new Padding(0, 3, 0, 3),
178 | };
179 | byeDpiLayout.Controls.Add(hotkeyLabel, 0, 1);
180 |
181 | _hotkeyTextBox = new HotkeyTextBox {
182 | Name = "hotkeyTextBox",
183 | Anchor = AnchorStyles.Left | AnchorStyles.Right,
184 | Margin = new Padding(0, 3, 0, 3)
185 | };
186 | byeDpiLayout.Controls.Add(_hotkeyTextBox, 1, 1);
187 |
188 | Label byeDpiArgsLabel = new Label {
189 | Text = Program.localization.GetString("settings_form.byedpi.args_label"),
190 | TextAlign = ContentAlignment.MiddleLeft,
191 | Name = "byeDpiArgsLabel",
192 | Margin = new Padding(0, 3, 0, 3),
193 | };
194 | byeDpiLayout.SetColumnSpan(byeDpiArgsLabel, 3);
195 | byeDpiLayout.Controls.Add(byeDpiArgsLabel, 0, 2);
196 |
197 | _byeDpiArgsTextBox = new TextBox {
198 | Name = "byeDpiArgsTextBox",
199 | Multiline = true,
200 | ScrollBars = ScrollBars.Vertical,
201 | Anchor = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top | AnchorStyles.Bottom,
202 | Margin = new Padding(0, 3, 0, 3)
203 | };
204 | byeDpiLayout.SetColumnSpan(_byeDpiArgsTextBox, 3);
205 | byeDpiLayout.Controls.Add(_byeDpiArgsTextBox, 0, 3);
206 | }
207 |
208 | private void AddProxiFyre() {
209 | TabPage proxiFyreTabPage = new TabPage {
210 | Text = Program.localization.GetString("settings_form.proxifyre.tab"),
211 | Name = "proxiFyreTabPage",
212 | BackColor = SystemColors.Control,
213 | Padding = new Padding(10)
214 | };
215 | _tabControl.TabPages.Add(proxiFyreTabPage);
216 |
217 | TableLayoutPanel proxiFyreTabLayout = new TableLayoutPanel {
218 | Dock = DockStyle.Fill,
219 | ColumnCount = 1,
220 | RowCount = 2,
221 | RowStyles = {
222 | new RowStyle(SizeType.AutoSize),
223 | new RowStyle(SizeType.Percent, 100F)
224 | },
225 | Name = "proxiFyreTabLayout"
226 | };
227 | proxiFyreTabPage.Controls.Add(proxiFyreTabLayout);
228 |
229 | GroupBox proxiFyreGroupBox = new GroupBox {
230 | Text = Program.localization.GetString("settings_form.proxifyre.group"),
231 | Name = "proxiFyreGroupBox",
232 | Dock = DockStyle.Fill,
233 | MinimumSize = new Size(0, 110),
234 | ForeColor = SystemColors.ControlText,
235 | BackColor = SystemColors.Control,
236 | Padding = new Padding(10, 5, 10, 10),
237 | Margin = new Padding(0)
238 | };
239 | proxiFyreTabLayout.Controls.Add(proxiFyreGroupBox, 0, 0);
240 |
241 | TableLayoutPanel proxiFyreLayout = new TableLayoutPanel {
242 | Dock = DockStyle.Fill,
243 | ColumnCount = 3,
244 | RowCount = 3,
245 | ColumnStyles = {
246 | new ColumnStyle(SizeType.AutoSize),
247 | new ColumnStyle(SizeType.Percent, 100F),
248 | new ColumnStyle(SizeType.Absolute, 30)
249 | },
250 | RowStyles = {
251 | new RowStyle(SizeType.Percent, 100F),
252 | new RowStyle(SizeType.Percent, 100F),
253 | new RowStyle(SizeType.Percent, 100F)
254 | },
255 | Name = "proxiFyreLayout"
256 | };
257 | proxiFyreGroupBox.Controls.Add(proxiFyreLayout);
258 |
259 | Label proxiFyrePathLabel = new Label {
260 | Text = Program.localization.GetString("settings_form.proxifyre.path_label"),
261 | TextAlign = ContentAlignment.MiddleLeft,
262 | Name = "proxiFyrePathLabel",
263 | Margin = new Padding(0),
264 | };
265 | proxiFyreLayout.Controls.Add(proxiFyrePathLabel, 0, 0);
266 |
267 | _proxiFyrePathTextBox = new TextBox {
268 | Name = "proxiFyrePathTextBox",
269 | Anchor = AnchorStyles.Left | AnchorStyles.Right,
270 | Margin = new Padding(0)
271 | };
272 | proxiFyreLayout.Controls.Add(_proxiFyrePathTextBox, 1, 0);
273 |
274 | Button proxiFyreBrowseButton = new Button {
275 | Text = "...",
276 | Anchor = AnchorStyles.None,
277 | Name = "proxiFyreBrowseButton",
278 | Margin = new Padding(0),
279 | };
280 | proxiFyreBrowseButton.Click += (s, e) => BrowseForExe(_proxiFyrePathTextBox, Program.localization.GetString("settings_form.proxifyre.browse_title"));
281 | proxiFyreLayout.Controls.Add(proxiFyreBrowseButton, 2, 0);
282 |
283 | Label proxiFyrePortLabel = new Label {
284 | Text = Program.localization.GetString("settings_form.proxifyre.port_label"),
285 | TextAlign = ContentAlignment.MiddleLeft,
286 | Name = "proxiFyrePortLabel",
287 | Margin = new Padding(0, 3, 0, 3),
288 | };
289 | proxiFyreLayout.Controls.Add(proxiFyrePortLabel, 0, 1);
290 |
291 | _proxiFyrePortNumBox = new NumericUpDown {
292 | Name = "proxiFyrePortNumBox",
293 | Minimum = 1,
294 | Maximum = 65535,
295 | Anchor = AnchorStyles.Left | AnchorStyles.None,
296 | Margin = new Padding(0),
297 | AutoSize = true
298 | };
299 | proxiFyreLayout.Controls.Add(_proxiFyrePortNumBox, 1, 1);
300 |
301 | _disableProxiFyreCheckBox = new CheckBox {
302 | Text = Program.localization.GetString("settings_form.proxifyre.disable"),
303 | Name = "disableProxiFyreCheckBox",
304 | Margin = new Padding(3, 3, 3, 0),
305 | Dock = DockStyle.Fill
306 | };
307 | proxiFyreLayout.SetColumnSpan(_disableProxiFyreCheckBox, 3);
308 | proxiFyreLayout.Controls.Add(_disableProxiFyreCheckBox, 0, 2);
309 |
310 | GroupBox appsGroupBox = new GroupBox {
311 | Text = Program.localization.GetString("settings_form.apps.group"),
312 | Name = "appsGroupBox",
313 | Dock = DockStyle.Fill,
314 | ForeColor = SystemColors.ControlText,
315 | BackColor = SystemColors.Control,
316 | Padding = new Padding(10),
317 | Margin = new Padding(0, 5, 0, 0),
318 | };
319 | proxiFyreTabLayout.Controls.Add(appsGroupBox, 0, 1);
320 |
321 | TableLayoutPanel appsLayout = new TableLayoutPanel {
322 | Dock = DockStyle.Fill,
323 | ColumnCount = 3,
324 | RowCount = 4,
325 | ColumnStyles = {
326 | new ColumnStyle(SizeType.AutoSize),
327 | new ColumnStyle(SizeType.Percent, 100F),
328 | new ColumnStyle(SizeType.Absolute, 30)
329 | },
330 | RowStyles = {
331 | new RowStyle(SizeType.Percent, 100F),
332 | new RowStyle(SizeType.AutoSize),
333 | new RowStyle(SizeType.AutoSize),
334 | new RowStyle(SizeType.AutoSize)
335 | },
336 | Name = "appsLayout"
337 | };
338 | appsGroupBox.Controls.Add(appsLayout);
339 |
340 | _appListBox = new ListBox {
341 | Name = "appListBox",
342 | Anchor = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top | AnchorStyles.Bottom,
343 | Margin = new Padding(3)
344 | };
345 | appsLayout.SetColumnSpan(_appListBox, 3);
346 | appsLayout.Controls.Add(_appListBox, 0, 0);
347 |
348 | Label appNameLabel = new Label {
349 | Text = Program.localization.GetString("settings_form.apps.name_label"),
350 | TextAlign = ContentAlignment.MiddleLeft,
351 | Name = "appNameLabel",
352 | Margin = new Padding(0, 3, 0, 3),
353 | AutoSize = true
354 | };
355 | appsLayout.SetColumnSpan(appNameLabel, 3);
356 | appsLayout.Controls.Add(appNameLabel, 0, 1);
357 |
358 | _appTextBox = new TextBox {
359 | Name = "appTextBox",
360 | Anchor = AnchorStyles.Left | AnchorStyles.Right,
361 | Margin = new Padding(0, 3, 0, 3)
362 | };
363 | appsLayout.SetColumnSpan(_appTextBox, 2);
364 | appsLayout.Controls.Add(_appTextBox, 0, 2);
365 |
366 | Button appBrowseButton = new Button {
367 | Text = "...",
368 | Anchor = AnchorStyles.None,
369 | Name = "appBrowseButton",
370 | Margin = new Padding(0)
371 | };
372 | appBrowseButton.Click += (s, e) => {
373 | BrowseForExe(_appTextBox, Program.localization.GetString("settings_form.apps.browse_title"));
374 | if (!string.IsNullOrWhiteSpace(_appTextBox.Text)) {
375 | AddAppToList(_appTextBox.Text);
376 | }
377 | };
378 | appsLayout.Controls.Add(appBrowseButton, 1, 2);
379 |
380 | FlowLayoutPanel appButtonsPanel = new FlowLayoutPanel {
381 | FlowDirection = FlowDirection.RightToLeft,
382 | Dock = DockStyle.Fill,
383 | WrapContents = false,
384 | AutoSize = true,
385 | Name = "appButtonsPanel"
386 | };
387 | appsLayout.SetColumnSpan(appButtonsPanel, 3);
388 | appsLayout.Controls.Add(appButtonsPanel, 0, 3);
389 |
390 | Button addAppButton = new Button {
391 | Text = Program.localization.GetString("settings_form.apps.add"),
392 | Name = "addAppButton",
393 | Margin = new Padding(3, 3, 0, 3),
394 | };
395 | addAppButton.Click += AddAppButton_Click;
396 | appButtonsPanel.Controls.Add(addAppButton);
397 |
398 | Button removeAppButton = new Button {
399 | Text = Program.localization.GetString("settings_form.apps.remove"),
400 | Name = "removeAppButton",
401 | Margin = new Padding(3),
402 | };
403 | removeAppButton.Click += RemoveAppButton_Click;
404 | appButtonsPanel.Controls.Add(removeAppButton);
405 | }
406 |
407 | private void AddAutorun() {
408 | TabPage autorunTabPage = new TabPage {
409 | Text = Program.localization.GetString("settings_form.autorun.tab"),
410 | Name = "autorunTabPage",
411 | BackColor = SystemColors.Control,
412 | Padding = new Padding(10)
413 | };
414 | _tabControl.TabPages.Add(autorunTabPage);
415 |
416 | GroupBox autorunGroupBox = new GroupBox {
417 | Text = Program.localization.GetString("settings_form.autorun.group"),
418 | Name = "autorunGroupBox",
419 | Dock = DockStyle.Fill,
420 | ForeColor = SystemColors.ControlText,
421 | BackColor = SystemColors.Control,
422 | Padding = new Padding(10, 5, 10, 10)
423 | };
424 | autorunTabPage.Controls.Add(autorunGroupBox);
425 |
426 | FlowLayoutPanel autorunLayout = new FlowLayoutPanel {
427 | Dock = DockStyle.Fill,
428 | FlowDirection = FlowDirection.TopDown,
429 | AutoSize = true,
430 | WrapContents = false,
431 | Name = "autorunLayout"
432 | };
433 | autorunGroupBox.Controls.Add(autorunLayout);
434 |
435 | _autoStartCheckBox = new CheckBox {
436 | Text = Program.localization.GetString("settings_form.autorun.auto_start"),
437 | Name = "autoStartCheckBox",
438 | Margin = new Padding(3),
439 | AutoSize = true
440 | };
441 | autorunLayout.Controls.Add(_autoStartCheckBox);
442 |
443 | _autoConnectCheckBox = new CheckBox {
444 | Text = Program.localization.GetString("settings_form.autorun.auto_connect"),
445 | Name = "autoConnectCheckBox",
446 | Margin = new Padding(3),
447 | AutoSize = true
448 | };
449 | autorunLayout.Controls.Add(_autoConnectCheckBox);
450 |
451 | _StartMinimizedCheckBox = new CheckBox {
452 | Text = Program.localization.GetString("settings_form.autorun.start_minimized"),
453 | Name = "StartMinimizedCheckBox",
454 | Margin = new Padding(3),
455 | AutoSize = true
456 | };
457 | autorunLayout.Controls.Add(_StartMinimizedCheckBox);
458 | }
459 |
460 | private void AddProxyTest() {
461 | TabPage proxyTestTabPage = new TabPage {
462 | Text = Program.localization.GetString("settings_form.proxy_test.tab"),
463 | Name = "proxyTestTabPage",
464 | BackColor = SystemColors.Control,
465 | Padding = new Padding(10)
466 | };
467 | _tabControl.TabPages.Add(proxyTestTabPage);
468 |
469 | TableLayoutPanel proxyTestTabLayout = new TableLayoutPanel {
470 | Dock = DockStyle.Fill,
471 | ColumnCount = 1,
472 | RowCount = 2,
473 | RowStyles = {
474 | new RowStyle(SizeType.AutoSize),
475 | new RowStyle(SizeType.Percent, 100F)
476 | },
477 | Name = "proxyTestTabLayout"
478 | };
479 | proxyTestTabPage.Controls.Add(proxyTestTabLayout);
480 |
481 | GroupBox proxySettingsGroupBox = new GroupBox {
482 | Text = Program.localization.GetString("settings_form.proxy_test.settings_group"),
483 | Name = "proxySettingsGroupBox",
484 | Dock = DockStyle.Fill,
485 | ForeColor = SystemColors.ControlText,
486 | BackColor = SystemColors.Control,
487 | MinimumSize = new Size(0, 130),
488 | Padding = new Padding(10, 5, 10, 10),
489 | Margin = new Padding(0)
490 | };
491 | proxyTestTabLayout.Controls.Add(proxySettingsGroupBox, 0, 0);
492 |
493 | TableLayoutPanel proxySettingsLayout = new TableLayoutPanel {
494 | Dock = DockStyle.Fill,
495 | ColumnCount = 2,
496 | RowCount = 4,
497 | ColumnStyles = {
498 | new ColumnStyle(SizeType.Percent, 100F),
499 | new ColumnStyle(SizeType.AutoSize),
500 | },
501 | RowStyles = {
502 | new RowStyle(SizeType.Percent, 100F),
503 | new RowStyle(SizeType.Percent, 100F),
504 | new RowStyle(SizeType.Percent, 100F),
505 | new RowStyle(SizeType.Percent, 100F),
506 | },
507 | Name = "proxySettingsLayout"
508 | };
509 | proxySettingsGroupBox.Controls.Add(proxySettingsLayout);
510 |
511 | Label delayLabel = new Label {
512 | Text = Program.localization.GetString("settings_form.proxy_test.delay_label"),
513 | TextAlign = ContentAlignment.MiddleLeft,
514 | Margin = new Padding(0),
515 | Dock = DockStyle.Fill
516 | };
517 | proxySettingsLayout.Controls.Add(delayLabel, 0, 0);
518 |
519 | _delayNumericUpDown = new NumericUpDown {
520 | Maximum = int.MaxValue,
521 | Anchor = AnchorStyles.Right | AnchorStyles.None,
522 | Margin = new Padding(0),
523 | AutoSize = true
524 | };
525 | proxySettingsLayout.Controls.Add(_delayNumericUpDown, 1, 0);
526 |
527 | Label requestsCountLabel = new Label {
528 | Text = Program.localization.GetString("settings_form.proxy_test.requests_label"),
529 | TextAlign = ContentAlignment.MiddleLeft,
530 | Margin = new Padding(0, 3, 0, 3),
531 | Dock = DockStyle.Fill
532 | };
533 | proxySettingsLayout.Controls.Add(requestsCountLabel, 0, 1);
534 |
535 | _requestsCountNumericUpDown = new NumericUpDown {
536 | Minimum = 1,
537 | Maximum = int.MaxValue,
538 | Anchor = AnchorStyles.Right | AnchorStyles.None,
539 | Margin = new Padding(0, 3, 0, 3),
540 | AutoSize = true
541 | };
542 | proxySettingsLayout.Controls.Add(_requestsCountNumericUpDown, 1, 1);
543 |
544 | _fullLogCheckBox = new CheckBox {
545 | Text = Program.localization.GetString("settings_form.proxy_test.full_log"),
546 | Margin = new Padding(3, 3, 3, 0),
547 | Dock = DockStyle.Fill
548 | };
549 | proxySettingsLayout.SetColumnSpan(_fullLogCheckBox, 2);
550 | proxySettingsLayout.Controls.Add(_fullLogCheckBox, 0, 2);
551 |
552 | TableLayoutPanel buttonsLayout = new TableLayoutPanel {
553 | Dock = DockStyle.Fill,
554 | ColumnCount = 2,
555 | RowCount = 1,
556 | ColumnStyles = {
557 | new ColumnStyle(SizeType.Percent, 50F),
558 | new ColumnStyle(SizeType.Percent, 50F)
559 | },
560 | RowStyles = {
561 | new RowStyle(SizeType.AutoSize)
562 | },
563 | Margin = new Padding(0, 5, 0, 0),
564 | Name = "buttonsLayout"
565 | };
566 | proxySettingsLayout.SetColumnSpan(buttonsLayout, 2);
567 | proxySettingsLayout.Controls.Add(buttonsLayout, 0, 3);
568 |
569 | Button editDomainsButton = new Button {
570 | Text = Program.localization.GetString("settings_form.proxy_test.edit_domains"),
571 | Dock = DockStyle.Fill,
572 | Margin = new Padding(0, 0, 3, 0)
573 | };
574 | editDomainsButton.Click += EditDomainsButton_Click;
575 | buttonsLayout.Controls.Add(editDomainsButton, 0, 0);
576 |
577 | Button editCommandsButton = new Button {
578 | Text = Program.localization.GetString("settings_form.proxy_test.edit_commands"),
579 | Dock = DockStyle.Fill,
580 | Margin = new Padding(3, 0, 0, 0)
581 | };
582 | editCommandsButton.Click += EditCommandsButton_Click;
583 | buttonsLayout.Controls.Add(editCommandsButton, 1, 0);
584 |
585 | GroupBox proxyLogsGroupBox = new GroupBox {
586 | Text = Program.localization.GetString("settings_form.proxy_test.logs_group"),
587 | Name = "proxyLogsGroupBox",
588 | Dock = DockStyle.Fill,
589 | ForeColor = SystemColors.ControlText,
590 | BackColor = SystemColors.Control,
591 | Padding = new Padding(10),
592 | Margin = new Padding(0, 5, 0, 0),
593 | };
594 | proxyTestTabLayout.Controls.Add(proxyLogsGroupBox, 0, 1);
595 |
596 | TableLayoutPanel proxyLogsLayout = new TableLayoutPanel {
597 | Dock = DockStyle.Fill,
598 | ColumnCount = 2,
599 | RowCount = 2,
600 | ColumnStyles = {
601 | new ColumnStyle(SizeType.AutoSize),
602 | new ColumnStyle(SizeType.Percent, 100F)
603 | },
604 | RowStyles = {
605 | new RowStyle(SizeType.Percent, 100F),
606 | new RowStyle(SizeType.AutoSize)
607 | },
608 | Name = "proxyLogsLayout"
609 | };
610 | proxyLogsGroupBox.Controls.Add(proxyLogsLayout);
611 |
612 | _proxyTestLogsBox = new TextBox {
613 | Text = ProxyTestManager.GetLatestLogs(),
614 | Name = "proxyLogsRichBox",
615 | BackColor = Color.White,
616 | ForeColor = Color.Black,
617 | ReadOnly = true,
618 | Multiline = true,
619 | ScrollBars = ScrollBars.Vertical,
620 | Anchor = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top | AnchorStyles.Bottom,
621 | Margin = new Padding(0, 0, 0, 3)
622 | };
623 | proxyLogsLayout.SetColumnSpan(_proxyTestLogsBox, 2);
624 | proxyLogsLayout.Controls.Add(_proxyTestLogsBox, 0, 0);
625 |
626 | Button proxyTestStartButton = new Button {
627 | Text = Program.localization.GetString("settings_form.proxy_test.start"),
628 | Margin = new Padding(0, 3, 0, 0),
629 | AutoSize = true
630 | };
631 | proxyTestStartButton.Click += ProxyTestStartButton_Click;
632 | proxyLogsLayout.Controls.Add(proxyTestStartButton, 0, 1);
633 |
634 | _proxyTestProgressLabel = new Label {
635 | Text = "",
636 | Name = "proxyTestProgressLabel",
637 | TextAlign = ContentAlignment.MiddleLeft,
638 | Visible = false,
639 | Anchor = AnchorStyles.Left | AnchorStyles.Right,
640 | Margin = new Padding(3, 3, 0, 0),
641 | AutoSize = false
642 | };
643 | proxyLogsLayout.Controls.Add(_proxyTestProgressLabel, 1, 1);
644 | }
645 |
646 | private void AddAbout() {
647 | TabPage aboutTabPage = new TabPage {
648 | Text = Program.localization.GetString("settings_form.about.tab"),
649 | Name = "aboutTabPage",
650 | BackColor = SystemColors.Control,
651 | Padding = new Padding(10)
652 | };
653 | _tabControl.TabPages.Add(aboutTabPage);
654 |
655 | GroupBox aboutGroupBox = new GroupBox {
656 | Text = Program.localization.GetString("settings_form.about.group"),
657 | Name = "aboutGroupBox",
658 | Dock = DockStyle.Fill,
659 | ForeColor = SystemColors.ControlText,
660 | BackColor = SystemColors.Control,
661 | Padding = new Padding(10)
662 | };
663 | aboutTabPage.Controls.Add(aboutGroupBox);
664 |
665 | TableLayoutPanel aboutLayout = new TableLayoutPanel {
666 | Dock = DockStyle.Fill,
667 | ColumnCount = 2,
668 | RowCount = 3,
669 | ColumnStyles = {
670 | new ColumnStyle(SizeType.AutoSize),
671 | new ColumnStyle(SizeType.Percent, 100F)
672 | },
673 | RowStyles = {
674 | new RowStyle(SizeType.AutoSize),
675 | new RowStyle(SizeType.AutoSize),
676 | new RowStyle(SizeType.AutoSize)
677 | },
678 | Name = "aboutLayout",
679 | AutoSize = true
680 | };
681 | aboutGroupBox.Controls.Add(aboutLayout);
682 |
683 | Assembly asm = Assembly.GetExecutingAssembly();
684 | string version = asm.GetCustomAttribute()?.Version;
685 | string author = asm.GetCustomAttribute()?.Copyright;
686 |
687 | Label versionLabel = new Label {
688 | Text = Program.localization.GetString("settings_form.about.version_label"),
689 | Name = "versionLabel",
690 | Margin = new Padding(0, 3, 0, 3),
691 | };
692 | aboutLayout.Controls.Add(versionLabel, 0, 0);
693 |
694 | Label versionValueLabel = new Label {
695 | Text = version,
696 | Name = "versionValueLabel",
697 | Margin = new Padding(10, 3, 0, 3),
698 | Anchor = AnchorStyles.Left | AnchorStyles.Right,
699 | };
700 | aboutLayout.Controls.Add(versionValueLabel, 1, 0);
701 |
702 | Label developerLabel = new Label {
703 | Text = Program.localization.GetString("settings_form.about.developer_label"),
704 | Name = "developerLabel",
705 | Margin = new Padding(0, 3, 0, 3),
706 | };
707 | aboutLayout.Controls.Add(developerLabel, 0, 1);
708 |
709 | Label developerValueLabel = new Label {
710 | Text = author,
711 | Name = "developerValueLabel",
712 | Margin = new Padding(10, 3, 0, 3),
713 | Anchor = AnchorStyles.Left | AnchorStyles.Right,
714 | };
715 | aboutLayout.Controls.Add(developerValueLabel, 1, 1);
716 |
717 | Label githubLabel = new Label {
718 | Text = Program.localization.GetString("settings_form.about.github_label"),
719 | Name = "githubLabel",
720 | Margin = new Padding(0, 3, 0, 3),
721 | };
722 | aboutLayout.Controls.Add(githubLabel, 0, 2);
723 |
724 | LinkLabel githubLinkLabel = new LinkLabel {
725 | Text = Program.localization.GetString("settings_form.about.github_link"),
726 | Name = "githubLinkLabel",
727 | Margin = new Padding(10, 3, 0, 3),
728 | Anchor = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top,
729 | };
730 | githubLinkLabel.LinkClicked += (s, e) => { System.Diagnostics.Process.Start(githubLinkLabel.Text); };
731 | aboutLayout.Controls.Add(githubLinkLabel, 1, 2);
732 | }
733 |
734 | private async void ProxyTestStartButton_Click(object sender, EventArgs e) {
735 | Button proxyTestStartButton = (Button)sender;
736 | if (!_proxyTestManager.IsTesting) {
737 | OkButton_Click(sender, e);
738 | _settings.Save();
739 |
740 | _settings.ProxyTestDelay = (int)_delayNumericUpDown.Value;
741 | _settings.ProxyTestRequestsCount = (int)_requestsCountNumericUpDown.Value;
742 | _settings.ProxyTestFullLog = _fullLogCheckBox.Checked;
743 | _settings.Save();
744 |
745 | _proxyTestManager.ProxyTestStartButton = proxyTestStartButton;
746 | _proxyTestManager.ProxyTestLogsBox = _proxyTestLogsBox;
747 | _proxyTestManager.ProxyTestProgressLabel = _proxyTestProgressLabel;
748 |
749 | await _proxyTestManager.StartTesting();
750 | }
751 | else {
752 | _proxyTestManager.StopTesting();
753 | }
754 | }
755 |
756 | private void SettingsForm_Load(object sender, EventArgs e) {
757 | _byeDpiPathTextBox.Text = _settings.ByeDpiPath;
758 | _hotkeyTextBox.Text = _settings.Hotkey;
759 | _byeDpiArgsTextBox.Text = _settings.ByeDpiArguments;
760 | _disableProxiFyreCheckBox.Checked = _settings.DisableProxiFyre;
761 | _proxiFyrePathTextBox.Text = _settings.ProxiFyrePath;
762 | _proxiFyrePortNumBox.Value = _settings.ProxiFyrePort;
763 |
764 | bool autorunEnabled = _autorunManager.IsAutorunEnabled();
765 | if (_settings.AutoStart != autorunEnabled) {
766 | _settings.AutoStart = autorunEnabled;
767 | }
768 |
769 | _autoStartCheckBox.Checked = _settings.AutoStart;
770 | _autoConnectCheckBox.Checked = _settings.AutoConnect;
771 | _StartMinimizedCheckBox.Checked = _settings.StartMinimized;
772 |
773 | _delayNumericUpDown.Value = _settings.ProxyTestDelay;
774 | _requestsCountNumericUpDown.Value = _settings.ProxyTestRequestsCount;
775 | _fullLogCheckBox.Checked = _settings.ProxyTestFullLog;
776 |
777 | _appListBox.Items.Clear();
778 | if (_settings.ProxifiedApps != null) {
779 | foreach (string app in _settings.ProxifiedApps) {
780 | _appListBox.Items.Add(app);
781 | }
782 | }
783 | }
784 |
785 | private void SettingsForm_FormClosing(object sender, FormClosingEventArgs e) {
786 | if (_proxyTestManager.IsTesting) {
787 | _proxyTestManager.StopTesting();
788 | _proxyTestManager = null;
789 | }
790 | }
791 |
792 | private void OkButton_Click(object sender, EventArgs e) {
793 | _settings.ByeDpiPath = _byeDpiPathTextBox.Text;
794 | _settings.Hotkey = _hotkeyTextBox.Text;
795 | _settings.ByeDpiArguments = _byeDpiArgsTextBox.Text;
796 | _settings.DisableProxiFyre = _disableProxiFyreCheckBox.Checked;
797 | _settings.ProxiFyrePath = _proxiFyrePathTextBox.Text;
798 | _settings.ProxiFyrePort = (int)_proxiFyrePortNumBox.Value;
799 | _settings.ProxifiedApps.Clear();
800 |
801 | foreach (string app in _appListBox.Items) {
802 | _settings.ProxifiedApps.Add(app);
803 | }
804 |
805 | _settings.AutoStart = _autoStartCheckBox.Checked;
806 | _settings.AutoConnect = _autoConnectCheckBox.Checked;
807 | _settings.StartMinimized = _StartMinimizedCheckBox.Checked;
808 |
809 | _settings.ProxyTestDelay = (int)_delayNumericUpDown.Value;
810 | _settings.ProxyTestRequestsCount = (int)_requestsCountNumericUpDown.Value;
811 | _settings.ProxyTestFullLog = _fullLogCheckBox.Checked;
812 |
813 | _autorunManager.SetAutorun(_settings.AutoStart);
814 | }
815 |
816 | private void BrowseForExe(TextBox targetTextBox, string title) {
817 | using (OpenFileDialog dialog = new OpenFileDialog()) {
818 | dialog.Filter = "*.exe|*.exe|*.*|*.*";
819 | dialog.Title = title;
820 |
821 | if (dialog.ShowDialog() == DialogResult.OK) {
822 | targetTextBox.Text = dialog.FileName;
823 | }
824 | }
825 | }
826 |
827 | private void AddAppToList(string appPath) {
828 | string appName = appPath.Trim();
829 |
830 | if (!_appListBox.Items.Contains(appName)) {
831 | _appListBox.Items.Add(appName);
832 | _appTextBox.Clear();
833 | }
834 | else {
835 | MessageBox.Show(
836 | Program.localization.GetString("settings_form.apps.already_added"),
837 | Program.localization.GetString("settings_form.title"),
838 | MessageBoxButtons.OK,
839 | MessageBoxIcon.Information
840 | );
841 | }
842 | }
843 |
844 | private void AddAppButton_Click(object sender, EventArgs e) {
845 | if (!string.IsNullOrWhiteSpace(_appTextBox.Text)) {
846 | AddAppToList(_appTextBox.Text);
847 | }
848 | }
849 |
850 | private void RemoveAppButton_Click(object sender, EventArgs e) {
851 | if (_appListBox.SelectedIndex >= 0) {
852 | _appListBox.Items.RemoveAt(_appListBox.SelectedIndex);
853 | }
854 | }
855 |
856 | private void EditDomainsButton_Click(object sender, EventArgs e) {
857 | try {
858 | Directory.CreateDirectory(ProxyTestManager.PROXY_TEST_FOLDER);
859 |
860 | if (!File.Exists(ProxyTestManager.PROXY_TEST_SITES)) {
861 | File.WriteAllText(ProxyTestManager.PROXY_TEST_SITES, "");
862 | }
863 |
864 | System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo {
865 | FileName = ProxyTestManager.PROXY_TEST_SITES,
866 | UseShellExecute = true
867 | });
868 | }
869 | catch (Exception) {
870 | Program.logger.Log(Program.localization.GetString("proxy_test.sites_file_read_error"));
871 | }
872 | }
873 |
874 | private void EditCommandsButton_Click(object sender, EventArgs e) {
875 | try {
876 | Directory.CreateDirectory(ProxyTestManager.PROXY_TEST_FOLDER);
877 |
878 | if (!File.Exists(ProxyTestManager.PROXY_TEST_CMDS)) {
879 | File.WriteAllText(ProxyTestManager.PROXY_TEST_CMDS, "");
880 | }
881 |
882 | System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo {
883 | FileName = ProxyTestManager.PROXY_TEST_CMDS,
884 | UseShellExecute = true
885 | });
886 | }
887 | catch (Exception) {
888 | Program.logger.Log(Program.localization.GetString("proxy_test.cmds_file_not_found"));
889 | }
890 | }
891 | }
892 | }
893 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 3, 29 June 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 | Preamble
9 |
10 | The GNU General Public License is a free, copyleft license for
11 | software and other kinds of works.
12 |
13 | The licenses for most software and other practical works are designed
14 | to take away your freedom to share and change the works. By contrast,
15 | the GNU General Public License is intended to guarantee your freedom to
16 | share and change all versions of a program--to make sure it remains free
17 | software for all its users. We, the Free Software Foundation, use the
18 | GNU General Public License for most of our software; it applies also to
19 | any other work released this way by its authors. You can apply it to
20 | your programs, too.
21 |
22 | When we speak of free software, we are referring to freedom, not
23 | price. Our General Public Licenses are designed to make sure that you
24 | have the freedom to distribute copies of free software (and charge for
25 | them if you wish), that you receive source code or can get it if you
26 | want it, that you can change the software or use pieces of it in new
27 | free programs, and that you know you can do these things.
28 |
29 | To protect your rights, we need to prevent others from denying you
30 | these rights or asking you to surrender the rights. Therefore, you have
31 | certain responsibilities if you distribute copies of the software, or if
32 | you modify it: responsibilities to respect the freedom of others.
33 |
34 | For example, if you distribute copies of such a program, whether
35 | gratis or for a fee, you must pass on to the recipients the same
36 | freedoms that you received. You must make sure that they, too, receive
37 | or can get the source code. And you must show them these terms so they
38 | know their rights.
39 |
40 | Developers that use the GNU GPL protect your rights with two steps:
41 | (1) assert copyright on the software, and (2) offer you this License
42 | giving you legal permission to copy, distribute and/or modify it.
43 |
44 | For the developers' and authors' protection, the GPL clearly explains
45 | that there is no warranty for this free software. For both users' and
46 | authors' sake, the GPL requires that modified versions be marked as
47 | changed, so that their problems will not be attributed erroneously to
48 | authors of previous versions.
49 |
50 | Some devices are designed to deny users access to install or run
51 | modified versions of the software inside them, although the manufacturer
52 | can do so. This is fundamentally incompatible with the aim of
53 | protecting users' freedom to change the software. The systematic
54 | pattern of such abuse occurs in the area of products for individuals to
55 | use, which is precisely where it is most unacceptable. Therefore, we
56 | have designed this version of the GPL to prohibit the practice for those
57 | products. If such problems arise substantially in other domains, we
58 | stand ready to extend this provision to those domains in future versions
59 | of the GPL, as needed to protect the freedom of users.
60 |
61 | Finally, every program is threatened constantly by software patents.
62 | States should not allow patents to restrict development and use of
63 | software on general-purpose computers, but in those that do, we wish to
64 | avoid the special danger that patents applied to a free program could
65 | make it effectively proprietary. To prevent this, the GPL assures that
66 | patents cannot be used to render the program non-free.
67 |
68 | The precise terms and conditions for copying, distribution and
69 | modification follow.
70 |
71 | TERMS AND CONDITIONS
72 |
73 | 0. Definitions.
74 |
75 | "This License" refers to version 3 of the GNU General Public License.
76 |
77 | "Copyright" also means copyright-like laws that apply to other kinds of
78 | works, such as semiconductor masks.
79 |
80 | "The Program" refers to any copyrightable work licensed under this
81 | License. Each licensee is addressed as "you". "Licensees" and
82 | "recipients" may be individuals or organizations.
83 |
84 | To "modify" a work means to copy from or adapt all or part of the work
85 | in a fashion requiring copyright permission, other than the making of an
86 | exact copy. The resulting work is called a "modified version" of the
87 | earlier work or a work "based on" the earlier work.
88 |
89 | A "covered work" means either the unmodified Program or a work based
90 | on the Program.
91 |
92 | To "propagate" a work means to do anything with it that, without
93 | permission, would make you directly or secondarily liable for
94 | infringement under applicable copyright law, except executing it on a
95 | computer or modifying a private copy. Propagation includes copying,
96 | distribution (with or without modification), making available to the
97 | public, and in some countries other activities as well.
98 |
99 | To "convey" a work means any kind of propagation that enables other
100 | parties to make or receive copies. Mere interaction with a user through
101 | a computer network, with no transfer of a copy, is not conveying.
102 |
103 | An interactive user interface displays "Appropriate Legal Notices"
104 | to the extent that it includes a convenient and prominently visible
105 | feature that (1) displays an appropriate copyright notice, and (2)
106 | tells the user that there is no warranty for the work (except to the
107 | extent that warranties are provided), that licensees may convey the
108 | work under this License, and how to view a copy of this License. If
109 | the interface presents a list of user commands or options, such as a
110 | menu, a prominent item in the list meets this criterion.
111 |
112 | 1. Source Code.
113 |
114 | The "source code" for a work means the preferred form of the work
115 | for making modifications to it. "Object code" means any non-source
116 | form of a work.
117 |
118 | A "Standard Interface" means an interface that either is an official
119 | standard defined by a recognized standards body, or, in the case of
120 | interfaces specified for a particular programming language, one that
121 | is widely used among developers working in that language.
122 |
123 | The "System Libraries" of an executable work include anything, other
124 | than the work as a whole, that (a) is included in the normal form of
125 | packaging a Major Component, but which is not part of that Major
126 | Component, and (b) serves only to enable use of the work with that
127 | Major Component, or to implement a Standard Interface for which an
128 | implementation is available to the public in source code form. A
129 | "Major Component", in this context, means a major essential component
130 | (kernel, window system, and so on) of the specific operating system
131 | (if any) on which the executable work runs, or a compiler used to
132 | produce the work, or an object code interpreter used to run it.
133 |
134 | The "Corresponding Source" for a work in object code form means all
135 | the source code needed to generate, install, and (for an executable
136 | work) run the object code and to modify the work, including scripts to
137 | control those activities. However, it does not include the work's
138 | System Libraries, or general-purpose tools or generally available free
139 | programs which are used unmodified in performing those activities but
140 | which are not part of the work. For example, Corresponding Source
141 | includes interface definition files associated with source files for
142 | the work, and the source code for shared libraries and dynamically
143 | linked subprograms that the work is specifically designed to require,
144 | such as by intimate data communication or control flow between those
145 | subprograms and other parts of the work.
146 |
147 | The Corresponding Source need not include anything that users
148 | can regenerate automatically from other parts of the Corresponding
149 | Source.
150 |
151 | The Corresponding Source for a work in source code form is that
152 | same work.
153 |
154 | 2. Basic Permissions.
155 |
156 | All rights granted under this License are granted for the term of
157 | copyright on the Program, and are irrevocable provided the stated
158 | conditions are met. This License explicitly affirms your unlimited
159 | permission to run the unmodified Program. The output from running a
160 | covered work is covered by this License only if the output, given its
161 | content, constitutes a covered work. This License acknowledges your
162 | rights of fair use or other equivalent, as provided by copyright law.
163 |
164 | You may make, run and propagate covered works that you do not
165 | convey, without conditions so long as your license otherwise remains
166 | in force. You may convey covered works to others for the sole purpose
167 | of having them make modifications exclusively for you, or provide you
168 | with facilities for running those works, provided that you comply with
169 | the terms of this License in conveying all material for which you do
170 | not control copyright. Those thus making or running the covered works
171 | for you must do so exclusively on your behalf, under your direction
172 | and control, on terms that prohibit them from making any copies of
173 | your copyrighted material outside their relationship with you.
174 |
175 | Conveying under any other circumstances is permitted solely under
176 | the conditions stated below. Sublicensing is not allowed; section 10
177 | makes it unnecessary.
178 |
179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180 |
181 | No covered work shall be deemed part of an effective technological
182 | measure under any applicable law fulfilling obligations under article
183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or
184 | similar laws prohibiting or restricting circumvention of such
185 | measures.
186 |
187 | When you convey a covered work, you waive any legal power to forbid
188 | circumvention of technological measures to the extent such circumvention
189 | is effected by exercising rights under this License with respect to
190 | the covered work, and you disclaim any intention to limit operation or
191 | modification of the work as a means of enforcing, against the work's
192 | users, your or third parties' legal rights to forbid circumvention of
193 | technological measures.
194 |
195 | 4. Conveying Verbatim Copies.
196 |
197 | You may convey verbatim copies of the Program's source code as you
198 | receive it, in any medium, provided that you conspicuously and
199 | appropriately publish on each copy an appropriate copyright notice;
200 | keep intact all notices stating that this License and any
201 | non-permissive terms added in accord with section 7 apply to the code;
202 | keep intact all notices of the absence of any warranty; and give all
203 | recipients a copy of this License along with the Program.
204 |
205 | You may charge any price or no price for each copy that you convey,
206 | and you may offer support or warranty protection for a fee.
207 |
208 | 5. Conveying Modified Source Versions.
209 |
210 | You may convey a work based on the Program, or the modifications to
211 | produce it from the Program, in the form of source code under the
212 | terms of section 4, provided that you also meet all of these conditions:
213 |
214 | a) The work must carry prominent notices stating that you modified
215 | it, and giving a relevant date.
216 |
217 | b) The work must carry prominent notices stating that it is
218 | released under this License and any conditions added under section
219 | 7. This requirement modifies the requirement in section 4 to
220 | "keep intact all notices".
221 |
222 | c) You must license the entire work, as a whole, under this
223 | License to anyone who comes into possession of a copy. This
224 | License will therefore apply, along with any applicable section 7
225 | additional terms, to the whole of the work, and all its parts,
226 | regardless of how they are packaged. This License gives no
227 | permission to license the work in any other way, but it does not
228 | invalidate such permission if you have separately received it.
229 |
230 | d) If the work has interactive user interfaces, each must display
231 | Appropriate Legal Notices; however, if the Program has interactive
232 | interfaces that do not display Appropriate Legal Notices, your
233 | work need not make them do so.
234 |
235 | A compilation of a covered work with other separate and independent
236 | works, which are not by their nature extensions of the covered work,
237 | and which are not combined with it such as to form a larger program,
238 | in or on a volume of a storage or distribution medium, is called an
239 | "aggregate" if the compilation and its resulting copyright are not
240 | used to limit the access or legal rights of the compilation's users
241 | beyond what the individual works permit. Inclusion of a covered work
242 | in an aggregate does not cause this License to apply to the other
243 | parts of the aggregate.
244 |
245 | 6. Conveying Non-Source Forms.
246 |
247 | You may convey a covered work in object code form under the terms
248 | of sections 4 and 5, provided that you also convey the
249 | machine-readable Corresponding Source under the terms of this License,
250 | in one of these ways:
251 |
252 | a) Convey the object code in, or embodied in, a physical product
253 | (including a physical distribution medium), accompanied by the
254 | Corresponding Source fixed on a durable physical medium
255 | customarily used for software interchange.
256 |
257 | b) Convey the object code in, or embodied in, a physical product
258 | (including a physical distribution medium), accompanied by a
259 | written offer, valid for at least three years and valid for as
260 | long as you offer spare parts or customer support for that product
261 | model, to give anyone who possesses the object code either (1) a
262 | copy of the Corresponding Source for all the software in the
263 | product that is covered by this License, on a durable physical
264 | medium customarily used for software interchange, for a price no
265 | more than your reasonable cost of physically performing this
266 | conveying of source, or (2) access to copy the
267 | Corresponding Source from a network server at no charge.
268 |
269 | c) Convey individual copies of the object code with a copy of the
270 | written offer to provide the Corresponding Source. This
271 | alternative is allowed only occasionally and noncommercially, and
272 | only if you received the object code with such an offer, in accord
273 | with subsection 6b.
274 |
275 | d) Convey the object code by offering access from a designated
276 | place (gratis or for a charge), and offer equivalent access to the
277 | Corresponding Source in the same way through the same place at no
278 | further charge. You need not require recipients to copy the
279 | Corresponding Source along with the object code. If the place to
280 | copy the object code is a network server, the Corresponding Source
281 | may be on a different server (operated by you or a third party)
282 | that supports equivalent copying facilities, provided you maintain
283 | clear directions next to the object code saying where to find the
284 | Corresponding Source. Regardless of what server hosts the
285 | Corresponding Source, you remain obligated to ensure that it is
286 | available for as long as needed to satisfy these requirements.
287 |
288 | e) Convey the object code using peer-to-peer transmission, provided
289 | you inform other peers where the object code and Corresponding
290 | Source of the work are being offered to the general public at no
291 | charge under subsection 6d.
292 |
293 | A separable portion of the object code, whose source code is excluded
294 | from the Corresponding Source as a System Library, need not be
295 | included in conveying the object code work.
296 |
297 | A "User Product" is either (1) a "consumer product", which means any
298 | tangible personal property which is normally used for personal, family,
299 | or household purposes, or (2) anything designed or sold for incorporation
300 | into a dwelling. In determining whether a product is a consumer product,
301 | doubtful cases shall be resolved in favor of coverage. For a particular
302 | product received by a particular user, "normally used" refers to a
303 | typical or common use of that class of product, regardless of the status
304 | of the particular user or of the way in which the particular user
305 | actually uses, or expects or is expected to use, the product. A product
306 | is a consumer product regardless of whether the product has substantial
307 | commercial, industrial or non-consumer uses, unless such uses represent
308 | the only significant mode of use of the product.
309 |
310 | "Installation Information" for a User Product means any methods,
311 | procedures, authorization keys, or other information required to install
312 | and execute modified versions of a covered work in that User Product from
313 | a modified version of its Corresponding Source. The information must
314 | suffice to ensure that the continued functioning of the modified object
315 | code is in no case prevented or interfered with solely because
316 | modification has been made.
317 |
318 | If you convey an object code work under this section in, or with, or
319 | specifically for use in, a User Product, and the conveying occurs as
320 | part of a transaction in which the right of possession and use of the
321 | User Product is transferred to the recipient in perpetuity or for a
322 | fixed term (regardless of how the transaction is characterized), the
323 | Corresponding Source conveyed under this section must be accompanied
324 | by the Installation Information. But this requirement does not apply
325 | if neither you nor any third party retains the ability to install
326 | modified object code on the User Product (for example, the work has
327 | been installed in ROM).
328 |
329 | The requirement to provide Installation Information does not include a
330 | requirement to continue to provide support service, warranty, or updates
331 | for a work that has been modified or installed by the recipient, or for
332 | the User Product in which it has been modified or installed. Access to a
333 | network may be denied when the modification itself materially and
334 | adversely affects the operation of the network or violates the rules and
335 | protocols for communication across the network.
336 |
337 | Corresponding Source conveyed, and Installation Information provided,
338 | in accord with this section must be in a format that is publicly
339 | documented (and with an implementation available to the public in
340 | source code form), and must require no special password or key for
341 | unpacking, reading or copying.
342 |
343 | 7. Additional Terms.
344 |
345 | "Additional permissions" are terms that supplement the terms of this
346 | License by making exceptions from one or more of its conditions.
347 | Additional permissions that are applicable to the entire Program shall
348 | be treated as though they were included in this License, to the extent
349 | that they are valid under applicable law. If additional permissions
350 | apply only to part of the Program, that part may be used separately
351 | under those permissions, but the entire Program remains governed by
352 | this License without regard to the additional permissions.
353 |
354 | When you convey a copy of a covered work, you may at your option
355 | remove any additional permissions from that copy, or from any part of
356 | it. (Additional permissions may be written to require their own
357 | removal in certain cases when you modify the work.) You may place
358 | additional permissions on material, added by you to a covered work,
359 | for which you have or can give appropriate copyright permission.
360 |
361 | Notwithstanding any other provision of this License, for material you
362 | add to a covered work, you may (if authorized by the copyright holders of
363 | that material) supplement the terms of this License with terms:
364 |
365 | a) Disclaiming warranty or limiting liability differently from the
366 | terms of sections 15 and 16 of this License; or
367 |
368 | b) Requiring preservation of specified reasonable legal notices or
369 | author attributions in that material or in the Appropriate Legal
370 | Notices displayed by works containing it; or
371 |
372 | c) Prohibiting misrepresentation of the origin of that material, or
373 | requiring that modified versions of such material be marked in
374 | reasonable ways as different from the original version; or
375 |
376 | d) Limiting the use for publicity purposes of names of licensors or
377 | authors of the material; or
378 |
379 | e) Declining to grant rights under trademark law for use of some
380 | trade names, trademarks, or service marks; or
381 |
382 | f) Requiring indemnification of licensors and authors of that
383 | material by anyone who conveys the material (or modified versions of
384 | it) with contractual assumptions of liability to the recipient, for
385 | any liability that these contractual assumptions directly impose on
386 | those licensors and authors.
387 |
388 | All other non-permissive additional terms are considered "further
389 | restrictions" within the meaning of section 10. If the Program as you
390 | received it, or any part of it, contains a notice stating that it is
391 | governed by this License along with a term that is a further
392 | restriction, you may remove that term. If a license document contains
393 | a further restriction but permits relicensing or conveying under this
394 | License, you may add to a covered work material governed by the terms
395 | of that license document, provided that the further restriction does
396 | not survive such relicensing or conveying.
397 |
398 | If you add terms to a covered work in accord with this section, you
399 | must place, in the relevant source files, a statement of the
400 | additional terms that apply to those files, or a notice indicating
401 | where to find the applicable terms.
402 |
403 | Additional terms, permissive or non-permissive, may be stated in the
404 | form of a separately written license, or stated as exceptions;
405 | the above requirements apply either way.
406 |
407 | 8. Termination.
408 |
409 | You may not propagate or modify a covered work except as expressly
410 | provided under this License. Any attempt otherwise to propagate or
411 | modify it is void, and will automatically terminate your rights under
412 | this License (including any patent licenses granted under the third
413 | paragraph of section 11).
414 |
415 | However, if you cease all violation of this License, then your
416 | license from a particular copyright holder is reinstated (a)
417 | provisionally, unless and until the copyright holder explicitly and
418 | finally terminates your license, and (b) permanently, if the copyright
419 | holder fails to notify you of the violation by some reasonable means
420 | prior to 60 days after the cessation.
421 |
422 | Moreover, your license from a particular copyright holder is
423 | reinstated permanently if the copyright holder notifies you of the
424 | violation by some reasonable means, this is the first time you have
425 | received notice of violation of this License (for any work) from that
426 | copyright holder, and you cure the violation prior to 30 days after
427 | your receipt of the notice.
428 |
429 | Termination of your rights under this section does not terminate the
430 | licenses of parties who have received copies or rights from you under
431 | this License. If your rights have been terminated and not permanently
432 | reinstated, you do not qualify to receive new licenses for the same
433 | material under section 10.
434 |
435 | 9. Acceptance Not Required for Having Copies.
436 |
437 | You are not required to accept this License in order to receive or
438 | run a copy of the Program. Ancillary propagation of a covered work
439 | occurring solely as a consequence of using peer-to-peer transmission
440 | to receive a copy likewise does not require acceptance. However,
441 | nothing other than this License grants you permission to propagate or
442 | modify any covered work. These actions infringe copyright if you do
443 | not accept this License. Therefore, by modifying or propagating a
444 | covered work, you indicate your acceptance of this License to do so.
445 |
446 | 10. Automatic Licensing of Downstream Recipients.
447 |
448 | Each time you convey a covered work, the recipient automatically
449 | receives a license from the original licensors, to run, modify and
450 | propagate that work, subject to this License. You are not responsible
451 | for enforcing compliance by third parties with this License.
452 |
453 | An "entity transaction" is a transaction transferring control of an
454 | organization, or substantially all assets of one, or subdividing an
455 | organization, or merging organizations. If propagation of a covered
456 | work results from an entity transaction, each party to that
457 | transaction who receives a copy of the work also receives whatever
458 | licenses to the work the party's predecessor in interest had or could
459 | give under the previous paragraph, plus a right to possession of the
460 | Corresponding Source of the work from the predecessor in interest, if
461 | the predecessor has it or can get it with reasonable efforts.
462 |
463 | You may not impose any further restrictions on the exercise of the
464 | rights granted or affirmed under this License. For example, you may
465 | not impose a license fee, royalty, or other charge for exercise of
466 | rights granted under this License, and you may not initiate litigation
467 | (including a cross-claim or counterclaim in a lawsuit) alleging that
468 | any patent claim is infringed by making, using, selling, offering for
469 | sale, or importing the Program or any portion of it.
470 |
471 | 11. Patents.
472 |
473 | A "contributor" is a copyright holder who authorizes use under this
474 | License of the Program or a work on which the Program is based. The
475 | work thus licensed is called the contributor's "contributor version".
476 |
477 | A contributor's "essential patent claims" are all patent claims
478 | owned or controlled by the contributor, whether already acquired or
479 | hereafter acquired, that would be infringed by some manner, permitted
480 | by this License, of making, using, or selling its contributor version,
481 | but do not include claims that would be infringed only as a
482 | consequence of further modification of the contributor version. For
483 | purposes of this definition, "control" includes the right to grant
484 | patent sublicenses in a manner consistent with the requirements of
485 | this License.
486 |
487 | Each contributor grants you a non-exclusive, worldwide, royalty-free
488 | patent license under the contributor's essential patent claims, to
489 | make, use, sell, offer for sale, import and otherwise run, modify and
490 | propagate the contents of its contributor version.
491 |
492 | In the following three paragraphs, a "patent license" is any express
493 | agreement or commitment, however denominated, not to enforce a patent
494 | (such as an express permission to practice a patent or covenant not to
495 | sue for patent infringement). To "grant" such a patent license to a
496 | party means to make such an agreement or commitment not to enforce a
497 | patent against the party.
498 |
499 | If you convey a covered work, knowingly relying on a patent license,
500 | and the Corresponding Source of the work is not available for anyone
501 | to copy, free of charge and under the terms of this License, through a
502 | publicly available network server or other readily accessible means,
503 | then you must either (1) cause the Corresponding Source to be so
504 | available, or (2) arrange to deprive yourself of the benefit of the
505 | patent license for this particular work, or (3) arrange, in a manner
506 | consistent with the requirements of this License, to extend the patent
507 | license to downstream recipients. "Knowingly relying" means you have
508 | actual knowledge that, but for the patent license, your conveying the
509 | covered work in a country, or your recipient's use of the covered work
510 | in a country, would infringe one or more identifiable patents in that
511 | country that you have reason to believe are valid.
512 |
513 | If, pursuant to or in connection with a single transaction or
514 | arrangement, you convey, or propagate by procuring conveyance of, a
515 | covered work, and grant a patent license to some of the parties
516 | receiving the covered work authorizing them to use, propagate, modify
517 | or convey a specific copy of the covered work, then the patent license
518 | you grant is automatically extended to all recipients of the covered
519 | work and works based on it.
520 |
521 | A patent license is "discriminatory" if it does not include within
522 | the scope of its coverage, prohibits the exercise of, or is
523 | conditioned on the non-exercise of one or more of the rights that are
524 | specifically granted under this License. You may not convey a covered
525 | work if you are a party to an arrangement with a third party that is
526 | in the business of distributing software, under which you make payment
527 | to the third party based on the extent of your activity of conveying
528 | the work, and under which the third party grants, to any of the
529 | parties who would receive the covered work from you, a discriminatory
530 | patent license (a) in connection with copies of the covered work
531 | conveyed by you (or copies made from those copies), or (b) primarily
532 | for and in connection with specific products or compilations that
533 | contain the covered work, unless you entered into that arrangement,
534 | or that patent license was granted, prior to 28 March 2007.
535 |
536 | Nothing in this License shall be construed as excluding or limiting
537 | any implied license or other defenses to infringement that may
538 | otherwise be available to you under applicable patent law.
539 |
540 | 12. No Surrender of Others' Freedom.
541 |
542 | If conditions are imposed on you (whether by court order, agreement or
543 | otherwise) that contradict the conditions of this License, they do not
544 | excuse you from the conditions of this License. If you cannot convey a
545 | covered work so as to satisfy simultaneously your obligations under this
546 | License and any other pertinent obligations, then as a consequence you may
547 | not convey it at all. For example, if you agree to terms that obligate you
548 | to collect a royalty for further conveying from those to whom you convey
549 | the Program, the only way you could satisfy both those terms and this
550 | License would be to refrain entirely from conveying the Program.
551 |
552 | 13. Use with the GNU Affero General Public License.
553 |
554 | Notwithstanding any other provision of this License, you have
555 | permission to link or combine any covered work with a work licensed
556 | under version 3 of the GNU Affero General Public License into a single
557 | combined work, and to convey the resulting work. The terms of this
558 | License will continue to apply to the part which is the covered work,
559 | but the special requirements of the GNU Affero General Public License,
560 | section 13, concerning interaction through a network will apply to the
561 | combination as such.
562 |
563 | 14. Revised Versions of this License.
564 |
565 | The Free Software Foundation may publish revised and/or new versions of
566 | the GNU General Public License from time to time. Such new versions will
567 | be similar in spirit to the present version, but may differ in detail to
568 | address new problems or concerns.
569 |
570 | Each version is given a distinguishing version number. If the
571 | Program specifies that a certain numbered version of the GNU General
572 | Public License "or any later version" applies to it, you have the
573 | option of following the terms and conditions either of that numbered
574 | version or of any later version published by the Free Software
575 | Foundation. If the Program does not specify a version number of the
576 | GNU General Public License, you may choose any version ever published
577 | by the Free Software Foundation.
578 |
579 | If the Program specifies that a proxy can decide which future
580 | versions of the GNU General Public License can be used, that proxy's
581 | public statement of acceptance of a version permanently authorizes you
582 | to choose that version for the Program.
583 |
584 | Later license versions may give you additional or different
585 | permissions. However, no additional obligations are imposed on any
586 | author or copyright holder as a result of your choosing to follow a
587 | later version.
588 |
589 | 15. Disclaimer of Warranty.
590 |
591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599 |
600 | 16. Limitation of Liability.
601 |
602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610 | SUCH DAMAGES.
611 |
612 | 17. Interpretation of Sections 15 and 16.
613 |
614 | If the disclaimer of warranty and limitation of liability provided
615 | above cannot be given local legal effect according to their terms,
616 | reviewing courts shall apply local law that most closely approximates
617 | an absolute waiver of all civil liability in connection with the
618 | Program, unless a warranty or assumption of liability accompanies a
619 | copy of the Program in return for a fee.
620 |
621 | END OF TERMS AND CONDITIONS
622 |
623 | How to Apply These Terms to Your New Programs
624 |
625 | If you develop a new program, and you want it to be of the greatest
626 | possible use to the public, the best way to achieve this is to make it
627 | free software which everyone can redistribute and change under these terms.
628 |
629 | To do so, attach the following notices to the program. It is safest
630 | to attach them to the start of each source file to most effectively
631 | state the exclusion of warranty; and each file should have at least
632 | the "copyright" line and a pointer to where the full notice is found.
633 |
634 |
635 | Copyright (C)
636 |
637 | This program is free software: you can redistribute it and/or modify
638 | it under the terms of the GNU General Public License as published by
639 | the Free Software Foundation, either version 3 of the License, or
640 | (at your option) any later version.
641 |
642 | This program is distributed in the hope that it will be useful,
643 | but WITHOUT ANY WARRANTY; without even the implied warranty of
644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
645 | GNU General Public License for more details.
646 |
647 | You should have received a copy of the GNU General Public License
648 | along with this program. If not, see .
649 |
650 | Also add information on how to contact you by electronic and paper mail.
651 |
652 | If the program does terminal interaction, make it output a short
653 | notice like this when it starts in an interactive mode:
654 |
655 | Copyright (C)
656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657 | This is free software, and you are welcome to redistribute it
658 | under certain conditions; type `show c' for details.
659 |
660 | The hypothetical commands `show w' and `show c' should show the appropriate
661 | parts of the General Public License. Of course, your program's commands
662 | might be different; for a GUI interface, you would use an "about box".
663 |
664 | You should also get your employer (if you work as a programmer) or school,
665 | if any, to sign a "copyright disclaimer" for the program, if necessary.
666 | For more information on this, and how to apply and follow the GNU GPL, see
667 | .
668 |
669 | The GNU General Public License does not permit incorporating your program
670 | into proprietary programs. If your program is a subroutine library, you
671 | may consider it more useful to permit linking proprietary applications with
672 | the library. If this is what you want to do, use the GNU Lesser General
673 | Public License instead of this License. But first, please read
674 | .
675 |
--------------------------------------------------------------------------------