mirror of
https://github.com/netchx/netch.git
synced 2026-05-11 23:45:06 +08:00
Add Trojan Support
This commit is contained in:
12
Netch/Forms/MainForm.Designer.cs
generated
12
Netch/Forms/MainForm.Designer.cs
generated
@@ -86,6 +86,7 @@ namespace Netch.Forms
|
||||
this.SettingsButton = new System.Windows.Forms.Button();
|
||||
this.ProfileGroupBox = new System.Windows.Forms.GroupBox();
|
||||
this.ProfileTable = new System.Windows.Forms.TableLayoutPanel();
|
||||
this.AddTrojanServerToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.MenuStrip.SuspendLayout();
|
||||
this.ConfigurationGroupBox.SuspendLayout();
|
||||
this.configLayoutPanel.SuspendLayout();
|
||||
@@ -127,7 +128,8 @@ namespace Netch.Forms
|
||||
this.AddSocks5ServerToolStripMenuItem,
|
||||
this.AddShadowsocksServerToolStripMenuItem,
|
||||
this.AddShadowsocksRServerToolStripMenuItem,
|
||||
this.AddVMessServerToolStripMenuItem});
|
||||
this.AddVMessServerToolStripMenuItem,
|
||||
this.AddTrojanServerToolStripMenuItem});
|
||||
this.ServerToolStripMenuItem.Margin = new System.Windows.Forms.Padding(3, 0, 0, 1);
|
||||
this.ServerToolStripMenuItem.Name = "ServerToolStripMenuItem";
|
||||
this.ServerToolStripMenuItem.Size = new System.Drawing.Size(57, 21);
|
||||
@@ -638,6 +640,13 @@ namespace Netch.Forms
|
||||
this.ProfileTable.Size = new System.Drawing.Size(599, 43);
|
||||
this.ProfileTable.TabIndex = 0;
|
||||
//
|
||||
// AddTrojanServerToolStripMenuItem
|
||||
//
|
||||
this.AddTrojanServerToolStripMenuItem.Name = "AddTrojanServerToolStripMenuItem";
|
||||
this.AddTrojanServerToolStripMenuItem.Size = new System.Drawing.Size(259, 22);
|
||||
this.AddTrojanServerToolStripMenuItem.Text = "Add [Trojan] Server";
|
||||
this.AddTrojanServerToolStripMenuItem.Click += new System.EventHandler(this.AddTrojanServerToolStripMenuItem_Click);
|
||||
//
|
||||
// MainForm
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
|
||||
@@ -738,5 +747,6 @@ namespace Netch.Forms
|
||||
private System.Windows.Forms.ToolStripMenuItem exitToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem updateACLWithProxyToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem reinstallTapDriverToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem AddTrojanServerToolStripMenuItem;
|
||||
}
|
||||
}
|
||||
@@ -493,6 +493,12 @@ namespace Netch.Forms
|
||||
Hide();
|
||||
}
|
||||
|
||||
private void AddTrojanServerToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
new Server.Trojan().Show();
|
||||
Hide();
|
||||
}
|
||||
|
||||
private void CreateProcessModeToolStripButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
new Mode.Process().Show();
|
||||
|
||||
176
Netch/Forms/Server/Trojan.Designer.cs
generated
Normal file
176
Netch/Forms/Server/Trojan.Designer.cs
generated
Normal file
@@ -0,0 +1,176 @@
|
||||
namespace Netch.Forms.Server
|
||||
{
|
||||
partial class Trojan
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Trojan));
|
||||
this.ConfigurationGroupBox = new System.Windows.Forms.GroupBox();
|
||||
this.PasswordTextBox = new System.Windows.Forms.TextBox();
|
||||
this.PasswordLabel = new System.Windows.Forms.Label();
|
||||
this.AddressLabel = new System.Windows.Forms.Label();
|
||||
this.PortTextBox = new System.Windows.Forms.TextBox();
|
||||
this.AddressTextBox = new System.Windows.Forms.TextBox();
|
||||
this.RemarkTextBox = new System.Windows.Forms.TextBox();
|
||||
this.RemarkLabel = new System.Windows.Forms.Label();
|
||||
this.PortLabel = new System.Windows.Forms.Label();
|
||||
this.ControlButton = new System.Windows.Forms.Button();
|
||||
this.ConfigurationGroupBox.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// ConfigurationGroupBox
|
||||
//
|
||||
this.ConfigurationGroupBox.Controls.Add(this.PasswordTextBox);
|
||||
this.ConfigurationGroupBox.Controls.Add(this.PasswordLabel);
|
||||
this.ConfigurationGroupBox.Controls.Add(this.AddressLabel);
|
||||
this.ConfigurationGroupBox.Controls.Add(this.PortTextBox);
|
||||
this.ConfigurationGroupBox.Controls.Add(this.AddressTextBox);
|
||||
this.ConfigurationGroupBox.Controls.Add(this.RemarkTextBox);
|
||||
this.ConfigurationGroupBox.Controls.Add(this.RemarkLabel);
|
||||
this.ConfigurationGroupBox.Controls.Add(this.PortLabel);
|
||||
this.ConfigurationGroupBox.Location = new System.Drawing.Point(12, 12);
|
||||
this.ConfigurationGroupBox.Name = "ConfigurationGroupBox";
|
||||
this.ConfigurationGroupBox.Size = new System.Drawing.Size(420, 109);
|
||||
this.ConfigurationGroupBox.TabIndex = 0;
|
||||
this.ConfigurationGroupBox.TabStop = false;
|
||||
this.ConfigurationGroupBox.Text = "Configuration";
|
||||
//
|
||||
// PasswordTextBox
|
||||
//
|
||||
this.PasswordTextBox.Location = new System.Drawing.Point(120, 77);
|
||||
this.PasswordTextBox.Name = "PasswordTextBox";
|
||||
this.PasswordTextBox.Size = new System.Drawing.Size(294, 23);
|
||||
this.PasswordTextBox.TabIndex = 7;
|
||||
this.PasswordTextBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
|
||||
//
|
||||
// PasswordLabel
|
||||
//
|
||||
this.PasswordLabel.AutoSize = true;
|
||||
this.PasswordLabel.Location = new System.Drawing.Point(10, 80);
|
||||
this.PasswordLabel.Name = "PasswordLabel";
|
||||
this.PasswordLabel.Size = new System.Drawing.Size(64, 17);
|
||||
this.PasswordLabel.TabIndex = 6;
|
||||
this.PasswordLabel.Text = "Password";
|
||||
//
|
||||
// AddressLabel
|
||||
//
|
||||
this.AddressLabel.AutoSize = true;
|
||||
this.AddressLabel.Location = new System.Drawing.Point(10, 51);
|
||||
this.AddressLabel.Name = "AddressLabel";
|
||||
this.AddressLabel.Size = new System.Drawing.Size(56, 17);
|
||||
this.AddressLabel.TabIndex = 2;
|
||||
this.AddressLabel.Text = "Address";
|
||||
//
|
||||
// PortTextBox
|
||||
//
|
||||
this.PortTextBox.Location = new System.Drawing.Point(358, 48);
|
||||
this.PortTextBox.Name = "PortTextBox";
|
||||
this.PortTextBox.Size = new System.Drawing.Size(56, 23);
|
||||
this.PortTextBox.TabIndex = 5;
|
||||
this.PortTextBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
|
||||
//
|
||||
// AddressTextBox
|
||||
//
|
||||
this.AddressTextBox.Location = new System.Drawing.Point(120, 48);
|
||||
this.AddressTextBox.Name = "AddressTextBox";
|
||||
this.AddressTextBox.Size = new System.Drawing.Size(232, 23);
|
||||
this.AddressTextBox.TabIndex = 3;
|
||||
this.AddressTextBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
|
||||
//
|
||||
// RemarkTextBox
|
||||
//
|
||||
this.RemarkTextBox.Location = new System.Drawing.Point(120, 19);
|
||||
this.RemarkTextBox.Name = "RemarkTextBox";
|
||||
this.RemarkTextBox.Size = new System.Drawing.Size(294, 23);
|
||||
this.RemarkTextBox.TabIndex = 1;
|
||||
this.RemarkTextBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
|
||||
//
|
||||
// RemarkLabel
|
||||
//
|
||||
this.RemarkLabel.AutoSize = true;
|
||||
this.RemarkLabel.Location = new System.Drawing.Point(10, 22);
|
||||
this.RemarkLabel.Name = "RemarkLabel";
|
||||
this.RemarkLabel.Size = new System.Drawing.Size(53, 17);
|
||||
this.RemarkLabel.TabIndex = 0;
|
||||
this.RemarkLabel.Text = "Remark";
|
||||
//
|
||||
// PortLabel
|
||||
//
|
||||
this.PortLabel.AutoSize = true;
|
||||
this.PortLabel.Location = new System.Drawing.Point(351, 51);
|
||||
this.PortLabel.Name = "PortLabel";
|
||||
this.PortLabel.Size = new System.Drawing.Size(11, 17);
|
||||
this.PortLabel.TabIndex = 4;
|
||||
this.PortLabel.Text = ":";
|
||||
//
|
||||
// ControlButton
|
||||
//
|
||||
this.ControlButton.Location = new System.Drawing.Point(357, 127);
|
||||
this.ControlButton.Name = "ControlButton";
|
||||
this.ControlButton.Size = new System.Drawing.Size(75, 23);
|
||||
this.ControlButton.TabIndex = 1;
|
||||
this.ControlButton.Text = "Save";
|
||||
this.ControlButton.UseVisualStyleBackColor = true;
|
||||
this.ControlButton.Click += new System.EventHandler(this.ControlButton_Click);
|
||||
//
|
||||
// Trojan
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
|
||||
this.ClientSize = new System.Drawing.Size(444, 161);
|
||||
this.Controls.Add(this.ControlButton);
|
||||
this.Controls.Add(this.ConfigurationGroupBox);
|
||||
this.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
|
||||
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
|
||||
this.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
this.MaximizeBox = false;
|
||||
this.Name = "Trojan";
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
||||
this.Text = "Trojan";
|
||||
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.Trojan_FormClosing);
|
||||
this.Load += new System.EventHandler(this.Trojan_Load);
|
||||
this.ConfigurationGroupBox.ResumeLayout(false);
|
||||
this.ConfigurationGroupBox.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.GroupBox ConfigurationGroupBox;
|
||||
private System.Windows.Forms.Button ControlButton;
|
||||
private System.Windows.Forms.Label RemarkLabel;
|
||||
private System.Windows.Forms.TextBox RemarkTextBox;
|
||||
private System.Windows.Forms.Label PortLabel;
|
||||
private System.Windows.Forms.TextBox AddressTextBox;
|
||||
private System.Windows.Forms.TextBox PortTextBox;
|
||||
private System.Windows.Forms.Label AddressLabel;
|
||||
private System.Windows.Forms.TextBox PasswordTextBox;
|
||||
private System.Windows.Forms.Label PasswordLabel;
|
||||
}
|
||||
}
|
||||
106
Netch/Forms/Server/Trojan.cs
Normal file
106
Netch/Forms/Server/Trojan.cs
Normal file
@@ -0,0 +1,106 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Netch.Forms.Server
|
||||
{
|
||||
public partial class Trojan : Form
|
||||
{
|
||||
public int Index;
|
||||
|
||||
/// <summary>
|
||||
/// 初始化
|
||||
/// </summary>
|
||||
/// <param name="index">需要编辑的索引</param>
|
||||
public Trojan(int index = -1)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
Index = index;
|
||||
}
|
||||
|
||||
private void Trojan_Load(object sender, EventArgs e)
|
||||
{
|
||||
ConfigurationGroupBox.Text = Utils.i18N.Translate(ConfigurationGroupBox.Text);
|
||||
RemarkLabel.Text = Utils.i18N.Translate(RemarkLabel.Text);
|
||||
AddressLabel.Text = Utils.i18N.Translate(AddressLabel.Text);
|
||||
PasswordLabel.Text = Utils.i18N.Translate(PasswordLabel.Text);
|
||||
ControlButton.Text = Utils.i18N.Translate(ControlButton.Text);
|
||||
|
||||
if (Index != -1)
|
||||
{
|
||||
RemarkTextBox.Text = Global.Settings.Server[Index].Remark;
|
||||
AddressTextBox.Text = Global.Settings.Server[Index].Hostname;
|
||||
PortTextBox.Text = Global.Settings.Server[Index].Port.ToString();
|
||||
PasswordTextBox.Text = Global.Settings.Server[Index].Password;
|
||||
}
|
||||
}
|
||||
|
||||
private void Trojan_FormClosing(object sender, FormClosingEventArgs e)
|
||||
{
|
||||
Global.MainForm.Show();
|
||||
}
|
||||
|
||||
private void ComboBox_DrawItem(object sender, DrawItemEventArgs e)
|
||||
{
|
||||
var cbx = sender as ComboBox;
|
||||
if (cbx != null)
|
||||
{
|
||||
e.DrawBackground();
|
||||
|
||||
if (e.Index >= 0)
|
||||
{
|
||||
var sf = new StringFormat();
|
||||
sf.LineAlignment = StringAlignment.Center;
|
||||
sf.Alignment = StringAlignment.Center;
|
||||
|
||||
var brush = new SolidBrush(cbx.ForeColor);
|
||||
|
||||
if ((e.State & DrawItemState.Selected) == DrawItemState.Selected)
|
||||
{
|
||||
brush = SystemBrushes.HighlightText as SolidBrush;
|
||||
}
|
||||
|
||||
e.Graphics.DrawString(cbx.Items[e.Index].ToString(), cbx.Font, brush, e.Bounds, sf);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ControlButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (!Regex.Match(PortTextBox.Text, "^[0-9]+$").Success)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (Index == -1)
|
||||
{
|
||||
Global.Settings.Server.Add(new Models.Server
|
||||
{
|
||||
Remark = RemarkTextBox.Text,
|
||||
Type = "Trojan",
|
||||
Hostname = AddressTextBox.Text,
|
||||
Port = int.Parse(PortTextBox.Text),
|
||||
Password = PasswordTextBox.Text
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
Global.Settings.Server[Index] = new Models.Server
|
||||
{
|
||||
Remark = RemarkTextBox.Text,
|
||||
Group = Global.Settings.Server[Index].Group,
|
||||
Type = "Trojan",
|
||||
Hostname = AddressTextBox.Text,
|
||||
Port = int.Parse(PortTextBox.Text),
|
||||
Password = PasswordTextBox.Text
|
||||
};
|
||||
}
|
||||
|
||||
Utils.Configuration.Save();
|
||||
MessageBox.Show(Utils.i18N.Translate("Saved"), Utils.i18N.Translate("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
Global.MainForm.InitServer();
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
4986
Netch/Forms/Server/Trojan.resx
Normal file
4986
Netch/Forms/Server/Trojan.resx
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user