SelectedNetworks
58 | { get { return _selectedNetworks; } }
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/MeshApp/frmForwardToNetwork.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
121 | True
122 |
123 |
124 | True
125 |
126 |
127 | True
128 |
129 |
130 | True
131 |
132 |
133 | True
134 |
135 |
--------------------------------------------------------------------------------
/MeshApp/frmImageDialog.Designer.cs:
--------------------------------------------------------------------------------
1 | namespace MeshApp
2 | {
3 | partial class frmImageDialog
4 | {
5 | ///
6 | /// Required designer variable.
7 | ///
8 | private System.ComponentModel.IContainer components = null;
9 |
10 | ///
11 | /// Clean up any resources being used.
12 | ///
13 | /// true if managed resources should be disposed; otherwise, false.
14 | protected override void Dispose(bool disposing)
15 | {
16 | if (disposing && (components != null))
17 | {
18 | components.Dispose();
19 | }
20 | base.Dispose(disposing);
21 | }
22 |
23 | #region Windows Form Designer generated code
24 |
25 | ///
26 | /// Required method for Designer support - do not modify
27 | /// the contents of this method with the code editor.
28 | ///
29 | private void InitializeComponent()
30 | {
31 | this.picImage = new System.Windows.Forms.PictureBox();
32 | this.btnBrowse = new System.Windows.Forms.Button();
33 | this.btnOK = new System.Windows.Forms.Button();
34 | this.btnCancel = new System.Windows.Forms.Button();
35 | this.label1 = new System.Windows.Forms.Label();
36 | ((System.ComponentModel.ISupportInitialize)(this.picImage)).BeginInit();
37 | this.SuspendLayout();
38 | //
39 | // picImage
40 | //
41 | this.picImage.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
42 | | System.Windows.Forms.AnchorStyles.Left)
43 | | System.Windows.Forms.AnchorStyles.Right)));
44 | this.picImage.BackColor = System.Drawing.Color.Silver;
45 | this.picImage.Cursor = System.Windows.Forms.Cursors.Cross;
46 | this.picImage.Location = new System.Drawing.Point(12, 27);
47 | this.picImage.Margin = new System.Windows.Forms.Padding(0);
48 | this.picImage.Name = "picImage";
49 | this.picImage.Size = new System.Drawing.Size(600, 280);
50 | this.picImage.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
51 | this.picImage.TabIndex = 0;
52 | this.picImage.TabStop = false;
53 | this.picImage.MouseDown += new System.Windows.Forms.MouseEventHandler(this.picImage_MouseDown);
54 | this.picImage.MouseMove += new System.Windows.Forms.MouseEventHandler(this.picImage_MouseMove);
55 | this.picImage.MouseUp += new System.Windows.Forms.MouseEventHandler(this.picImage_MouseUp);
56 | //
57 | // btnBrowse
58 | //
59 | this.btnBrowse.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
60 | this.btnBrowse.Location = new System.Drawing.Point(12, 313);
61 | this.btnBrowse.Name = "btnBrowse";
62 | this.btnBrowse.Size = new System.Drawing.Size(75, 23);
63 | this.btnBrowse.TabIndex = 1;
64 | this.btnBrowse.Text = "Browse";
65 | this.btnBrowse.UseVisualStyleBackColor = true;
66 | this.btnBrowse.Click += new System.EventHandler(this.btnBrowse_Click);
67 | //
68 | // btnOK
69 | //
70 | this.btnOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
71 | this.btnOK.Enabled = false;
72 | this.btnOK.Location = new System.Drawing.Point(456, 313);
73 | this.btnOK.Name = "btnOK";
74 | this.btnOK.Size = new System.Drawing.Size(75, 23);
75 | this.btnOK.TabIndex = 3;
76 | this.btnOK.Text = "OK";
77 | this.btnOK.UseVisualStyleBackColor = true;
78 | this.btnOK.Click += new System.EventHandler(this.btnOK_Click);
79 | //
80 | // btnCancel
81 | //
82 | this.btnCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
83 | this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
84 | this.btnCancel.Location = new System.Drawing.Point(537, 313);
85 | this.btnCancel.Name = "btnCancel";
86 | this.btnCancel.Size = new System.Drawing.Size(75, 23);
87 | this.btnCancel.TabIndex = 4;
88 | this.btnCancel.Text = "Cancel";
89 | this.btnCancel.UseVisualStyleBackColor = true;
90 | this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
91 | //
92 | // label1
93 | //
94 | this.label1.AutoSize = true;
95 | this.label1.Location = new System.Drawing.Point(9, 9);
96 | this.label1.Name = "label1";
97 | this.label1.Size = new System.Drawing.Size(377, 13);
98 | this.label1.TabIndex = 5;
99 | this.label1.Text = "To select profile picture, use your mouse to drag and crop image shown below.";
100 | //
101 | // frmImageDialog
102 | //
103 | this.AcceptButton = this.btnOK;
104 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
105 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
106 | this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(250)))), ((int)(((byte)(250)))), ((int)(((byte)(250)))));
107 | this.CancelButton = this.btnCancel;
108 | this.ClientSize = new System.Drawing.Size(624, 343);
109 | this.Controls.Add(this.label1);
110 | this.Controls.Add(this.btnCancel);
111 | this.Controls.Add(this.btnOK);
112 | this.Controls.Add(this.btnBrowse);
113 | this.Controls.Add(this.picImage);
114 | this.MinimizeBox = false;
115 | this.Name = "frmImageDialog";
116 | this.ShowIcon = false;
117 | this.ShowInTaskbar = false;
118 | this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
119 | this.Text = "Select Profile Picture";
120 | this.Load += new System.EventHandler(this.frmImageDialog_Load);
121 | ((System.ComponentModel.ISupportInitialize)(this.picImage)).EndInit();
122 | this.ResumeLayout(false);
123 | this.PerformLayout();
124 |
125 | }
126 |
127 | #endregion
128 |
129 | private System.Windows.Forms.PictureBox picImage;
130 | private System.Windows.Forms.Button btnBrowse;
131 | private System.Windows.Forms.Button btnOK;
132 | private System.Windows.Forms.Button btnCancel;
133 | private System.Windows.Forms.Label label1;
134 | }
135 | }
--------------------------------------------------------------------------------
/MeshApp/frmImportPEM.cs:
--------------------------------------------------------------------------------
1 | /*
2 | Technitium Mesh
3 | Copyright (C) 2019 Shreyas Zare (shreyas@technitium.com)
4 |
5 | This program is free software: you can redistribute it and/or modify
6 | it under the terms of the GNU General Public License as published by
7 | the Free Software Foundation, either version 3 of the License, or
8 | (at your option) any later version.
9 |
10 | This program is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License
16 | along with this program. If not, see .
17 |
18 | */
19 |
20 | using System;
21 | using System.IO;
22 | using System.Security.Cryptography;
23 | using System.Text;
24 | using System.Windows.Forms;
25 | using TechnitiumLibrary.Security.Cryptography;
26 |
27 | namespace MeshApp
28 | {
29 | public partial class frmImportPEM : Form
30 | {
31 | #region variables
32 |
33 | RSAParameters _privateKey;
34 |
35 | #endregion
36 |
37 | #region form code
38 |
39 | public frmImportPEM()
40 | {
41 | InitializeComponent();
42 | }
43 |
44 | private void txtRSAKey_TextChanged(object sender, EventArgs e)
45 | {
46 | if (!txtRSAKey.Text.Contains("\r\n"))
47 | txtRSAKey.Text = txtRSAKey.Text.Replace("\n", "\r\n");
48 | }
49 |
50 | private void btnOK_Click(object sender, EventArgs e)
51 | {
52 | try
53 | {
54 | using (MemoryStream mS = new MemoryStream(Encoding.UTF8.GetBytes(txtRSAKey.Text)))
55 | {
56 | _privateKey = PEMFormat.ReadRSAPrivateKey(mS);
57 | }
58 |
59 | using (RSACryptoServiceProvider rsa = new RSACryptoServiceProvider())
60 | {
61 | rsa.ImportParameters(_privateKey);
62 |
63 | if (rsa.KeySize < 2048)
64 | {
65 | MessageBox.Show("The RSA private key must be at least 2048-bit. The current key is " + rsa.KeySize + "-bit.", "Short RSA Private Key", MessageBoxButtons.OK, MessageBoxIcon.Error);
66 | return;
67 | }
68 | }
69 |
70 | this.DialogResult = DialogResult.OK;
71 | this.Close();
72 | }
73 | catch
74 | {
75 | MessageBox.Show("Error in reading PEM format. Please make sure you have pasted the RSA private key in a proper PEM format.", "Invalid PEM Format", MessageBoxButtons.OK, MessageBoxIcon.Error);
76 | }
77 | }
78 |
79 | #endregion
80 |
81 | #region properties
82 |
83 | public RSAParameters PrivateKey
84 | { get { return _privateKey; } }
85 |
86 | #endregion
87 | }
88 | }
89 |
--------------------------------------------------------------------------------
/MeshApp/frmMessageInfo.Designer.cs:
--------------------------------------------------------------------------------
1 | namespace MeshApp
2 | {
3 | partial class frmMessageInfo
4 | {
5 | ///
6 | /// Required designer variable.
7 | ///
8 | private System.ComponentModel.IContainer components = null;
9 |
10 | ///
11 | /// Clean up any resources being used.
12 | ///
13 | /// true if managed resources should be disposed; otherwise, false.
14 | protected override void Dispose(bool disposing)
15 | {
16 | if (disposing && (components != null))
17 | {
18 | components.Dispose();
19 | }
20 | base.Dispose(disposing);
21 | }
22 |
23 | #region Windows Form Designer generated code
24 |
25 | ///
26 | /// Required method for Designer support - do not modify
27 | /// the contents of this method with the code editor.
28 | ///
29 | private void InitializeComponent()
30 | {
31 | this.chatMessagePanel = new System.Windows.Forms.Panel();
32 | this.listView1 = new System.Windows.Forms.ListView();
33 | this.columnHeader1 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
34 | this.columnHeader2 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
35 | this.btnClose = new System.Windows.Forms.Button();
36 | this.SuspendLayout();
37 | //
38 | // chatMessagePanel
39 | //
40 | this.chatMessagePanel.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
41 | | System.Windows.Forms.AnchorStyles.Left)
42 | | System.Windows.Forms.AnchorStyles.Right)));
43 | this.chatMessagePanel.AutoScroll = true;
44 | this.chatMessagePanel.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(224)))), ((int)(((byte)(224)))), ((int)(((byte)(224)))));
45 | this.chatMessagePanel.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
46 | this.chatMessagePanel.Location = new System.Drawing.Point(12, 12);
47 | this.chatMessagePanel.Name = "chatMessagePanel";
48 | this.chatMessagePanel.Size = new System.Drawing.Size(460, 150);
49 | this.chatMessagePanel.TabIndex = 0;
50 | //
51 | // listView1
52 | //
53 | this.listView1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
54 | | System.Windows.Forms.AnchorStyles.Right)));
55 | this.listView1.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
56 | this.columnHeader1,
57 | this.columnHeader2});
58 | this.listView1.FullRowSelect = true;
59 | this.listView1.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable;
60 | this.listView1.HideSelection = false;
61 | this.listView1.Location = new System.Drawing.Point(12, 168);
62 | this.listView1.Name = "listView1";
63 | this.listView1.Size = new System.Drawing.Size(460, 124);
64 | this.listView1.TabIndex = 1;
65 | this.listView1.UseCompatibleStateImageBehavior = false;
66 | this.listView1.View = System.Windows.Forms.View.Details;
67 | //
68 | // columnHeader1
69 | //
70 | this.columnHeader1.Text = "Recipient";
71 | this.columnHeader1.Width = 200;
72 | //
73 | // columnHeader2
74 | //
75 | this.columnHeader2.Text = "Delivery Status";
76 | this.columnHeader2.Width = 230;
77 | //
78 | // btnClose
79 | //
80 | this.btnClose.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
81 | this.btnClose.DialogResult = System.Windows.Forms.DialogResult.Cancel;
82 | this.btnClose.Location = new System.Drawing.Point(397, 301);
83 | this.btnClose.Name = "btnClose";
84 | this.btnClose.Size = new System.Drawing.Size(75, 23);
85 | this.btnClose.TabIndex = 2;
86 | this.btnClose.Text = "&Close";
87 | this.btnClose.UseVisualStyleBackColor = true;
88 | //
89 | // frmMessageInfo
90 | //
91 | this.AcceptButton = this.btnClose;
92 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
93 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
94 | this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(250)))), ((int)(((byte)(250)))), ((int)(((byte)(250)))));
95 | this.CancelButton = this.btnClose;
96 | this.ClientSize = new System.Drawing.Size(484, 331);
97 | this.Controls.Add(this.btnClose);
98 | this.Controls.Add(this.listView1);
99 | this.Controls.Add(this.chatMessagePanel);
100 | this.MaximizeBox = false;
101 | this.MinimizeBox = false;
102 | this.MinimumSize = new System.Drawing.Size(500, 250);
103 | this.Name = "frmMessageInfo";
104 | this.ShowIcon = false;
105 | this.ShowInTaskbar = false;
106 | this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
107 | this.Text = "Message Info";
108 | this.ResumeLayout(false);
109 |
110 | }
111 |
112 | #endregion
113 |
114 | private System.Windows.Forms.Panel chatMessagePanel;
115 | private System.Windows.Forms.ListView listView1;
116 | private System.Windows.Forms.Button btnClose;
117 | private System.Windows.Forms.ColumnHeader columnHeader1;
118 | private System.Windows.Forms.ColumnHeader columnHeader2;
119 | }
120 | }
--------------------------------------------------------------------------------
/MeshApp/frmMessageInfo.cs:
--------------------------------------------------------------------------------
1 | /*
2 | Technitium Mesh
3 | Copyright (C) 2019 Shreyas Zare (shreyas@technitium.com)
4 |
5 | This program is free software: you can redistribute it and/or modify
6 | it under the terms of the GNU General Public License as published by
7 | the Free Software Foundation, either version 3 of the License, or
8 | (at your option) any later version.
9 |
10 | This program is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License
16 | along with this program. If not, see .
17 |
18 | */
19 |
20 | using MeshApp.UserControls;
21 | using MeshCore.Message;
22 | using MeshCore.Network;
23 | using System.Windows.Forms;
24 |
25 | namespace MeshApp
26 | {
27 | public partial class frmMessageInfo : Form
28 | {
29 | public frmMessageInfo(MeshNetwork.Peer selfPeer, MessageItem message)
30 | {
31 | this.SuspendLayout();
32 |
33 | InitializeComponent();
34 |
35 | CustomListViewItem displayItem;
36 |
37 | switch (message.Type)
38 | {
39 | case MessageType.TextMessage:
40 | ChatMessageTextItem textItem = new ChatMessageTextItem(selfPeer, message);
41 | textItem.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
42 | textItem.Width = chatMessagePanel.Width - 30;
43 | textItem.ContextMenuStrip = null;
44 |
45 | displayItem = textItem;
46 | break;
47 |
48 | case MessageType.FileAttachment:
49 | ChatMessageFileItem fileItem = new ChatMessageFileItem(selfPeer, message);
50 | fileItem.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
51 | fileItem.Width = chatMessagePanel.Width - 30;
52 | fileItem.ContextMenuStrip = null;
53 |
54 | displayItem = fileItem;
55 | break;
56 |
57 | default:
58 | return;
59 | }
60 |
61 | if (displayItem.Height > 150)
62 | {
63 | chatMessagePanel.Height = 140;
64 | }
65 | else
66 | {
67 | chatMessagePanel.Height = displayItem.Height + 10;
68 |
69 | int heightDiff = 150 - chatMessagePanel.Height;
70 |
71 | this.Height -= heightDiff;
72 | listView1.Top -= heightDiff;
73 | btnClose.Top -= heightDiff;
74 | }
75 |
76 | chatMessagePanel.Controls.Add(displayItem);
77 |
78 | MeshNetwork.Peer[] peers = selfPeer.Network.GetPeers();
79 |
80 | foreach (MessageRecipient rcpt in message.Recipients)
81 | {
82 | string rcptName = null;
83 |
84 | foreach (MeshNetwork.Peer peer in peers)
85 | {
86 | if (peer.PeerUserId.Equals(rcpt.UserId))
87 | {
88 | rcptName = peer.ProfileDisplayName;
89 | break;
90 | }
91 | }
92 |
93 | if (rcptName == null)
94 | rcptName = rcpt.UserId.ToString();
95 |
96 | ListViewItem item = listView1.Items.Add(rcptName);
97 |
98 | switch (rcpt.Status)
99 | {
100 | case MessageRecipientStatus.Delivered:
101 | item.SubItems.Add("Delivered on " + rcpt.DeliveredOn.ToLocalTime().ToString());
102 | break;
103 |
104 | case MessageRecipientStatus.Undelivered:
105 | item.SubItems.Add("Undelivered");
106 | break;
107 | }
108 | }
109 |
110 | this.ResumeLayout();
111 | }
112 | }
113 | }
114 |
--------------------------------------------------------------------------------
/MeshApp/frmMessageInfo.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
121 | True
122 |
123 |
124 | True
125 |
126 |
127 | True
128 |
129 |
130 | True
131 |
132 |
--------------------------------------------------------------------------------
/MeshApp/frmNetworkInfo.Designer.cs:
--------------------------------------------------------------------------------
1 | namespace MeshApp
2 | {
3 | partial class frmNetworkInfo
4 | {
5 | ///
6 | /// Required designer variable.
7 | ///
8 | private System.ComponentModel.IContainer components = null;
9 |
10 | ///
11 | /// Clean up any resources being used.
12 | ///
13 | /// true if managed resources should be disposed; otherwise, false.
14 | protected override void Dispose(bool disposing)
15 | {
16 | if (disposing && (components != null))
17 | {
18 | components.Dispose();
19 | }
20 | base.Dispose(disposing);
21 | }
22 |
23 | #region Windows Form Designer generated code
24 |
25 | ///
26 | /// Required method for Designer support - do not modify
27 | /// the contents of this method with the code editor.
28 | ///
29 | private void InitializeComponent()
30 | {
31 | this.listView1 = new System.Windows.Forms.ListView();
32 | this.columnHeader1 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
33 | this.columnHeader2 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
34 | this.btnClose = new System.Windows.Forms.Button();
35 | this.btnRecheck = new System.Windows.Forms.Button();
36 | this.SuspendLayout();
37 | //
38 | // listView1
39 | //
40 | this.listView1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
41 | | System.Windows.Forms.AnchorStyles.Left)
42 | | System.Windows.Forms.AnchorStyles.Right)));
43 | this.listView1.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
44 | this.columnHeader1,
45 | this.columnHeader2});
46 | this.listView1.FullRowSelect = true;
47 | this.listView1.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable;
48 | this.listView1.HideSelection = false;
49 | this.listView1.Location = new System.Drawing.Point(12, 12);
50 | this.listView1.MultiSelect = false;
51 | this.listView1.Name = "listView1";
52 | this.listView1.Size = new System.Drawing.Size(460, 358);
53 | this.listView1.TabIndex = 0;
54 | this.listView1.UseCompatibleStateImageBehavior = false;
55 | this.listView1.View = System.Windows.Forms.View.Details;
56 | this.listView1.DoubleClick += new System.EventHandler(this.listView1_DoubleClick);
57 | //
58 | // columnHeader1
59 | //
60 | this.columnHeader1.Text = "Name";
61 | this.columnHeader1.Width = 120;
62 | //
63 | // columnHeader2
64 | //
65 | this.columnHeader2.Text = "Value";
66 | this.columnHeader2.Width = 300;
67 | //
68 | // btnClose
69 | //
70 | this.btnClose.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
71 | this.btnClose.DialogResult = System.Windows.Forms.DialogResult.Cancel;
72 | this.btnClose.Location = new System.Drawing.Point(397, 380);
73 | this.btnClose.Name = "btnClose";
74 | this.btnClose.Size = new System.Drawing.Size(75, 23);
75 | this.btnClose.TabIndex = 2;
76 | this.btnClose.Text = "&Close";
77 | this.btnClose.UseVisualStyleBackColor = true;
78 | //
79 | // btnRecheck
80 | //
81 | this.btnRecheck.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
82 | this.btnRecheck.Location = new System.Drawing.Point(12, 380);
83 | this.btnRecheck.Name = "btnRecheck";
84 | this.btnRecheck.Size = new System.Drawing.Size(75, 23);
85 | this.btnRecheck.TabIndex = 1;
86 | this.btnRecheck.Text = "&Refresh";
87 | this.btnRecheck.UseVisualStyleBackColor = true;
88 | this.btnRecheck.Click += new System.EventHandler(this.btnRecheck_Click);
89 | //
90 | // frmNetworkInfo
91 | //
92 | this.AcceptButton = this.btnClose;
93 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
94 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
95 | this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(250)))), ((int)(((byte)(250)))), ((int)(((byte)(250)))));
96 | this.CancelButton = this.btnClose;
97 | this.ClientSize = new System.Drawing.Size(484, 411);
98 | this.Controls.Add(this.btnRecheck);
99 | this.Controls.Add(this.btnClose);
100 | this.Controls.Add(this.listView1);
101 | this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
102 | this.MaximizeBox = false;
103 | this.MinimizeBox = false;
104 | this.Name = "frmNetworkInfo";
105 | this.ShowInTaskbar = false;
106 | this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
107 | this.Text = "Network Info";
108 | this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.frmNetworkInfo_FormClosing);
109 | this.Load += new System.EventHandler(this.frmNetworkInfo_Load);
110 | this.ResumeLayout(false);
111 |
112 | }
113 |
114 | #endregion
115 |
116 | private System.Windows.Forms.ListView listView1;
117 | private System.Windows.Forms.Button btnClose;
118 | private System.Windows.Forms.ColumnHeader columnHeader1;
119 | private System.Windows.Forms.ColumnHeader columnHeader2;
120 | private System.Windows.Forms.Button btnRecheck;
121 | }
122 | }
--------------------------------------------------------------------------------
/MeshApp/frmNetworkInfo.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
121 | True
122 |
123 |
124 | True
125 |
126 |
127 | True
128 |
129 |
130 | True
131 |
132 |
--------------------------------------------------------------------------------
/MeshApp/frmProxyConfig.cs:
--------------------------------------------------------------------------------
1 | /*
2 | Technitium Mesh
3 | Copyright (C) 2019 Shreyas Zare (shreyas@technitium.com)
4 |
5 | This program is free software: you can redistribute it and/or modify
6 | it under the terms of the GNU General Public License as published by
7 | the Free Software Foundation, either version 3 of the License, or
8 | (at your option) any later version.
9 |
10 | This program is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License
16 | along with this program. If not, see .
17 |
18 | */
19 |
20 | using System;
21 | using System.Net;
22 | using System.Windows.Forms;
23 | using TechnitiumLibrary.Net.Proxy;
24 |
25 | namespace MeshApp
26 | {
27 | public partial class frmProxyConfig : Form
28 | {
29 | #region variables
30 |
31 | string _proxyAddress;
32 | ushort _proxyPort = 0;
33 |
34 | #endregion
35 |
36 | #region constructor
37 |
38 | public frmProxyConfig()
39 | {
40 | InitializeComponent();
41 | }
42 |
43 | #endregion
44 |
45 | #region form code
46 |
47 | public frmProxyConfig(NetProxyType proxyType, string proxyAddress, int proxyPort, NetworkCredential proxyCredentials)
48 | {
49 | InitializeComponent();
50 |
51 | if ((proxyPort == 9150) && (proxyAddress == "127.0.0.1"))
52 | cmbProxy.SelectedIndex = 3;
53 | else
54 | cmbProxy.SelectedIndex = (int)proxyType;
55 |
56 | txtProxyAddress.Text = proxyAddress;
57 | txtProxyPort.Text = proxyPort.ToString();
58 |
59 | if (proxyCredentials != null)
60 | {
61 | chkProxyAuth.Checked = true;
62 | txtProxyUser.Text = proxyCredentials.UserName;
63 | txtProxyPass.Text = proxyCredentials.Password;
64 | }
65 | }
66 |
67 | private void chkProxyAuth_CheckedChanged(object sender, EventArgs e)
68 | {
69 | txtProxyUser.Enabled = chkProxyAuth.Checked;
70 | txtProxyPass.Enabled = chkProxyAuth.Checked;
71 | }
72 |
73 | private void cmbProxy_SelectedIndexChanged(object sender, EventArgs e)
74 | {
75 | btnCheckProxy.Enabled = (cmbProxy.SelectedIndex != 0);
76 |
77 | txtProxyAddress.Enabled = btnCheckProxy.Enabled;
78 | txtProxyPort.Enabled = btnCheckProxy.Enabled;
79 | chkProxyAuth.Enabled = btnCheckProxy.Enabled;
80 | txtProxyUser.Enabled = chkProxyAuth.Enabled && chkProxyAuth.Checked;
81 | txtProxyPass.Enabled = chkProxyAuth.Enabled && chkProxyAuth.Checked;
82 | }
83 |
84 | private void btnOK_Click(object sender, EventArgs e)
85 | {
86 | if ((cmbProxy.SelectedIndex != 0) && (string.IsNullOrWhiteSpace(txtProxyAddress.Text)))
87 | {
88 | MessageBox.Show("The proxy address is missing. Please enter a valid proxy address.", "Proxy Address Missing!", MessageBoxButtons.OK, MessageBoxIcon.Error);
89 | return;
90 | }
91 |
92 | _proxyAddress = txtProxyAddress.Text;
93 |
94 | if (!ushort.TryParse(txtProxyPort.Text, out _proxyPort))
95 | {
96 | MessageBox.Show("The proxy port number specified is invalid. The number must be in 0-65535 range.", "Invalid Proxy Port Specified!", MessageBoxButtons.OK, MessageBoxIcon.Error);
97 | return;
98 | }
99 |
100 | if ((chkProxyAuth.Checked) && (string.IsNullOrWhiteSpace(txtProxyUser.Text)))
101 | {
102 | MessageBox.Show("The proxy username is missing. Please enter a username.", "Proxy Username Missing!", MessageBoxButtons.OK, MessageBoxIcon.Error);
103 | return;
104 | }
105 |
106 | this.DialogResult = DialogResult.OK;
107 | this.Close();
108 | }
109 |
110 | private void btnCheckProxy_Click(object sender, EventArgs e)
111 | {
112 | try
113 | {
114 | NetProxyType proxyType = this.ProxyType;
115 | NetProxy proxy;
116 | NetworkCredential credentials = null;
117 |
118 | if (chkProxyAuth.Checked)
119 | credentials = new NetworkCredential(txtProxyUser.Text, txtProxyPass.Text);
120 |
121 | switch (proxyType)
122 | {
123 | case NetProxyType.Http:
124 | proxy = new NetProxy(new WebProxyEx(new Uri("http://" + txtProxyAddress.Text + ":" + int.Parse(txtProxyPort.Text)), false, new string[] { }, credentials));
125 | break;
126 |
127 | case NetProxyType.Socks5:
128 | proxy = new NetProxy(new SocksClient(txtProxyAddress.Text, int.Parse(txtProxyPort.Text), credentials));
129 | break;
130 |
131 | default:
132 | return;
133 | }
134 |
135 | proxy.CheckProxyAccess();
136 |
137 | MessageBox.Show("Mesh was able to connect to the proxy server successfully.", "Proxy Check Success!", MessageBoxButtons.OK, MessageBoxIcon.Information);
138 | }
139 | catch (Exception ex)
140 | {
141 | MessageBox.Show(ex.Message, "Proxy Check Failed!", MessageBoxButtons.OK, MessageBoxIcon.Error);
142 | }
143 | }
144 |
145 | #endregion
146 |
147 | #region properties
148 |
149 | public NetProxyType ProxyType
150 | { get { return (NetProxyType)cmbProxy.SelectedIndex; } }
151 |
152 | public string ProxyAddress
153 | { get { return _proxyAddress; } }
154 |
155 | public int ProxyPort
156 | { get { return _proxyPort; } }
157 |
158 | public NetworkCredential ProxyCredentials
159 | {
160 | get
161 | {
162 | if (chkProxyAuth.Checked)
163 | return new NetworkCredential(txtProxyUser.Text, txtProxyPass.Text);
164 | else
165 | return null;
166 | }
167 | }
168 |
169 | #endregion
170 | }
171 | }
172 |
--------------------------------------------------------------------------------
/MeshApp/frmViewGroup.cs:
--------------------------------------------------------------------------------
1 | /*
2 | Technitium Mesh
3 | Copyright (C) 2019 Shreyas Zare (shreyas@technitium.com)
4 |
5 | This program is free software: you can redistribute it and/or modify
6 | it under the terms of the GNU General Public License as published by
7 | the Free Software Foundation, either version 3 of the License, or
8 | (at your option) any later version.
9 |
10 | This program is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License
16 | along with this program. If not, see .
17 |
18 | */
19 |
20 | using MeshCore.Network;
21 | using System;
22 | using System.Drawing;
23 | using System.IO;
24 | using System.Windows.Forms;
25 |
26 | namespace MeshApp
27 | {
28 | public partial class frmViewGroup : Form
29 | {
30 | #region variables
31 |
32 | MeshNetwork _network;
33 |
34 | Image _groupImage;
35 | bool _changesMade = false;
36 |
37 | #endregion
38 |
39 | #region constructor
40 |
41 | public frmViewGroup(MeshNetwork network)
42 | {
43 | InitializeComponent();
44 |
45 | _network = network;
46 |
47 | //name
48 | string name = _network.NetworkName;
49 |
50 | //name icon
51 | if (name.Length > 0)
52 | {
53 | labIcon.Text = name.Substring(0, 1).ToUpper();
54 |
55 | int x = name.LastIndexOf(" ", StringComparison.CurrentCultureIgnoreCase);
56 | if (x > 0)
57 | {
58 | labIcon.Text += name.Substring(x + 1, 1).ToUpper();
59 | }
60 | else if (name.Length > 1)
61 | {
62 | labIcon.Text += name.Substring(1, 1).ToLower();
63 | }
64 | }
65 | else
66 | {
67 | labIcon.Text = "";
68 | }
69 |
70 | if (_network.Status == MeshNetworkStatus.Online)
71 | labIcon.BackColor = Color.FromArgb(102, 153, 255);
72 | else
73 | labIcon.BackColor = Color.Gray;
74 |
75 | labName.Text = name;
76 |
77 | //image icon
78 | if ((_network.GroupDisplayImage != null) && (_network.GroupDisplayImage.Length > 0))
79 | {
80 | using (MemoryStream mS = new MemoryStream(_network.GroupDisplayImage))
81 | {
82 | _groupImage = Image.FromStream(mS);
83 | picIcon.Image = _groupImage;
84 | }
85 |
86 | picIcon.Visible = true;
87 | labIcon.Visible = false;
88 | }
89 | }
90 |
91 | #endregion
92 |
93 | #region form code
94 |
95 | private void mnuChangePhoto_Click(object sender, EventArgs e)
96 | {
97 | using (frmImageDialog frm = new frmImageDialog())
98 | {
99 | if (frm.ShowDialog(this) == DialogResult.OK)
100 | {
101 | _groupImage = frm.SelectedImage;
102 | picIcon.Image = _groupImage;
103 |
104 | using (MemoryStream mS = new MemoryStream(4096))
105 | {
106 | frm.SelectedImage.Save(mS, System.Drawing.Imaging.ImageFormat.Jpeg);
107 | _network.GroupDisplayImage = mS.ToArray();
108 | }
109 |
110 | _changesMade = true;
111 |
112 | picIcon.Visible = true;
113 | labIcon.Visible = false;
114 | }
115 | }
116 | }
117 |
118 | private void mnuRemovePhoto_Click(object sender, EventArgs e)
119 | {
120 | _network.GroupDisplayImage = null;
121 | _groupImage = null;
122 | picIcon.Image = Properties.Resources.change_photo;
123 |
124 | _changesMade = true;
125 |
126 | picIcon.Visible = false;
127 | labIcon.Visible = true;
128 | }
129 |
130 | private void labIcon_MouseUp(object sender, MouseEventArgs e)
131 | {
132 | switch (e.Button)
133 | {
134 | case MouseButtons.Left:
135 | mnuChangePhoto_Click(null, null);
136 | break;
137 |
138 | case MouseButtons.Right:
139 | mnuRemovePhoto.Enabled = (_groupImage != null);
140 | Control control = sender as Control;
141 | mnuGroupImage.Show(control, e.Location);
142 | break;
143 | }
144 | }
145 |
146 | private void labIcon_MouseEnter(object sender, EventArgs e)
147 | {
148 | if (_groupImage == null)
149 | {
150 | picIcon.Visible = true;
151 | labIcon.Visible = false;
152 | }
153 | else
154 | {
155 | picIcon.Image = Properties.Resources.change_photo;
156 | }
157 | }
158 |
159 | private void picIcon_MouseEnter(object sender, EventArgs e)
160 | {
161 | if (_groupImage != null)
162 | picIcon.Image = Properties.Resources.change_photo;
163 | }
164 |
165 | private void picIcon_MouseLeave(object sender, EventArgs e)
166 | {
167 | if (_groupImage == null)
168 | {
169 | labIcon.Visible = true;
170 | picIcon.Visible = false;
171 | }
172 | else
173 | {
174 | picIcon.Image = _groupImage;
175 | }
176 | }
177 |
178 | private void mnuCopy_Click(object sender, EventArgs e)
179 | {
180 | try
181 | {
182 | Clipboard.Clear();
183 | Clipboard.SetText(labName.Text);
184 | }
185 | catch
186 | { }
187 | }
188 |
189 | private void btnClose_Click(object sender, EventArgs e)
190 | {
191 | if (_changesMade)
192 | this.DialogResult = DialogResult.OK;
193 |
194 | this.Close();
195 | }
196 |
197 | #endregion
198 | }
199 | }
200 |
--------------------------------------------------------------------------------
/MeshApp/logo2.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TechnitiumSoftware/Mesh/4a7dc4f4dab999143baa4247606089479805d61a/MeshApp/logo2.ico
--------------------------------------------------------------------------------
/MeshCore/Debug.cs:
--------------------------------------------------------------------------------
1 | /*
2 | Technitium Mesh
3 | Copyright (C) 2018 Shreyas Zare (shreyas@technitium.com)
4 |
5 | This program is free software: you can redistribute it and/or modify
6 | it under the terms of the GNU General Public License as published by
7 | the Free Software Foundation, either version 3 of the License, or
8 | (at your option) any later version.
9 |
10 | This program is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License
16 | along with this program. If not, see .
17 |
18 | */
19 |
20 | using System;
21 | using System.Threading;
22 |
23 | namespace MeshCore
24 | {
25 | public static class Debug
26 | {
27 | #region variables
28 |
29 | static object _lockObj = new object();
30 | static IDebug _debug;
31 |
32 | #endregion
33 |
34 | #region public static
35 |
36 | public static void SetDebug(IDebug debug)
37 | {
38 | if (_debug == null)
39 | _debug = debug;
40 | }
41 |
42 | public static void Write(string source, Exception ex)
43 | {
44 | if (_debug != null)
45 | Write(source, ex.ToString());
46 | }
47 |
48 | public static void Write(string source, string message)
49 | {
50 | if (_debug != null)
51 | {
52 | Monitor.Enter(_lockObj);
53 | try
54 | {
55 | _debug.Write("[" + DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss") + "] [" + source + "] " + message + "\r\n");
56 | }
57 | catch
58 | { }
59 | finally
60 | {
61 | Monitor.Exit(_lockObj);
62 | }
63 | }
64 | }
65 |
66 | #endregion
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/MeshCore/IDebug.cs:
--------------------------------------------------------------------------------
1 | /*
2 | Technitium Mesh
3 | Copyright (C) 2018 Shreyas Zare (shreyas@technitium.com)
4 |
5 | This program is free software: you can redistribute it and/or modify
6 | it under the terms of the GNU General Public License as published by
7 | the Free Software Foundation, either version 3 of the License, or
8 | (at your option) any later version.
9 |
10 | This program is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License
16 | along with this program. If not, see .
17 |
18 | */
19 |
20 | namespace MeshCore
21 | {
22 | public interface IDebug
23 | {
24 | void Write(string message);
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/MeshCore/MeshCore.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {D6B9A05E-7417-4902-8B41-114CD0A8130E}
8 | Library
9 | Properties
10 | MeshCore
11 | MeshCore
12 | v4.6.1
13 | 512
14 | true
15 |
16 |
17 | true
18 | full
19 | false
20 | bin\Debug\
21 | DEBUG;TRACE
22 | prompt
23 | 4
24 |
25 |
26 | pdbonly
27 | true
28 | bin\Release\
29 | TRACE
30 | prompt
31 | 4
32 |
33 |
34 |
35 |
36 | ..\..\..\TechnitiumLibrary\bin\TechnitiumLibrary.IO.dll
37 |
38 |
39 | ..\..\..\TechnitiumLibrary\bin\TechnitiumLibrary.Net.dll
40 |
41 |
42 | ..\..\..\TechnitiumLibrary\bin\TechnitiumLibrary.Net.Tor.dll
43 |
44 |
45 | ..\..\..\TechnitiumLibrary\bin\TechnitiumLibrary.Net.UPnP.dll
46 |
47 |
48 | ..\..\..\TechnitiumLibrary\bin\TechnitiumLibrary.Security.Cryptography.dll
49 |
50 |
51 | ..\..\..\TechnitiumLibrary\bin\TechnitiumLibrary.Security.Cryptography.EllipticCurve.dll
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
--------------------------------------------------------------------------------
/MeshCore/MeshException.cs:
--------------------------------------------------------------------------------
1 | /*
2 | Technitium Mesh
3 | Copyright (C) 2019 Shreyas Zare (shreyas@technitium.com)
4 |
5 | This program is free software: you can redistribute it and/or modify
6 | it under the terms of the GNU General Public License as published by
7 | the Free Software Foundation, either version 3 of the License, or
8 | (at your option) any later version.
9 |
10 | This program is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License
16 | along with this program. If not, see .
17 |
18 | */
19 |
20 | using System;
21 |
22 | namespace MeshCore
23 | {
24 | [Serializable()]
25 | public class MeshException : Exception
26 | {
27 | public MeshException()
28 | { }
29 |
30 | public MeshException(string message)
31 | : base(message)
32 | { }
33 |
34 | public MeshException(string message, Exception innerException)
35 | : base(message, innerException)
36 | { }
37 |
38 | protected MeshException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context)
39 | : base(info, context)
40 | { }
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/MeshCore/Message/MessageRecipient.cs:
--------------------------------------------------------------------------------
1 | /*
2 | Technitium Mesh
3 | Copyright (C) 2018 Shreyas Zare (shreyas@technitium.com)
4 |
5 | This program is free software: you can redistribute it and/or modify
6 | it under the terms of the GNU General Public License as published by
7 | the Free Software Foundation, either version 3 of the License, or
8 | (at your option) any later version.
9 |
10 | This program is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License
16 | along with this program. If not, see .
17 |
18 | */
19 |
20 | using System;
21 | using System.IO;
22 | using TechnitiumLibrary.IO;
23 |
24 | namespace MeshCore.Message
25 | {
26 | public enum MessageRecipientStatus : byte
27 | {
28 | Undelivered = 0,
29 | Delivered = 1
30 | }
31 |
32 | public class MessageRecipient
33 | {
34 | #region variables
35 |
36 | readonly BinaryNumber _userId;
37 |
38 | MessageRecipientStatus _status = MessageRecipientStatus.Undelivered;
39 | DateTime _deliveredOn;
40 |
41 | #endregion
42 |
43 | #region constructor
44 |
45 | public MessageRecipient(BinaryNumber userId)
46 | {
47 | _userId = userId;
48 | }
49 |
50 | public MessageRecipient(BinaryReader bR)
51 | {
52 | switch (bR.ReadByte()) //version
53 | {
54 | case 1:
55 | _userId = new BinaryNumber(bR.BaseStream);
56 | _status = (MessageRecipientStatus)bR.ReadByte();
57 | _deliveredOn = bR.ReadDate();
58 | break;
59 |
60 | default:
61 | throw new InvalidDataException("Cannot decode data format: version not supported.");
62 | }
63 | }
64 |
65 | #endregion
66 |
67 | #region public
68 |
69 | public void SetDeliveredStatus()
70 | {
71 | _status = MessageRecipientStatus.Delivered;
72 | _deliveredOn = DateTime.UtcNow;
73 | }
74 |
75 | public void WriteTo(BinaryWriter bW)
76 | {
77 | bW.Write((byte)1); //version
78 | _userId.WriteTo(bW.BaseStream);
79 | bW.Write((byte)_status);
80 | bW.Write(_deliveredOn);
81 | }
82 |
83 | #endregion
84 |
85 | #region properties
86 |
87 | public BinaryNumber UserId
88 | { get { return _userId; } }
89 |
90 | public MessageRecipientStatus Status
91 | { get { return _status; } }
92 |
93 | public DateTime DeliveredOn
94 | { get { return _deliveredOn; } }
95 |
96 | #endregion
97 | }
98 | }
99 |
--------------------------------------------------------------------------------
/MeshCore/Network/DHT/IDhtConnectionManager.cs:
--------------------------------------------------------------------------------
1 | /*
2 | Technitium Mesh
3 | Copyright (C) 2018 Shreyas Zare (shreyas@technitium.com)
4 |
5 | This program is free software: you can redistribute it and/or modify
6 | it under the terms of the GNU General Public License as published by
7 | the Free Software Foundation, either version 3 of the License, or
8 | (at your option) any later version.
9 |
10 | This program is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License
16 | along with this program. If not, see .
17 |
18 | */
19 |
20 | using System.IO;
21 | using System.Net;
22 |
23 | namespace MeshCore.Network.DHT
24 | {
25 | public interface IDhtConnectionManager
26 | {
27 | Stream GetConnection(EndPoint remoteNodeEP);
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/MeshCore/Network/DHT/NodeContact.cs:
--------------------------------------------------------------------------------
1 | /*
2 | Technitium Mesh
3 | Copyright (C) 2018 Shreyas Zare (shreyas@technitium.com)
4 |
5 | This program is free software: you can redistribute it and/or modify
6 | it under the terms of the GNU General Public License as published by
7 | the Free Software Foundation, either version 3 of the License, or
8 | (at your option) any later version.
9 |
10 | This program is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License
16 | along with this program. If not, see .
17 |
18 | */
19 |
20 | using System;
21 | using System.IO;
22 | using System.Net;
23 | using System.Security.Cryptography;
24 | using TechnitiumLibrary.IO;
25 | using TechnitiumLibrary.Net;
26 |
27 | namespace MeshCore.Network.DHT
28 | {
29 | class NodeContact
30 | {
31 | #region variables
32 |
33 | const int NODE_RPC_FAIL_LIMIT = 5; //max failed RPC count before declaring node stale
34 | const int NODE_STALE_TIMEOUT_SECONDS = 900; //15mins timeout before declaring node stale
35 |
36 | static readonly byte[] NODE_ID_SALT = new byte[] { 0xF4, 0xC7, 0x56, 0x9A, 0xA3, 0xAD, 0xC9, 0xA7, 0x13, 0x0E, 0xCA, 0x56, 0x56, 0xA3, 0x52, 0x8F, 0xFE, 0x6E, 0x9C, 0x72 };
37 |
38 | readonly EndPoint _nodeEP;
39 | readonly BinaryNumber _nodeId;
40 |
41 | protected bool _isCurrentNode;
42 | DateTime _lastSeen;
43 | int _successfulRpcCount = 0;
44 | int _failRpcCount = 0;
45 |
46 | #endregion
47 |
48 | #region constructor
49 |
50 | public NodeContact(BinaryReader bR)
51 | {
52 | _nodeEP = EndPointExtension.Parse(bR);
53 | _nodeId = GetNodeId(_nodeEP);
54 | }
55 |
56 | public NodeContact(EndPoint nodeEP)
57 | {
58 | _nodeEP = nodeEP;
59 | _nodeId = GetNodeId(_nodeEP);
60 | }
61 |
62 | protected NodeContact(BinaryNumber nodeId, EndPoint nodeEP)
63 | {
64 | _nodeId = nodeId;
65 | _nodeEP = nodeEP;
66 | }
67 |
68 | #endregion
69 |
70 | #region static
71 |
72 | private static BinaryNumber GetNodeId(EndPoint nodeEP)
73 | {
74 | using (HMAC hmac = new HMACSHA256(NODE_ID_SALT))
75 | {
76 | using (MemoryStream mS = new MemoryStream(32))
77 | {
78 | nodeEP.WriteTo(new BinaryWriter(mS));
79 | mS.Position = 0;
80 |
81 | return new BinaryNumber(hmac.ComputeHash(mS));
82 | }
83 | }
84 | }
85 |
86 | #endregion
87 |
88 | #region public
89 |
90 | public bool IsStale()
91 | {
92 | if (_isCurrentNode)
93 | return false;
94 | else
95 | return ((_failRpcCount > NODE_RPC_FAIL_LIMIT) || ((DateTime.UtcNow - _lastSeen).TotalSeconds > NODE_STALE_TIMEOUT_SECONDS));
96 | }
97 |
98 | public void UpdateLastSeenTime()
99 | {
100 | _lastSeen = DateTime.UtcNow;
101 | _successfulRpcCount++;
102 | _failRpcCount = 0;
103 | }
104 |
105 | public void IncrementRpcFailCount()
106 | {
107 | _failRpcCount++;
108 | }
109 |
110 | public void WriteTo(BinaryWriter bW)
111 | {
112 | _nodeEP.WriteTo(bW);
113 | }
114 |
115 | public override bool Equals(object obj)
116 | {
117 | if (obj is null)
118 | return false;
119 |
120 | if (ReferenceEquals(this, obj))
121 | return true;
122 |
123 | NodeContact contact = obj as NodeContact;
124 | if (contact == null)
125 | return false;
126 |
127 | if (_nodeEP.Equals(contact._nodeEP))
128 | return true;
129 |
130 | return _nodeId.Equals(contact._nodeId);
131 | }
132 |
133 | public override int GetHashCode()
134 | {
135 | return _nodeId.GetHashCode();
136 | }
137 |
138 | public override string ToString()
139 | {
140 | return _nodeEP.ToString();
141 | }
142 |
143 | #endregion
144 |
145 | #region properties
146 |
147 | public EndPoint NodeEP
148 | { get { return _nodeEP; } }
149 |
150 | public BinaryNumber NodeId
151 | { get { return _nodeId; } }
152 |
153 | public bool IsCurrentNode
154 | { get { return _isCurrentNode; } }
155 |
156 | public DateTime LastSeen
157 | { get { return _lastSeen; } }
158 |
159 | public int SuccessfulRpcCount
160 | { get { return _successfulRpcCount; } }
161 |
162 | #endregion
163 | }
164 | }
165 |
--------------------------------------------------------------------------------
/MeshCore/Network/MeshNetworkPeerInfo.cs:
--------------------------------------------------------------------------------
1 | /*
2 | Technitium Mesh
3 | Copyright (C) 2019 Shreyas Zare (shreyas@technitium.com)
4 |
5 | This program is free software: you can redistribute it and/or modify
6 | it under the terms of the GNU General Public License as published by
7 | the Free Software Foundation, either version 3 of the License, or
8 | (at your option) any later version.
9 |
10 | This program is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License
16 | along with this program. If not, see .
17 |
18 | */
19 |
20 | using System;
21 | using System.IO;
22 | using System.Net;
23 | using System.Text;
24 | using TechnitiumLibrary.IO;
25 | using TechnitiumLibrary.Net;
26 |
27 | namespace MeshCore.Network
28 | {
29 | public class MeshNetworkPeerInfo
30 | {
31 | #region variables
32 |
33 | readonly BinaryNumber _peerUserId;
34 | readonly string _peerName; //optional
35 | readonly EndPoint[] _peerEPs;
36 |
37 | #endregion
38 |
39 | #region constructor
40 |
41 | public MeshNetworkPeerInfo(BinaryNumber peerUserId, IPEndPoint peerEP)
42 | {
43 | _peerUserId = peerUserId;
44 | _peerEPs = new IPEndPoint[] { peerEP };
45 | }
46 |
47 | public MeshNetworkPeerInfo(BinaryNumber peerUserId, string peerName, EndPoint[] peerEPs)
48 | {
49 | _peerUserId = peerUserId;
50 | _peerName = peerName;
51 | _peerEPs = peerEPs;
52 | }
53 |
54 | public MeshNetworkPeerInfo(BinaryReader bR)
55 | {
56 | _peerUserId = new BinaryNumber(bR.BaseStream);
57 |
58 | _peerName = Encoding.UTF8.GetString(bR.ReadBytes(bR.ReadByte()));
59 | if (_peerName == "")
60 | _peerName = null;
61 |
62 | {
63 | _peerEPs = new EndPoint[bR.ReadByte()];
64 |
65 | for (int i = 0; i < _peerEPs.Length; i++)
66 | _peerEPs[i] = EndPointExtension.Parse(bR);
67 | }
68 | }
69 |
70 | #endregion
71 |
72 | #region public
73 |
74 | public void WriteTo(BinaryWriter bW)
75 | {
76 | _peerUserId.WriteTo(bW.BaseStream);
77 |
78 | if (_peerName == null)
79 | bW.Write((byte)0);
80 | else
81 | bW.WriteShortString(_peerName);
82 |
83 | bW.Write(Convert.ToByte(_peerEPs.Length));
84 |
85 | foreach (EndPoint peerEP in _peerEPs)
86 | peerEP.WriteTo(bW);
87 | }
88 |
89 | public override bool Equals(object obj)
90 | {
91 | if (obj == null)
92 | return false;
93 |
94 | if (ReferenceEquals(this, obj))
95 | return true;
96 |
97 | MeshNetworkPeerInfo objPeerInfo = obj as MeshNetworkPeerInfo;
98 |
99 | return _peerUserId.Equals(objPeerInfo._peerUserId);
100 | }
101 |
102 | public override int GetHashCode()
103 | {
104 | return _peerUserId.GetHashCode();
105 | }
106 |
107 | public override string ToString()
108 | {
109 | if (_peerName == null)
110 | return "[" + _peerUserId.ToString() + "]";
111 |
112 | return _peerName + " [" + _peerUserId.ToString() + "]";
113 | }
114 |
115 | #endregion
116 |
117 | #region properties
118 |
119 | public BinaryNumber PeerUserId
120 | { get { return _peerUserId; } }
121 |
122 | public string PeerDisplayName
123 | {
124 | get
125 | {
126 | if (_peerName == null)
127 | return _peerUserId.ToString();
128 |
129 | return _peerName;
130 | }
131 | }
132 |
133 | public EndPoint[] PeerEPs
134 | { get { return _peerEPs; } }
135 |
136 | #endregion
137 | }
138 | }
139 |
--------------------------------------------------------------------------------
/MeshCore/Network/SecureChannel/SecureChannelException.cs:
--------------------------------------------------------------------------------
1 | /*
2 | Technitium Mesh
3 | Copyright (C) 2019 Shreyas Zare (shreyas@technitium.com)
4 |
5 | This program is free software: you can redistribute it and/or modify
6 | it under the terms of the GNU General Public License as published by
7 | the Free Software Foundation, either version 3 of the License, or
8 | (at your option) any later version.
9 |
10 | This program is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License
16 | along with this program. If not, see .
17 |
18 | */
19 |
20 | using System;
21 | using System.IO;
22 | using System.Net;
23 | using TechnitiumLibrary.IO;
24 |
25 | namespace MeshCore.Network.SecureChannel
26 | {
27 | public enum SecureChannelCode : byte
28 | {
29 | None = 0,
30 | RemoteError = 1,
31 | ProtocolVersionNotSupported = 2,
32 | NoMatchingCipherAvailable = 3,
33 | NoMatchingOptionsAvailable = 4,
34 | PskAuthenticationFailed = 5,
35 | PeerAuthenticationFailed = 6,
36 | UntrustedRemotePeerUserId = 7,
37 | MessageAuthenticationFailed = 8,
38 | RenegotiationFailed = 9,
39 | UnknownException = 254,
40 | }
41 |
42 | [Serializable()]
43 | public class SecureChannelException : IOException
44 | {
45 | #region variable
46 |
47 | readonly SecureChannelCode _code;
48 | readonly EndPoint _peerEP;
49 | readonly BinaryNumber _peerUserId;
50 |
51 | #endregion
52 |
53 | #region constructor
54 |
55 | public SecureChannelException()
56 | { }
57 |
58 | public SecureChannelException(string message) : base(message)
59 | { }
60 |
61 | public SecureChannelException(string message, Exception innerException) : base(message, innerException)
62 | { }
63 |
64 | public SecureChannelException(SecureChannelCode code, EndPoint peerEP, BinaryNumber peerUserId)
65 | {
66 | _code = code;
67 | _peerEP = peerEP;
68 | _peerUserId = peerUserId;
69 | }
70 |
71 | public SecureChannelException(SecureChannelCode code, EndPoint peerEP, BinaryNumber peerUserId, string message)
72 | : base(message)
73 | {
74 | _code = code;
75 | _peerEP = peerEP;
76 | _peerUserId = peerUserId;
77 | }
78 |
79 | public SecureChannelException(SecureChannelCode code, EndPoint peerEP, BinaryNumber peerUserId, string message, Exception innerException)
80 | : base(message, innerException)
81 | {
82 | _code = code;
83 | _peerEP = peerEP;
84 | _peerUserId = peerUserId;
85 | }
86 |
87 | protected SecureChannelException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context)
88 | : base(info, context)
89 | { }
90 |
91 | #endregion
92 |
93 | #region property
94 |
95 | public SecureChannelCode Code
96 | { get { return _code; } }
97 |
98 | public EndPoint PeerEP
99 | { get { return _peerEP; } }
100 |
101 | public BinaryNumber PeerUserId
102 | { get { return _peerUserId; } }
103 |
104 | #endregion
105 | }
106 | }
107 |
--------------------------------------------------------------------------------
/MeshCore/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("Mesh Core")]
9 | [assembly: AssemblyDescription("A secure, anonymous, peer-to-peer instant messenger.")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("Technitium")]
12 | [assembly: AssemblyProduct("Mesh")]
13 | [assembly: AssemblyCopyright("Copyright © 2019")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("d6b9a05e-7417-4902-8b41-114cd0a8130e")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.1.0.0")]
36 | [assembly: AssemblyFileVersion("1.1.0.0")]
37 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | 
4 | Technitium Mesh
5 |
6 |
7 | Get a secure, anonymous, peer-to-peer instant messenger
8 | One messenger for Internet and LAN chat with end-to-end encryption
9 |
10 |
11 |
12 |
13 |
14 | Technitium Mesh is a secure, anonymous, peer-to-peer (p2p), open source instant messenger designed to provide end-to-end encryption. Primary aim of developing this instant messenger is to provide privacy which is achieved using cryptography and anonymity using Tor network. It can be used over Internet and private LAN networks (without Internet) for instant messaging and file transfer with support for private chats and group chats.
15 |
16 | Mesh is based on [Bit Chat](https://github.com/TechnitiumSoftware/BitChatClient) and is its successor. Mesh takes core ideas from its predecessor and removes a few. Notably, Mesh does not require centralized user registration and provides anonymous profile support using Tor hidden service. It also removes use of BitTorrent trackers for finding peers which was causing issues with Bit Chat since some ISPs blocking BitTorrent traffic would also block Bit Chat traffic. Instead, Mesh relies only on [Distributed Hash Tables (DHT)](https://en.wikipedia.org/wiki/Distributed_hash_table) for all purposes.
17 |
18 | Mesh allows creating both pure p2p and anonymous profiles with support for running multiple profiles concurrently. Both p2p and anonymous profiles are interoperable such that a p2p profile user can connect with an anonymous profile user via Tor Network.
19 |
20 | With Mesh, there is no meta data generated. User identifier is designed in such a way that it can be changed anytime to hide identity. Since, there is no user registration, we don't know who uses Mesh or how many people use it. In p2p mode, the connections use IPv4 or IPv6 connectivity directly to connect with peers without any server in between. With anonymous mode, all connectivity occurs over Tor network and uses Tor hidden service to accept inbound connections.
21 |
22 | # Peer-to-Peer
23 | - Serverless, peer-to-peer architecture that uses [Distributed Hash Tables (DHT)](https://en.wikipedia.org/wiki/Distributed_hash_table).
24 | - No meta data is stored since even we don't know to whom you are chatting with.
25 | - Works as LAN chat just as it works on the Internet.
26 | - Works in private LAN networks not connected to Internet.
27 | - Anonymous profiles use [Tor Network](https://www.torproject.org/) to hide your identity.
28 |
29 | # Secure
30 | - Uses RSA 2048 bit keys to generate profiles.
31 | - Provides end-to-end encryption with [Perfect Forward Secrecy (PFS)](https://en.wikipedia.org/wiki/Forward_secrecy) using DHE-2048 or ECDHE-256.
32 | - Protocol is secured with AES 256-bit encryption with [Authenticated Encryption](https://en.wikipedia.org/wiki/Authenticated_encryption).
33 | - Changeable user identifier to hide identity.
34 | - Open source implementation allows you to inspect the code.
35 |
36 | # Installation
37 | - **Windows (Setup)**: [Download setup installer](https://download.technitium.com/mesh/MeshSetup.zip)
38 | - **Windows (Standalone)**: [Download portable zip](https://download.technitium.com/mesh/MeshPortable.zip)
39 |
40 | # Frequently Asked Questions (FAQ)
41 | Read this [FAQ](https://mesh.im/faq.html) page which should answer most of your queries.
42 |
43 | # Support
44 | For support, send an email to support@technitium.com. For any issues, feedback, or feature request, create an issue on [GitHub](https://github.com/TechnitiumSoftware/Mesh/issues).
45 |
46 | # Become A Patron
47 | Make contribution to Technitium by becoming a Patron and help making new software, updates, and features possible.
48 |
49 | [Become a Patron now!](https://www.patreon.com/technitium)
50 |
--------------------------------------------------------------------------------