Skip to content

Commit a29ce87

Browse files
committed
20191218
1 parent 3b68b68 commit a29ce87

File tree

363 files changed

+15226
-3213
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

363 files changed

+15226
-3213
lines changed

Doc/Basic Component.jpg

38.1 KB
Loading

Doc/HP-Socket Class Diagram.uml

Lines changed: 4478 additions & 1192 deletions
Large diffs are not rendered by default.
60.5 KB
Binary file not shown.
8.8 KB
Loading

DotNet/README.md

Lines changed: 166 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,166 @@
1+
# [HPSocket.Net](https://gitee.com/int2e/HPSocket.Net)
2+
3+
## Overview
4+
#### .Net Framework Supported
5+
* `.Net Framework 2.0+`
6+
* `.Net Core 2.0+`
7+
8+
#### Platform supported
9+
* `Windows 7+ x86/x64`
10+
* `Linux kernel 2.6.32+ x86/x64`
11+
* `mac OS 10.12+ x64`
12+
13+
## Installation Guide
14+
`HPSocket.Net` deploy via NuGet package manager
15+
16+
Use the following command in the Package Manager console to manually install `HPSocket.Net`
17+
```
18+
Install-Package HPSocket.Net
19+
```
20+
Or right-click on the project name in the solution of Visual Studio-> Manage NuGet Packages-> Browse the page-> search box and enter HPSocket.Net and then install
21+
22+
23+
### About macOS
24+
`HPSocket.Net` now supports development using` .net core2.0 + `in` osx 10.12 + `
25+
26+
`Libhpsocket4c.dylib` in Nuget package is compiled from [HP-Socket-for-macOS](https://gitee.com/xin_chong/HP-Socket-for-macOS)
27+
28+
29+
## Components List
30+
### Basic COmponents
31+
Basic component is the original component provided by HP-Socket. For related usage, please refer to [HP-Socket Doc](https://github.com/ldcsaa/HP-Socket/tree/master/Doc)
32+
33+
##### TCP
34+
+ `ITcpServer`
35+
+ `ITcpAgent`
36+
+ `ITcpClient`
37+
+ `ITcpPullServer`
38+
+ `ITcpPullAgent`
39+
+ `ITcpPullClient`
40+
+ `ITcpPackServer`
41+
+ `ITcpPackAgent`
42+
+ `ITcpPacClient`
43+
44+
##### UDP
45+
+ `IUdpServer`
46+
+ `IUdpClient`
47+
+ `IUdpCast`
48+
+ `IUdpArqServer`
49+
+ `IUdpArqClient`
50+
+ `IUdpNode`
51+
52+
##### SSL
53+
+ `ISslServer`
54+
+ `ISslAgent`
55+
+ `ISslClient`
56+
+ `ISslPullServer`
57+
+ `ISslPullAgent`
58+
+ `ISslPullClient`
59+
+ `ISslPackServer`
60+
+ `ISslPackAgent`
61+
+ `ISslPackClient`
62+
63+
##### HTTP
64+
+ `IHttpServer`
65+
+ `IHttpsServer`
66+
+ `IHttpAgent`
67+
+ `IHttpsAgent`
68+
+ `IHttpClient`
69+
+ `IHttpsClient`
70+
+ `IHttpSyncClient`
71+
+ `IHttpsSyncClient`
72+
73+
#### ThreadPool
74+
+ `ThreadPool`
75+
76+
### Extended components
77+
+ `ITcpPortForwarding`
78+
+ `IHttpEasyServer`
79+
+ `IHttpsEasyServer`
80+
+ `IHttpEasyAgent`
81+
+ `IHttpsEasyAgent`
82+
+ `IHttpEasyClient`
83+
+ `IHttpsEasyClient`
84+
+ `IWebSocketServer`
85+
+ `IWebSocketAgent`
86+
87+
`HPSocket.Net` provides a TCP port forwarding component` ITcpPortForwarding`, 10 lines of code can complete TCP port forwarding.
88+
89+
`HPSocket.Net` currently provides 6 Easy components and 2 WebSocket components for easier processing of http / https / ws data packets. The basic http components provided by `HP-Socket` need to implement the data packets themselves. Complete acquisition, Easy component has done these processing, http / https Easy component is bound to the following events, when the event arrives, you can get the complete data packet.
90+
91+
+ `OnEasyChunkData` Complete packet event for http CHUNK message
92+
+ `OnEasyMessageData` Complete packet event for http GET or POST message
93+
+ `OnEasyWebSocketMessageData` Complete packet event for WebSocket message
94+
95+
`WebSocket` can also use the following two components directly
96+
97+
+ `IWebSocketServer` WebSocket Server
98+
+ `IWebSocketAgent` WebSocket Client (Unlike other Agent components, the WebSocket Agent component does not support connecting to different WebSocket Servers, which means that all connections of the `IWebSocketAgent` component can only connect to the same server)
99+
100+
101+
## Instructions
102+
1. For the use of most components, please refer to the project in the `demo` directory.
103+
2. In addition to the `Pack` series model, the `Agent` series components provided by `HPSocket.Net` (including the `ITcpPortForwarding` component) support to setting `HTTP` or `Socks5` proxy, which can be set in the manner of`List<IProxy>`. Multiple proxies can be set at the same time, which will be used randomly, and can be mixed with `HTTP` and `Socks5` proxy at the same time. For the usage method, refer to the `demo` of each` Agent` component.
104+
105+
### Easy component event binding example
106+
107+
#### IHttpEasyServer
108+
```cs
109+
// Create HttpEasyServer instance
110+
using(IHttpEasyServer httpServer = new HttpEasyServer())
111+
{
112+
// ... other settings
113+
114+
// Binding OnEasyMessageData event
115+
httpServer.OnEasyMessageData += (sender, id, data) =>
116+
{
117+
// The data parameter is a complete packet each time
118+
// ... Process data
119+
120+
return HttpParseResult.Ok;
121+
};
122+
}
123+
```
124+
125+
#### IHttpEasyAgent
126+
```cs
127+
// Create HttpEasyAgent instance
128+
using(IHttpEasyAgent httpAgent = new HttpEasyAgent())
129+
{
130+
// ... other settings
131+
132+
// Binding OnEasyMessageData event
133+
httpAgent.OnEasyMessageData += (sender, id, data) =>
134+
{
135+
// The data parameter is a complete packet each time
136+
// ... Process data
137+
138+
return HttpParseResult.Ok;
139+
};
140+
}
141+
```
142+
143+
#### IHttpEasyClient
144+
```cs
145+
// Create HttpEasyClient instance
146+
using(IHttpEasyClient httpClient = new HttpEasyClient())
147+
{
148+
// ... other settings
149+
150+
// Binding OnEasyMessageData event
151+
httpClient.OnEasyMessageData += (sender, data) =>
152+
{
153+
// The data parameter is a complete packet each time
154+
// ... Process data
155+
156+
return HttpParseResult.Ok;
157+
};
158+
}
159+
```
160+
161+
## Contribute
162+
163+
1. Fork this Repository
164+
2. Create a new Feat_xxx branch
165+
3. Submit code
166+
4. Create a new Pull Request

DotNet/README_zh.md

Lines changed: 166 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,166 @@
1+
# [HPSocket.Net](https://gitee.com/int2e/HPSocket.Net)
2+
3+
## 概览
4+
#### .Net 框架支持
5+
* `.Net Framework 2.0+`
6+
* `.Net Core 2.0+`
7+
8+
#### 平台支持
9+
* `Windows 7+ x86/x64`
10+
* `Linux kernel 2.6.32+ x86/x64`
11+
* `mac OS 10.12+ x64`
12+
13+
## 安装教程
14+
`HPSocket.Net`通过NuGet软件包管理器部署
15+
16+
在 Package Manager 控制台中使用以下命令来手动安装 `HPSocket.Net`
17+
```
18+
Install-Package HPSocket.Net
19+
```
20+
或在`Visual Studio`的解决方案中的`项目名``鼠标右键`->`管理 NuGet 程序包`->`浏览`页面->搜索框输入`HPSocket.Net`->然后安装
21+
22+
23+
### 关于macOS
24+
`HPSocket.Net`现在支持在`osx 10.12+`中使用`.net core2.0+`进行开发
25+
26+
Nuget软件包中的`libhpsocket4c.dylib`编译自`HP-Socket``macOS分支`[HP-Socket-for-macOS](https://gitee.com/xin_chong/HP-Socket-for-macOS)
27+
28+
29+
## 组件列表
30+
### 基础组件
31+
基础组件是`HP-Socket`提供的原始组件, 相关使用方法请参考[HP-Socket Doc](https://github.com/ldcsaa/HP-Socket/tree/master/Doc)
32+
33+
##### TCP
34+
+ `ITcpServer`
35+
+ `ITcpAgent`
36+
+ `ITcpClient`
37+
+ `ITcpPullServer`
38+
+ `ITcpPullAgent`
39+
+ `ITcpPullClient`
40+
+ `ITcpPackServer`
41+
+ `ITcpPackAgent`
42+
+ `ITcpPacClient`
43+
44+
##### UDP
45+
+ `IUdpServer`
46+
+ `IUdpClient`
47+
+ `IUdpCast`
48+
+ `IUdpArqServer`
49+
+ `IUdpArqClient`
50+
+ `IUdpNode`
51+
52+
##### SSL
53+
+ `ISslServer`
54+
+ `ISslAgent`
55+
+ `ISslClient`
56+
+ `ISslPullServer`
57+
+ `ISslPullAgent`
58+
+ `ISslPullClient`
59+
+ `ISslPackServer`
60+
+ `ISslPackAgent`
61+
+ `ISslPackClient`
62+
63+
##### HTTP
64+
+ `IHttpServer`
65+
+ `IHttpsServer`
66+
+ `IHttpAgent`
67+
+ `IHttpsAgent`
68+
+ `IHttpClient`
69+
+ `IHttpsClient`
70+
+ `IHttpSyncClient`
71+
+ `IHttpsSyncClient`
72+
73+
#### ThreadPool
74+
+ `ThreadPool`
75+
76+
### 扩展组件
77+
+ `ITcpPortForwarding`
78+
+ `IHttpEasyServer`
79+
+ `IHttpsEasyServer`
80+
+ `IHttpEasyAgent`
81+
+ `IHttpsEasyAgent`
82+
+ `IHttpEasyClient`
83+
+ `IHttpsEasyClient`
84+
+ `IWebSocketServer`
85+
+ `IWebSocketAgent`
86+
87+
`HPSocket.Net` 提供一个Tcp端口转发组件`ITcpPortForwarding`, 10行代码即可完成TCP端口转发
88+
89+
`HPSocket.Net`目前提供6个Easy组件和2个WebSocket组件, 用来更简单的处理http/https/ws的数据包, `HP-Socket`提供的基础http组件, 需要自己来实现数据包的完整获取, Easy组件已经做了这些处理, http/https的Easy组件绑定以下事件, 当事件到达, 即可获得完整数据包
90+
91+
+ `OnEasyChunkData` http CHUNK消息的完整数据包事件
92+
+ `OnEasyMessageData` http GET或POST的完整数据包事件
93+
+ `OnEasyWebSocketMessageData` WebSocket消息的完整数据包事件
94+
95+
`WebSocket` 也可以直接使用以下两个组件
96+
97+
+ `IWebSocketServer` WebSocket 服务端
98+
+ `IWebSocketAgent` WebSocket 客户端 (与其他Agent组件不同, WebSocket的Agent组件不支持连接到不同的WebSocket Server, 也就是说`IWebSocketAgent`组件所有的连接都只能连接到同一个服务器)
99+
100+
101+
## 使用说明
102+
1. 大部分组件使用方法请参考`demo`目录下的工程
103+
2. `HPSocket.Net`提供的`Agent`系列组件除`Pack`系列模型外, 包括`ITcpPortForwarding`组件, 都支持设置`http``socks5`代理, 以`List<IProxy>`方式设置, 可同时设置多个代理, 组件内部会随机使用, 可以同时混用`http``socks5`代理, 使用方法参考各`Agent`组件的`demo`
104+
105+
### Easy扩展组件事件绑定示例
106+
107+
#### IHttpEasyServer
108+
```cs
109+
// 创建 HttpEasyServer 的实例
110+
using(IHttpEasyServer httpServer = new HttpEasyServer())
111+
{
112+
// ...其他设置
113+
114+
// 绑定 OnEasyMessageData 事件
115+
httpServer.OnEasyMessageData += (sender, id, data) =>
116+
{
117+
// data 参数每次都是一个完整的数据包
118+
// ... 处理 data
119+
120+
return HttpParseResult.Ok;
121+
};
122+
}
123+
```
124+
125+
#### IHttpEasyAgent
126+
```cs
127+
// 创建 HttpEasyAgent 的实例
128+
using(IHttpEasyAgent httpAgent = new HttpEasyAgent())
129+
{
130+
// ...其他设置
131+
132+
// 绑定 OnEasyMessageData 事件
133+
httpAgent.OnEasyMessageData += (sender, id, data) =>
134+
{
135+
// data 参数每次都是一个完整的数据包
136+
// ... 处理 data
137+
138+
return HttpParseResult.Ok;
139+
};
140+
}
141+
```
142+
143+
#### IHttpEasyClient
144+
```cs
145+
// 创建 HttpEasyClient 的实例
146+
using(IHttpEasyClient httpClient = new HttpEasyClient())
147+
{
148+
// ...其他设置
149+
150+
// 绑定 OnEasyMessageData 事件
151+
httpClient.OnEasyMessageData += (sender, data) =>
152+
{
153+
// data 参数每次都是一个完整的数据包
154+
// ... 处理 data
155+
156+
return HttpParseResult.Ok;
157+
};
158+
}
159+
```
160+
161+
## 参与贡献
162+
163+
1. Fork 本仓库
164+
2. 新建 Feat_xxx 分支
165+
3. 提交代码
166+
4. 新建 Pull Request

0 commit comments

Comments
 (0)