-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbanlist.cs
More file actions
57 lines (50 loc) · 1.34 KB
/
Copy pathbanlist.cs
File metadata and controls
57 lines (50 loc) · 1.34 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
using System;
using System.Collections.Generic;
using System.IO;
namespace DK_UDP_Bot
{
public class BanList
{
public string ip;
public ushort port;
public BanList ()
{
reset();
}
private void reset ()
{
ip = string.Empty;
port = 0;
}
}
public partial class Program
{
List<BanList> bannedIPs = new List<BanList>();
string BanListFileName = string.Empty;
public void Init_BanList ()
{
if (String.IsNullOrWhiteSpace(BanListFileName))
{
return;
}
if (!System.IO.File.Exists(BanListFileName))
{
Console.Write("Ban list file {0} does not exist.\n", BanListFileName);
}
using (StreamReader sr = new StreamReader(BanListFileName))
{
while (!sr.EndOfStream)
{
ushort _port = 0;
var line = sr.ReadLine().Split(':');
if (line.Length != 2)
{
continue;
}
ushort.TryParse(line[1], out _port);
bannedIPs.Add(new BanList { ip = line[0], port = _port });
}
}
}
}
}