Skip to content

Commit a8c2785

Browse files
committed
v2.1 调整代码结构,支持native打包;clientId校验缺陷调整为用户名、密码校验
1 parent 3b53718 commit a8c2785

File tree

7 files changed

+313
-19
lines changed

7 files changed

+313
-19
lines changed

_doc/demo/hppt.md

+115
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
## 示例1 通过http端口,websocket反向代理访问内部服务器SSH端口
2+
3+
假设你有一个服务器集群,仅有一个nginx提供了80/443端口对外访问(111.222.33.44:80),你想要访问集群中的应用服务器(192.168.0.2)的22端口,则可以按如下结构部署
4+
5+
![示例1](../img/hpptdemo.jpg)
6+
7+
1、在集群中任一服务器上新建一个hppt目录,并上传hppt.jar(也可用可执行文件 hppt.exe 或 hppt)、ss.yml、log4j2.xml文件到此目录下:
8+
9+
```
10+
hppt
11+
- hppt.jar (or hppt.exe or hppt_linux_file)
12+
- ss.yml
13+
- log4j2.xml
14+
```
15+
16+
并调整ss.yml的配置信息:
17+
18+
```yaml
19+
type: hppt
20+
#服务端口
21+
port: 20871
22+
# 允许的客户端账号和密码
23+
clients:
24+
- user: user1
25+
password: 12345
26+
- user: user2
27+
password: 112233
28+
29+
```
30+
(注1:作为快速演示,这里的type选择了最简单的post类型,此场景下最佳性能的协议为websocket,或是有独立端口的话可以配置hppt协议,ws、hppt版的说明奋力码字中。。)
31+
32+
(注2:实际应用中,为了确保安全,建议把clientId设置得更复杂一些)
33+
34+
执行如下命令运行服务端的hppt(3选1)
35+
36+
jar包运行
37+
```shell
38+
cd hppt
39+
<jdk21_path>/bin/java -jar hppt.jar ss ss.yml
40+
```
41+
42+
windows下可执行文件运行
43+
```shell
44+
cd hppt
45+
chcp 65001
46+
hppt.exe ss ss.yml
47+
```
48+
49+
linux下可执行文件运行
50+
```shell
51+
cd hppt
52+
./hppt ss ss.yml
53+
#后台运行用命令 nohup ./hppt ss ss.yml >/dev/null &
54+
```
55+
56+
2、自己笔记本上,新建一个hppt目录,拷贝hppt.jar (or hppt.exe or hppt_linux_file)、sc.yml、log4j2.xml文件到此目录下:
57+
58+
```
59+
hppt
60+
- hppt.jar (or hppt.exe or hppt_linux_file)
61+
- sc.yml
62+
- log4j2.xml
63+
```
64+
65+
并调整sc.yml的配置信息:
66+
67+
```yaml
68+
# 和服务端的type保持一致
69+
type: hppt
70+
# 客户端用户名,每个sc进程用一个,不要重复
71+
clientUser: user1
72+
# 客户端密码
73+
clientPassword: 12345
74+
75+
hppt:
76+
#服务端地址
77+
host: "111.222.33.44"
78+
#服务端端口
79+
port: 20871
80+
forwards:
81+
# 把192.168.0.2的22端口代理到本机的10022端口
82+
- localPort: 10022
83+
remoteHost: "192.168.0.2"
84+
remotePort: 22
85+
# 同理也可以代理数据库等任意TCP端口,只要服务端的hppt所在服务器能访问到的端口都行
86+
- localPort: 10023
87+
remoteHost: "192.168.0.3"
88+
remotePort: 3306
89+
90+
91+
```
92+
93+
执行如下命令启动客户端的hppt(3选1)
94+
95+
jar包运行
96+
```shell
97+
cd hppt
98+
<jdk21_path>/bin/java -jar hppt.jar sc sc.yml
99+
```
100+
101+
windows下可执行文件运行
102+
```shell
103+
cd hppt
104+
chcp 65001
105+
hppt.exe sc sc.yml
106+
```
107+
108+
linux下可执行文件运行
109+
```shell
110+
cd hppt
111+
./hppt sc sc.yml
112+
#后台运行用命令 nohup ./hppt ss ss.yml >/dev/null &
113+
```
114+
115+
随后,你就可以在公司用linux连接工具访问localhost的10022端口,来登录应用服务器了

_doc/demo/websocket.md

+138
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
## 示例1 通过http端口,websocket反向代理访问内部服务器SSH端口
2+
3+
假设你有一个服务器集群,仅有一个nginx提供了80/443端口对外访问(111.222.33.44:80),你想要访问集群中的应用服务器(192.168.0.2)的22端口,则可以按如下结构部署
4+
5+
![示例1](../img/3.jpg)
6+
7+
1、在集群中任一服务器上新建一个hppt目录,并上传hppt.jar(也可用可执行文件 hppt.exe 或 hppt)、ss.yml、log4j2.xml文件到此目录下:
8+
9+
```
10+
hppt
11+
- hppt.jar (or hppt.exe or hppt_linux_file)
12+
- ss.yml
13+
- log4j2.xml
14+
```
15+
16+
并调整ss.yml的配置信息:
17+
18+
```yaml
19+
type: websocket
20+
#服务端口
21+
port: 20871
22+
# 允许的客户端账号和密码
23+
clients:
24+
- user: user1
25+
password: 12345
26+
- user: user2
27+
password: 112233
28+
29+
```
30+
(注1:作为快速演示,这里的type选择了最简单的post类型,此场景下最佳性能的协议为websocket,或是有独立端口的话可以配置hppt协议,ws、hppt版的说明奋力码字中。。)
31+
32+
(注2:实际应用中,为了确保安全,建议把clientId设置得更复杂一些)
33+
34+
执行如下命令运行服务端的hppt(3选1)
35+
36+
jar包运行
37+
```shell
38+
cd hppt
39+
<jdk21_path>/bin/java -jar hppt.jar ss ss.yml
40+
```
41+
42+
windows下可执行文件运行
43+
```shell
44+
cd hppt
45+
chcp 65001
46+
hppt.exe ss ss.yml
47+
```
48+
49+
linux下可执行文件运行
50+
```shell
51+
cd hppt
52+
./hppt ss ss.yml
53+
#后台运行用命令 nohup ./hppt ss ss.yml >/dev/null &
54+
```
55+
56+
57+
在nginx上增加一段配置指向hppt
58+
59+
```
60+
server {
61+
# 用https也ok的,对应修改nginx https配置即可
62+
listen 80;
63+
...
64+
location /aaa/ {
65+
proxy_redirect off;
66+
proxy_pass http://win10:20871/s;
67+
proxy_http_version 1.1;
68+
proxy_set_header Upgrade $http_upgrade;
69+
proxy_set_header Connection "upgrade";
70+
proxy_set_header Host $http_host;
71+
}
72+
73+
...
74+
```
75+
76+
随后,访问`http://111.222.33.44:80/aaa/` 能看到“not a WebSocket handshake request”字样即证明服务端部署成功。
77+
78+
2、自己笔记本上,新建一个hppt目录,拷贝hppt.jar (or hppt.exe or hppt_linux_file)、sc.yml、log4j2.xml文件到此目录下:
79+
80+
```
81+
hppt
82+
- hppt.jar
83+
- sc.yml
84+
- log4j2.xml
85+
```
86+
87+
并调整sc.yml的配置信息:
88+
89+
```yaml
90+
# 和服务端的type保持一致
91+
type: websocket
92+
# 客户端用户名,每个sc进程用一个,不要重复
93+
clientUser: user1
94+
# 客户端密码
95+
clientPassword: 12345
96+
97+
98+
websocket:
99+
#服务端http地址,可以填nginx转发过的地址
100+
serverUrl: "ws://111.222.33.44:80/aaa"
101+
# 服务端http地址,不用nginx的话直接配原始的服务端端口
102+
#serverUrl: "ws://111.222.33.44:20871"
103+
forwards:
104+
# 把192.168.0.2的22端口代理到本机的10022端口
105+
- localPort: 10022
106+
remoteHost: "192.168.0.2"
107+
remotePort: 22
108+
# 同理也可以代理数据库等任意TCP端口,只要服务端的hppt所在服务器能访问到的端口都行
109+
- localPort: 10023
110+
remoteHost: "192.168.0.3"
111+
remotePort: 3306
112+
113+
114+
```
115+
116+
执行如下命令启动客户端的hppt(3选1)
117+
118+
jar包运行
119+
```shell
120+
cd hppt
121+
<jdk21_path>/bin/java -jar hppt.jar sc sc.yml
122+
```
123+
124+
windows下可执行文件运行
125+
```shell
126+
cd hppt
127+
chcp 65001
128+
hppt.exe sc sc.yml
129+
```
130+
131+
linux下可执行文件运行
132+
```shell
133+
cd hppt
134+
./hppt sc sc.yml
135+
#后台运行用命令 nohup ./hppt ss ss.yml >/dev/null &
136+
```
137+
138+
随后,你就可以在公司用linux连接工具访问localhost的10022端口,来登录应用服务器了

_doc/img/hpptdemo.jpg

38.6 KB
Loading

_doc/page/kafkademo.md

Whitespace-only changes.

_doc/readme.pptx

5.15 KB
Binary file not shown.

0 commit comments

Comments
 (0)