Skip to content

Commit f0bdef8

Browse files
committed
bandlist and boundlist
1 parent be32c68 commit f0bdef8

3 files changed

Lines changed: 36 additions & 3 deletions

File tree

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Text;
4+
5+
namespace NSmartProxy.Data
6+
{
7+
/// <summary>
8+
/// 服务的端口绑定配置以及用户的banlist
9+
/// </summary>
10+
[Serializable]
11+
public class ServerBoundConfig
12+
{
13+
public HashSet<string> UsersBanlist;
14+
public UserPortBound UserPortBoundList;
15+
16+
public class UserPortBound
17+
{
18+
public string UserName;
19+
public List<int> Bound = new List<int>();
20+
}
21+
}
22+
}

src/NSmartProxy/Authorize/NSPServerContext.cs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,32 @@ namespace NSmartProxy.Authorize
77
{
88
public class NSPServerContext
99
{
10-
public NSPClientCollection Clients = new NSPClientCollection();
11-
public Dictionary<int, NSPApp> PortAppMap = new Dictionary<int, NSPApp>(); //端口和app的映射关系
10+
public NSPClientCollection Clients;
11+
public Dictionary<int, NSPApp> PortAppMap;//端口和app的映射关系
12+
public ServerBoundConfig BoundConfig;
13+
1214
public HashSet<string> TokenCaches; //服务端会话池,登陆后的会话都在这里,每天需要做定时清理
15+
1316
private bool supportAnonymousLogin = true;
1417

1518
public NSPServerContext()
1619
{
1720
TokenCaches = new HashSet<string>();
21+
Clients = new NSPClientCollection();
22+
PortAppMap = new Dictionary<int, NSPApp>();
23+
BoundConfig = new ServerBoundConfig();
1824
}
1925

2026
/// <summary>
2127
/// 支持客户端匿名登陆
2228
/// </summary>
2329
public bool SupportAnonymousLogin { get => supportAnonymousLogin; set => supportAnonymousLogin = value; }
2430

25-
public void CloseAllSourceByClient(int clientId)
31+
/// <summary>
32+
/// 上下文中删除特定客户端
33+
/// </summary>
34+
/// <param name="clientId"></param>
35+
public void CloseAllSourceByClient(int clientId, bool addToBanlist = false)
2636
{
2737
if (Clients.ContainsKey(clientId))
2838
{

src/NSmartProxy/Extension/HttpServer_APIs.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,7 @@ public bool ForbidClient(string clientIdStr)
398398
}
399399
//TODO QQQ 加入禁用列表
400400

401+
//写入数据
401402
return true;
402403
}
403404

0 commit comments

Comments
 (0)