mirror of
https://github.com/ehang-io/nps.git
synced 2025-09-02 03:16:53 +00:00
https 、客户端与服务端连接优化
This commit is contained in:
@@ -40,7 +40,8 @@ func (s *BaseController) display(tpl ...string) {
|
||||
}
|
||||
ip := s.Ctx.Request.Host
|
||||
if strings.LastIndex(ip, ":") > 0 {
|
||||
s.Data["ip"] = utils.GetHostByName(ip[0:])
|
||||
arr := strings.Split(utils.GetHostByName(ip), ":")
|
||||
s.Data["ip"] = arr[0]
|
||||
}
|
||||
s.Data["p"] = server.Bridge.TunnelPort
|
||||
s.Data["proxyPort"] = beego.AppConfig.String("hostPort")
|
||||
|
@@ -38,7 +38,6 @@ func (s *ClientController) Add() {
|
||||
P: s.GetString("p"),
|
||||
Compress: s.GetString("compress"),
|
||||
Crypt: s.GetBoolNoErr("crypt"),
|
||||
Mux: s.GetBoolNoErr("mux"),
|
||||
},
|
||||
RateLimit: s.GetIntNoErr("rate_limit"),
|
||||
Flow: &utils.Flow{
|
||||
@@ -91,7 +90,6 @@ func (s *ClientController) Edit() {
|
||||
c.Cnf.P = s.GetString("p")
|
||||
c.Cnf.Compress = s.GetString("compress")
|
||||
c.Cnf.Crypt = s.GetBoolNoErr("crypt")
|
||||
c.Cnf.Mux = s.GetBoolNoErr("mux")
|
||||
c.Flow.FlowLimit = int64(s.GetIntNoErr("flow_limit"))
|
||||
c.RateLimit = s.GetIntNoErr("rate_limit")
|
||||
if c.Rate != nil {
|
||||
|
@@ -81,7 +81,6 @@ func (s *IndexController) Add() {
|
||||
P: s.GetString("p"),
|
||||
Compress: s.GetString("compress"),
|
||||
Crypt: s.GetBoolNoErr("crypt"),
|
||||
Mux: s.GetBoolNoErr("mux"),
|
||||
},
|
||||
Id: server.CsvDb.GetTaskId(),
|
||||
UseClientCnf: s.GetBoolNoErr("use_client"),
|
||||
@@ -136,7 +135,6 @@ func (s *IndexController) Edit() {
|
||||
t.Config.P = s.GetString("p")
|
||||
t.Config.Compress = s.GetString("compress")
|
||||
t.Config.Crypt = s.GetBoolNoErr("crypt")
|
||||
t.Config.Mux = s.GetBoolNoErr("mux")
|
||||
t.UseClientCnf = s.GetBoolNoErr("use_client")
|
||||
t.Remark = s.GetString("remark")
|
||||
if t.Client, err = server.CsvDb.GetClient(s.GetIntNoErr("client_id")); err != nil {
|
||||
|
@@ -38,13 +38,6 @@
|
||||
<option value="1">加密</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group" id="compress">
|
||||
<label class="control-label">是否TCP复用</label>
|
||||
<select class="form-control" name="crypt">
|
||||
<option value="0">不启用</option>
|
||||
<option value="1">启用</option>
|
||||
</select>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="tile-footer">
|
||||
|
@@ -43,13 +43,6 @@
|
||||
<option {{if eq true .c.Cnf.Crypt}}selected{{end}} value="1">加密</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group" id="compress">
|
||||
<label class="control-label">是否启用TCP复用(所有模式均支持)</label>
|
||||
<select class="form-control" name="mux">
|
||||
<option {{if eq false .c.Cnf.Mux}}selected{{end}} value="0">不启用</option>
|
||||
<option {{if eq true .c.Cnf.Mux}}selected{{end}} value="1">启用</option>
|
||||
</select>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="tile-footer">
|
||||
|
@@ -11,7 +11,6 @@
|
||||
<th>备注</th>
|
||||
<th>压缩方式</th>
|
||||
<th>加密</th>
|
||||
<th>多路复用</th>
|
||||
<th>用户名</th>
|
||||
<th>密码</th>
|
||||
<th>状态</th>
|
||||
@@ -126,7 +125,6 @@
|
||||
{data: "Addr"},
|
||||
{data: "Addr"},
|
||||
{data: "Addr"},
|
||||
{data: "Addr"},
|
||||
{data: "Remark"},
|
||||
{data: "Status"},
|
||||
{data: "IsConnect"},
|
||||
@@ -193,20 +191,10 @@
|
||||
render: function (data, type, row, meta) {
|
||||
return row.Cnf.U
|
||||
}
|
||||
},
|
||||
{
|
||||
targets: -8,
|
||||
render: function (data, type, row, meta) {
|
||||
if (row.Cnf.Mux == "0") {
|
||||
return "不启用"
|
||||
} else {
|
||||
return "启用"
|
||||
}
|
||||
}
|
||||
}
|
||||
,
|
||||
{
|
||||
targets: -9,
|
||||
targets: -8,
|
||||
render: function (data, type, row, meta) {
|
||||
if (row.Cnf.Crypt == "0") {
|
||||
return "不加密"
|
||||
@@ -217,7 +205,7 @@
|
||||
}
|
||||
,
|
||||
{
|
||||
targets: -10,
|
||||
targets: -9,
|
||||
render: function (data, type, row, meta) {
|
||||
return row.Cnf.Compress
|
||||
}
|
||||
|
@@ -59,13 +59,6 @@
|
||||
<option value="1">加密</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group" id="mux">
|
||||
<label class="control-label">是否TCP复用</label>
|
||||
<select class="form-control" name="mux">
|
||||
<option value="0">不启用</option>
|
||||
<option value="1">启用</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group" id="u">
|
||||
<label class="control-label">验证用户名(仅socks5,web穿透支持)</label>
|
||||
<input class="form-control" type="text" name="u" placeholder="不填则无需验证">
|
||||
|
@@ -55,13 +55,6 @@
|
||||
<option {{if eq true .t.Config.Crypt}}selected{{end}} value="1">加密</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group" id="mux">
|
||||
<label class="control-label">是否启用TCP复用(所有模式均支持)</label>
|
||||
<select class="form-control" name="mux">
|
||||
<option {{if eq false .t.Config.Mux}}selected{{end}} value="0">不启用</option>
|
||||
<option {{if eq true .t.Config.Mux}}selected{{end}} value="1">启用</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group" id="u">
|
||||
<label class="control-label">验证用户名(仅socks5,web穿透支持)</label>
|
||||
<input class="form-control" value="{{.t.Config.U}}" type="text" name="u"
|
||||
|
@@ -26,26 +26,16 @@
|
||||
</p>
|
||||
<p><b>使用步骤:</b></p>
|
||||
<ul>
|
||||
<li>将a.proxy.com,b.proxy.com解析到公网服务器{{.ip}}</li>
|
||||
<li>使用nginx监听这两个个域名,并配置ssl等……</li>
|
||||
<li>在nginx配置中添加反向代理(或直接将http监听端口改为80)<br>
|
||||
<pre><code>
|
||||
server {
|
||||
listen 80;
|
||||
server_name a.proxy.com b.proxy.com;#也可以是泛解析*.proxy.com
|
||||
#ssl等配置
|
||||
<b>location / {
|
||||
proxy_pass http://127.0.0.1:{{.proxyPort}};
|
||||
}</b>
|
||||
}
|
||||
</code></pre>
|
||||
</li>
|
||||
<li>在域名代理管理中添加一个客户端,选择压缩方式,保存。 <a href="/index/add?type=hostServer">立即添加</a></li>
|
||||
{{/*<li>在域名代理管理中找到新加的客户端(查看其vkey或者客户端命令),任意内网机器执行客户端命令</li>*/}}
|
||||
<li>将*.proxy.com解析到公网服务器{{.ip}}</li>
|
||||
<li>在客户端管理中创建一个客户端,记录下验证密钥</li>
|
||||
<li>点击该客户端的域名管理,添加两条规则规则:1、域名:a.proxy.com,内网目标:127.0.0.1:81,2、域名:b.proxy.com,内网目标:127.0.0.1:82</li>
|
||||
<li>内网客户端运行<code>
|
||||
<pre>./proxy_client server={{.ip}}:{{.p}} -vkey=客户端的密钥</pre>
|
||||
</code></pre></li>
|
||||
<li>现在访问a.proxy.com,b.proxy.com即可成功</li>
|
||||
</ul>
|
||||
<p>注:上文中提到公网ip({{.ip}})为系统自动识别,如果是在测试环境中请自行对应,默认内网客户端已经启动</p>
|
||||
<p>注:上文中提到公网ip({{.ip}})为系统自动识别,如果是在测试环境中请自行对应,<b>如需使用https请在配置文件中将https端口设置为443,和将对应的证书文件路径添加到配置文件中
|
||||
</b></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -61,10 +51,13 @@
|
||||
</p>
|
||||
<p><b>使用步骤:</b></p>
|
||||
<ul>
|
||||
<li>在tcp隧道管理中添加一条隧道,填写监听的端口(8001)、内网目标ip和目标端口(10.1.50.101:22),选择压缩方式,保存。 <a
|
||||
href="/index/add?type=tunnelServer">立即添加</a></li>
|
||||
{{/*<li>在tcp管理列表中找到新加的隧道(查看其vkey或者客户端命令),任意内网机器执行客户端命令</li>*/}}
|
||||
<li>访问公网服务器ip({{.ip}}):填写的监听端口(8001),相当于访问内网ip(10.1.50.101):目标端口(22),例如:ssh -p 8001 root@{{.ip}}</li>
|
||||
<li>在客户端管理中创建一个客户端,记录下验证密钥</li>
|
||||
<li>内网客户端运行<code>
|
||||
<pre>./proxy_client server={{.ip}}:{{.p}} -vkey=客户端的密钥</pre>
|
||||
</code></pre>
|
||||
</li>
|
||||
<li>在该客户端隧道管理中添加一条tcp隧道,填写监听的端口(8001)、内网目标ip和目标端口(10.1.50.101:22),选择压缩方式,保存。</li>
|
||||
<li>访问公网服务器ip({{.ip}}),填写的监听端口(8001),相当于访问内网ip(10.1.50.101):目标端口(22),例如:ssh -p 8001 root@{{.ip}}</li>
|
||||
</ul>
|
||||
<p>注:上文中提到公网ip({{.ip}})为系统自动识别,如果是在测试环境中请自行对应,默认内网客户端已经启动</p>
|
||||
</div>
|
||||
@@ -80,9 +73,12 @@
|
||||
</p>
|
||||
<p><b>使用步骤:</b></p>
|
||||
<ul>
|
||||
<li>在udp隧道管理中添加一条隧道,填写监听的端口(8002)、内网目标ip和目标端口(10.1.50.102:53),选择压缩方式,保存。 <a
|
||||
href="/index/add?type=udpServer">立即添加</a></li>
|
||||
{{/*<li>在udp管理列表中找到新加的隧道(查看其vkey或者客户端命令),任意内网机器执行客户端命令</li>*/}}
|
||||
<li>在客户端管理中创建一个客户端,记录下验证密钥</li>
|
||||
<li>内网客户端运行<code>
|
||||
<pre>./proxy_client server={{.ip}}:{{.p}} -vkey=客户端的密钥</pre>
|
||||
</code></pre>
|
||||
</li>
|
||||
<li>在该客户端的隧道管理中添加一条udp隧道,填写监听的端口(53)、内网目标ip和目标端口(10.1.50.102:53),选择压缩方式,保存。</li>
|
||||
<li>修改本机dns为{{.ip}},则相当于使用10.1.50.202作为dns服务器</li>
|
||||
</ul>
|
||||
<p>注:上文中提到公网ip({{.ip}})为系统自动识别,如果是在测试环境中请自行对应,默认内网客户端已经启动</p>
|
||||
@@ -101,9 +97,12 @@
|
||||
</p>
|
||||
<p><b>使用步骤:</b></p>
|
||||
<ul>
|
||||
<li>在socks5隧道管理中添加一条隧道,填写监听的端口(8003),验证用户名和密码自行选择(建议先不填,部分客户端不支持,proxifer支持),选择压缩方式,保存。 <a
|
||||
href="/index/add?type=sock5Server">立即添加</a></li>
|
||||
{{/*<li>在socks5代理管理列表中找到新加的隧道(查看其vkey或者客户端命令),任意内网机器执行客户端命令</li>*/}}
|
||||
<li>在客户端管理中创建一个客户端,记录下验证密钥</li>
|
||||
<li>内网客户端运行<code>
|
||||
<pre>./proxy_client server={{.ip}}:{{.p}} -vkey=客户端的密钥</pre>
|
||||
</code></pre>
|
||||
</li>
|
||||
<li>在该客户端隧道管理中添加一条socks5代理,填写监听的端口(8003),验证用户名和密码自行选择(建议先不填,部分客户端不支持,proxifer支持),选择压缩方式,保存。</li>
|
||||
<li>在外网环境的本机配置socks5代理,ip为公网服务器ip({{.ip}}),端口为填写的监听端口(8003),即可畅享内网了</li>
|
||||
</ul>
|
||||
<p>注:上文中提到公网ip({{.ip}})为系统自动识别,如果是在测试环境中请自行对应,默认内网客户端已经启动</p>
|
||||
@@ -120,13 +119,23 @@
|
||||
</p>
|
||||
<p><b>使用步骤:</b></p>
|
||||
<ul>
|
||||
<li>在http隧道管理中添加一条隧道,填写监听的端口(8004),选择压缩方式,保存。 <a
|
||||
href="/index/add?type=httpProxyServer">立即添加</a></li>
|
||||
<li>在http代理管理列表中找到新加的隧道(查看其vkey或者客户端命令),任意内网机器执行客户端命令</li>
|
||||
<li>在客户端管理中创建一个客户端,记录下验证密钥</li>
|
||||
<li>内网客户端运行<code>
|
||||
<pre>./proxy_client server={{.ip}}:{{.p}} -vkey=客户端的密钥</pre>
|
||||
</code></pre>
|
||||
</li>
|
||||
<li>在该客户端隧道管理中添加一条http代理,填写监听的端口(8004),选择压缩方式,保存。</li>
|
||||
<li>在外网环境的本机配置http代理,ip为公网服务器ip({{.ip}}),端口为填写的监听端口(8004),即可访问了</li>
|
||||
</ul>
|
||||
<p>注:上文中提到公网ip({{.ip}})为系统自动识别,如果是在测试环境中请自行对应,默认内网客户端已经启动</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-12">
|
||||
<div class="tile">
|
||||
<p><b>单个客户端可以田间多条隧道或者域名解析</b></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</main>
|
||||
|
@@ -12,7 +12,6 @@
|
||||
<th>host改写</th>
|
||||
<th>压缩方式</th>
|
||||
<th>加密</th>
|
||||
<th>多路复用</th>
|
||||
<th>用户名</th>
|
||||
<th>密码</th>
|
||||
<th>出口流量</th>
|
||||
@@ -84,7 +83,6 @@
|
||||
{data: 'HostChange'},
|
||||
{data: 'HostChange'},
|
||||
{data: 'HostChange'},
|
||||
{data: 'HostChange'},
|
||||
{data: 'Target'},
|
||||
],
|
||||
bFilter: false,
|
||||
@@ -127,20 +125,10 @@
|
||||
render: function (data, type, row, meta) {
|
||||
return row.Client.Cnf.U
|
||||
}
|
||||
},
|
||||
{
|
||||
targets: -6,
|
||||
render: function (data, type, row, meta) {
|
||||
if (row.Client.Cnf.Mux == "0") {
|
||||
return "不启用"
|
||||
} else {
|
||||
return "启用"
|
||||
}
|
||||
}
|
||||
}
|
||||
,
|
||||
{
|
||||
targets: -7,
|
||||
targets: -6,
|
||||
render: function (data, type, row, meta) {
|
||||
if (row.Client.Cnf.Crypt == "0") {
|
||||
return "不加密"
|
||||
@@ -151,7 +139,7 @@
|
||||
}
|
||||
,
|
||||
{
|
||||
targets: -8,
|
||||
targets: -7,
|
||||
render: function (data, type, row, meta) {
|
||||
return row.Client.Cnf.Compress
|
||||
}
|
||||
|
@@ -12,7 +12,6 @@
|
||||
<th>内网目标</th>
|
||||
<th>压缩方式</th>
|
||||
<th>加密传输</th>
|
||||
<th>TCP多路复用</th>
|
||||
<th>用户名</th>
|
||||
<th>密码</th>
|
||||
<th>客户端状态</th>
|
||||
@@ -114,7 +113,6 @@
|
||||
{data: 'Target'},
|
||||
{data: 'Compress'},
|
||||
{data: 'Crypt'},
|
||||
{data: 'Mux'},
|
||||
{data: 'U'},
|
||||
{data: 'P'},
|
||||
{data: 'ClientStatus'},
|
||||
@@ -152,7 +150,7 @@
|
||||
}
|
||||
}
|
||||
}, {
|
||||
targets: 8,
|
||||
targets: 7,
|
||||
render: function (data, type, row, meta) {
|
||||
if (row.UseClientCnf == true) {
|
||||
return row.Client.Cnf.U
|
||||
@@ -161,7 +159,7 @@
|
||||
}
|
||||
}
|
||||
}, {
|
||||
targets: 9,
|
||||
targets: 8,
|
||||
render: function (data, type, row, meta) {
|
||||
if (row.UseClientCnf == true) {
|
||||
return row.Client.Cnf.P
|
||||
@@ -181,7 +179,7 @@
|
||||
}
|
||||
},
|
||||
{
|
||||
targets: -9,
|
||||
targets: -8,
|
||||
render: function (data, type, row, meta) {
|
||||
if (row.UseClientCnf == true) {
|
||||
crypt = row.Client.Cnf.Crypt
|
||||
@@ -195,21 +193,6 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
targets: -8,
|
||||
render: function (data, type, row, meta) {
|
||||
if (row.UseClientCnf == true) {
|
||||
mux = row.Client.Cnf.Mux
|
||||
} else {
|
||||
mux = row.Config.Mux
|
||||
}
|
||||
if (mux == "0") {
|
||||
return "不启用"
|
||||
} else {
|
||||
return "启用"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
targets: -5,
|
||||
render: function (data, type, row, meta) {
|
||||
|
Reference in New Issue
Block a user