This repository was archived by the owner on Apr 2, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 52
Expand file tree
/
Copy pathNameServer.cs
More file actions
107 lines (100 loc) · 3.66 KB
/
NameServer.cs
File metadata and controls
107 lines (100 loc) · 3.66 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
using System;
using System.IO;
using System.Net;
using System.Text;
using System.Threading;
using Newtonsoft.Json;
using start;
namespace server
{
// Token: 0x02000050 RID: 80
internal class NameServer
{
// Token: 0x06000227 RID: 551 RVA: 0x00006D1C File Offset: 0x00004F1C
public NameServer()
{
try
{
Console.WriteLine("[NameServer.cs] has started.");
new Thread(new ThreadStart(this.StartListen)).Start();
new Thread(new ThreadStart(this.StartListen2)).Start();
}
catch (Exception ex)
{
Console.WriteLine("An Exception Occurred while Listening :" + ex.ToString());
}
}
// Token: 0x06000228 RID: 552 RVA: 0x00006D84 File Offset: 0x00004F84
private void StartListen()
{
//nameserver is ONLY for 2018
this.listener.Prefixes.Add("http://localhost:20181/");
for (; ; )
{
this.listener.Start();
Console.WriteLine("[NameServer.cs] is listening.");
HttpListenerContext context = this.listener.GetContext();
HttpListenerRequest request = context.Request;
HttpListenerResponse response = context.Response;
string rawUrl = request.RawUrl;
string s = "";
NSData data = new NSData()
{
API = "http://localhost:2018",
Notifications = "http://localhost:20161",
Images = "http://localhost:20182"
};
s = JsonConvert.SerializeObject(data);
Console.WriteLine("API Response: " + s);
byte[] bytes = Encoding.UTF8.GetBytes(s);
response.ContentLength64 = (long)bytes.Length;
Stream outputStream = response.OutputStream;
outputStream.Write(bytes, 0, bytes.Length);
Thread.Sleep(400);
outputStream.Close();
this.listener.Stop();
}
}
private void StartListen2()
{
//nameserver is ONLY for 2018
this.listener2.Prefixes.Add("http://localhost:56/");
for (; ; )
{
this.listener2.Start();
Console.WriteLine("[NameServer2.cs] is listening.");
HttpListenerContext context = this.listener2.GetContext();
HttpListenerRequest request = context.Request;
HttpListenerResponse response = context.Response;
string rawUrl = request.RawUrl;
string s = "";
NSData data = new NSData()
{
API = "http://localhost:2018",
Notifications = "http://localhost:20161",
Images = "http://localhost:20182"
};
s = JsonConvert.SerializeObject(data);
Console.WriteLine("API Response: " + s);
byte[] bytes = Encoding.UTF8.GetBytes(s);
response.ContentLength64 = (long)bytes.Length;
Stream outputStream = response.OutputStream;
outputStream.Write(bytes, 0, bytes.Length);
Thread.Sleep(500);
outputStream.Close();
this.listener2.Stop();
}
}
public static string VersionCheckResponse = "{\"ValidVersion\":true}";
public static string BlankResponse = "";
public class NSData
{
public string API { get; set; }
public string Notifications { get; set; }
public string Images { get; set; }
}
// Token: 0x04000192 RID: 402
private HttpListener listener = new HttpListener();
private HttpListener listener2 = new HttpListener();
}
}