-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathServerInfo.cs
More file actions
112 lines (100 loc) · 3.21 KB
/
ServerInfo.cs
File metadata and controls
112 lines (100 loc) · 3.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
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
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
110
111
112
using M9Studio.SecureStream;
using M9Studio.ShadowTalk.Core;
using System.Net;
using System.Net.Sockets;
using System.Numerics;
namespace M9Studio.ShadowTalk.Client
{
public class ServerInfo
{
public int ServerId;
public string ServerName;
public string IP;
public int Port;
//для расшифровки сообщений
public string RSA;
public string Name;
public int Id;
public string K;
public string PrivateA;
public string PublicA;
private string _token = null;
public string token
{
get
{
if (_token == null)
{
long timestamp = DateTimeOffset.UtcNow.ToUnixTimeSeconds();
_token = $"{Id}:{timestamp}";
}
return _token;
}
}
public string hmac => SRPHelper.ComputeHMAC(Convert.FromHexString(K), token);
private SecureChannelManager<IPEndPoint> _ChannelManager;
public SecureChannelManager<IPEndPoint> ChannelManager
{
get => _ChannelManager;
set
{
_ChannelManager = value;
if (value == null)
{
foreach (var item in Users)
{
item.Value.Panel.labelServer.ForeColor = Color.Red;
if(item.Value.Form != null)
{
item.Value.Form.labelServer.ForeColor = Color.Red;
}
}
}
else
{
foreach (var item in Users)
{
item.Value.Panel.labelServer.ForeColor = Color.Yellow;
if (item.Value.Form != null)
{
item.Value.Form.labelServer.ForeColor = Color.Yellow;
}
}
}
}
}
private SecureSession<IPEndPoint> _Session;
public SecureSession<IPEndPoint> Session
{
get => _Session;
set
{
_Session = value;
if (value == null)
{
foreach (var item in Users)
{
item.Value.Panel.labelServer.ForeColor = Color.Red;
if (item.Value.Form != null)
{
item.Value.Form.labelServer.ForeColor = Color.Red;
}
}
}
else
{
foreach (var item in Users)
{
item.Value.Panel.labelServer.ForeColor = Color.Green;
if (item.Value.Form != null)
{
item.Value.Form.labelServer.ForeColor = Color.Green;
}
}
}
}
}
public Socket Socket;
public Dictionary<int, User> Users = new Dictionary<int, User>();
}
}