Skip to content

Commit 9499e4d

Browse files
committed
1
1 parent 178b899 commit 9499e4d

31 files changed

Lines changed: 1799 additions & 156 deletions

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM alpine:3.20
1+
FROM alpine:3.21
22
ENV LANG=zh_CN.UTF-8 \
33
TZ=Asia/Shanghai \
44
PS1="\u@\h:\w \$ "

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,9 @@ Path : JDK安装目录\bin
111111

112112
```
113113
Linux: mkdir /home/nginxWebUI/
114-
wget -O /home/nginxWebUI/nginxWebUI.jar https://gitee.com/cym1102/nginxWebUI/releases/download/4.2.6/nginxWebUI-4.2.6.jar
114+
wget -O /home/nginxWebUI/nginxWebUI.jar https://gitee.com/cym1102/nginxWebUI/releases/download/4.2.7/nginxWebUI-4.2.7.jar
115115
116-
Windows: 直接使用浏览器下载 https://gitee.com/cym1102/nginxWebUI/releases/download/4.2.6/nginxWebUI-4.2.6.jar 到 D:/home/nginxWebUI/nginxWebUI.jar
116+
Windows: 直接使用浏览器下载 https://gitee.com/cym1102/nginxWebUI/releases/download/4.2.7/nginxWebUI-4.2.7.jar 到 D:/home/nginxWebUI/nginxWebUI.jar
117117
```
118118

119119
有新版本只需要修改路径中的版本即可

README_EN.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,9 @@ reboot
107107

108108
```
109109
Linux: mkdir /home/nginxWebUI/
110-
wget -O /home/nginxWebUI/nginxWebUI.jar https://gitee.com/cym1102/nginxWebUI/releases/download/4.2.6/nginxWebUI-4.2.6.jar
110+
wget -O /home/nginxWebUI/nginxWebUI.jar https://gitee.com/cym1102/nginxWebUI/releases/download/4.2.7/nginxWebUI-4.2.7.jar
111111
112-
Windows: Download directly from your browser https://gitee.com/cym1102/nginxWebUI/releases/download/4.2.6/nginxWebUI-4.2.6.jar into D:/home/nginxWebUI/
112+
Windows: Download directly from your browser https://gitee.com/cym1102/nginxWebUI/releases/download/4.2.7/nginxWebUI-4.2.7.jar into D:/home/nginxWebUI/
113113
```
114114

115115
With a new version, you just need to change the version in the path

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<modelVersion>4.0.0</modelVersion>
1212
<groupId>com.cym</groupId>
1313
<artifactId>nginxWebUI</artifactId>
14-
<version>4.2.6</version>
14+
<version>4.2.7</version>
1515

1616
<properties>
1717
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

src/main/java/com/cym/config/InitConfig.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,13 +167,13 @@ public void start() throws Throwable {
167167
String nginxExe = settingService.get("nginxExe");
168168
String nginxDir = settingService.get("nginxDir");
169169
if (StrUtil.isNotEmpty(nginxExe) && StrUtil.isNotEmpty(nginxPath)) {
170-
RuntimeUtil.execForStr("/bin/sh", "-c", "pkill -9 nginx");
170+
RuntimeUtil.exec("/bin/sh", "-c", "pkill -9 nginx");
171171

172172
String cmd = nginxExe + " -c " + nginxPath;
173173
if (StrUtil.isNotEmpty(nginxDir)) {
174174
cmd += " -p " + nginxDir;
175175
}
176-
RuntimeUtil.execForStr("/bin/sh", "-c", cmd);
176+
RuntimeUtil.exec("/bin/sh", "-c", cmd);
177177
}
178178
}
179179

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
package com.cym.controller.api;
2+
3+
import java.util.List;
4+
5+
import org.noear.solon.annotation.Controller;
6+
import org.noear.solon.annotation.Inject;
7+
import org.noear.solon.annotation.Mapping;
8+
import org.slf4j.Logger;
9+
import org.slf4j.LoggerFactory;
10+
11+
import com.cym.controller.adminPage.WwwController;
12+
import com.cym.model.Cert;
13+
import com.cym.model.Www;
14+
import com.cym.service.WwwService;
15+
import com.cym.sqlhelper.bean.Page;
16+
import com.cym.sqlhelper.bean.Sort;
17+
import com.cym.sqlhelper.bean.Sort.Direction;
18+
import com.cym.utils.BaseController;
19+
import com.cym.utils.JsonResult;
20+
21+
/**
22+
* 静态网页接口
23+
*
24+
*/
25+
@Mapping("/api/www")
26+
@Controller
27+
public class WwwApiController extends BaseController {
28+
Logger logger = LoggerFactory.getLogger(this.getClass());
29+
@Inject
30+
WwwService wwwService;
31+
@Inject
32+
WwwController wwwController;
33+
34+
/**
35+
* 获取静态网页分页列表
36+
*
37+
*/
38+
@Mapping("getList")
39+
public JsonResult<List<Www>> getList() {
40+
List<Www> wwws = sqlHelper.findAll(new Sort("dir", Direction.ASC), Www.class);
41+
42+
return renderSuccess(wwws);
43+
}
44+
45+
/**
46+
* 添加或编辑静态网页
47+
*
48+
* @param www 静态网页
49+
* @param dirTemp zip文件路径
50+
*
51+
*/
52+
@Mapping("addOver")
53+
public JsonResult addOver(Www www, String dirTemp) {
54+
return wwwController.addOver(www, dirTemp);
55+
}
56+
57+
/**
58+
* 清空静态网页路径
59+
*
60+
* @param id 静态网页id
61+
*
62+
*/
63+
@Mapping("clean")
64+
public JsonResult clean(String id) {
65+
return wwwController.clean(id);
66+
}
67+
68+
/**
69+
* 删除静态网页
70+
*
71+
* @param id 静态网页id
72+
*
73+
*/
74+
@Mapping("del")
75+
public JsonResult del(String id) {
76+
return wwwController.del(id);
77+
}
78+
79+
/**
80+
* 静态网页详情
81+
*
82+
* @param id 静态网页id
83+
*
84+
*/
85+
@Mapping("detail")
86+
public JsonResult<Www> detail(String id) {
87+
return wwwController.detail(id);
88+
}
89+
90+
/**
91+
* 获取静态网页描述
92+
*
93+
* @param id 静态网页id
94+
*
95+
*/
96+
@Mapping("getDescr")
97+
public JsonResult<String> getDescr(String id) {
98+
return wwwController.getDescr(id);
99+
}
100+
101+
/**
102+
* 编辑静态网页描述
103+
*
104+
* @param id 静态网页id
105+
* @param descr 静态网页描述
106+
*
107+
*/
108+
@Mapping("editDescr")
109+
public JsonResult editDescr(String id, String descr) {
110+
return wwwController.editDescr(id, descr);
111+
}
112+
}

src/main/java/com/cym/model/Www.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,21 @@
33
import com.cym.sqlhelper.bean.BaseModel;
44
import com.cym.sqlhelper.config.Table;
55

6+
/**
7+
*
8+
* 静态网页
9+
*
10+
*/
611
@Table
712
public class Www extends BaseModel {
13+
/**
14+
* 路径
15+
*/
816
String dir;
917

18+
/**
19+
* 描述
20+
*/
1021
String descr;
1122

1223
public String getDescr() {

src/main/java/com/cym/service/ConfService.java

Lines changed: 69 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ public NgxBlock buildBlockUpstream(Upstream upstream) {
414414
return ngxBlockServer;
415415
}
416416

417-
public static List<Integer> processPort(String listenString){
417+
public List<Integer> processPort(String listenString) {
418418
List<Integer> numbers = new ArrayList<>();
419419

420420
// 使用逗号分割字符串
@@ -445,13 +445,26 @@ public static List<Integer> processPort(String listenString){
445445
return numbers;
446446
}
447447

448-
public static Boolean processListenPort(Server server, NgxBlock ngxBlockServer, Boolean isIpv6) {
449-
if (isIpv6 && server.getIpv6() != 1){
450-
return false;
448+
public void httpListenPort(Server server, NgxBlock ngxBlockServer, Boolean isIpv6) {
449+
String host = null;
450+
List<Integer> ports = null;
451+
// 分离host和port
452+
if (server.getListen().contains(":")) {
453+
int lastColonIndex = server.getListen().lastIndexOf(":");
454+
host = server.getListen().substring(0, lastColonIndex);
455+
ports = processPort(server.getListen().substring(lastColonIndex + 1));
456+
} else {
457+
ports = processPort(server.getListen());
458+
}
459+
460+
String listenKey = null;
461+
if (isIpv6) {
462+
listenKey = "listen [::]:";
463+
} else if (host != null) {
464+
listenKey = "listen " + host + ":";
465+
} else {
466+
listenKey = "listen ";
451467
}
452-
List<Integer> ports = processPort(server.getListen());
453-
454-
String listenKey = isIpv6 ? "listen [::]:" : "listen ";
455468

456469
String value = "";
457470
for (Integer port : ports) {
@@ -473,7 +486,47 @@ public static Boolean processListenPort(Server server, NgxBlock ngxBlockServer,
473486
ngxParam.addValue(value);
474487
ngxBlockServer.addEntry(ngxParam);
475488
}
476-
return true;
489+
490+
}
491+
492+
493+
public void tcpListenPort(Server server, NgxBlock ngxBlockServer, Boolean isIpv6) {
494+
String host = null;
495+
List<Integer> ports = null;
496+
// 分离host和port
497+
if (server.getListen().contains(":")) {
498+
int lastColonIndex = server.getListen().lastIndexOf(":");
499+
host = server.getListen().substring(0, lastColonIndex);
500+
ports = processPort(server.getListen().substring(lastColonIndex + 1));
501+
} else {
502+
ports = processPort(server.getListen());
503+
}
504+
505+
String listenKey = null;
506+
if (isIpv6) {
507+
listenKey = "listen [::]:";
508+
} else if (host != null) {
509+
listenKey = "listen " + host + ":";
510+
} else {
511+
listenKey = "listen ";
512+
}
513+
514+
String value = "";
515+
for (Integer port : ports) {
516+
NgxParam ngxParam = new NgxParam();
517+
value = listenKey + port;
518+
if (server.getProxyProtocol() == 1) {
519+
value += " proxy_protocol";
520+
}
521+
if (server.getProxyType() == 2) {
522+
value += " udp";
523+
}
524+
if (server.getSsl() != null && server.getSsl() == 1) {
525+
value += " ssl";
526+
}
527+
ngxParam.addValue(value);
528+
ngxBlockServer.addEntry(ngxParam);
529+
}
477530

478531
}
479532

@@ -501,10 +554,10 @@ public NgxBlock bulidBlockServer(Server server, ConfExt confExt) {
501554
}
502555

503556
// 监听端口
504-
processListenPort(server, ngxBlockServer, false);
505-
// 监控ipv6
506-
processListenPort(server, ngxBlockServer, true);
507-
557+
httpListenPort(server, ngxBlockServer, false);
558+
if (server.getIpv6() == 1) {
559+
httpListenPort(server, ngxBlockServer, true);
560+
}
508561

509562
if (server.getSsl() == 1 && server.getHttp2() == 2) { // http2新版写法
510563
ngxParam = new NgxParam();
@@ -685,38 +738,13 @@ public NgxBlock bulidBlockServer(Server server, ConfExt confExt) {
685738
} else {
686739
ngxBlockServer.addValue("server");
687740

741+
688742
// 监听端口
689-
ngxParam = new NgxParam();
690-
String value = "listen " + server.getListen();
691-
if (server.getProxyProtocol() == 1) {
692-
value += " proxy_protocol";
693-
}
694-
if (server.getProxyType() == 2) {
695-
value += " udp";
696-
}
697-
if (server.getSsl() != null && server.getSsl() == 1) {
698-
value += " ssl";
699-
}
700-
701-
ngxParam.addValue(value);
702-
ngxBlockServer.addEntry(ngxParam);
703-
704-
// 监控ipv6
743+
tcpListenPort(server, ngxBlockServer, false);
705744
if (server.getIpv6() == 1) {
706-
ngxParam = new NgxParam();
707-
value = "listen [::]:" + replaceIp(server.getListen());
708-
if (server.getProxyProtocol() == 1) {
709-
value += " proxy_protocol";
710-
}
711-
if (server.getProxyType() == 2) {
712-
value += " udp";
713-
}
714-
if (server.getSsl() != null && server.getSsl() == 1) {
715-
value += " ssl";
716-
}
717-
ngxParam.addValue(value);
718-
ngxBlockServer.addEntry(ngxParam);
745+
tcpListenPort(server, ngxBlockServer, true);
719746
}
747+
720748

721749
// 指向负载均衡
722750
Upstream upstream = sqlHelper.findById(server.getProxyUpstreamId(), Upstream.class);

src/main/java/com/cym/service/ServerService.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,9 @@ public List<Location> getLocationByServerId(String serverId) {
7373

7474
public void addOver(Server server, String serverParamJson, List<Location> locations) {
7575

76-
if (server.getDef() != null && server.getDef() == 1) {
77-
clearDef();
78-
}
76+
// if (server.getDef() != null && server.getDef() == 1) {
77+
// clearDef();
78+
// }
7979

8080
sqlHelper.insertOrUpdate(server);
8181

@@ -133,13 +133,13 @@ private String findLocationDescr(List<Location> locationOlds, Location locationN
133133
return null;
134134
}
135135

136-
private void clearDef() {
137-
List<Server> servers = sqlHelper.findListByQuery(new ConditionAndWrapper().eq("def", 1), Server.class);
138-
for (Server server : servers) {
139-
server.setDef(0);
140-
sqlHelper.updateById(server);
141-
}
142-
}
136+
// private void clearDef() {
137+
// List<Server> servers = sqlHelper.findListByQuery(new ConditionAndWrapper().eq("def", 1), Server.class);
138+
// for (Server server : servers) {
139+
// server.setDef(0);
140+
// sqlHelper.updateById(server);
141+
// }
142+
// }
143143

144144
public void addOverTcp(Server server, String serverParamJson) {
145145
sqlHelper.insertOrUpdate(server);

src/main/resources/WEB-INF/view/adminPage/server/index.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@
175175
</td>
176176
<td>
177177
${ext.server.listen}
178-
<#if ext.server.def==1>default</#if>
178+
<#if ext.server.def==1>default_server</#if>
179179
</td>
180180
<td>
181181

@@ -294,8 +294,8 @@
294294
</div>
295295

296296
<div class="layui-form-item" style="padding-left: 20px;">
297-
<input type="checkbox" name="def" id="def" title="default" lay-skin="primary">
298-
<input type="checkbox" name="proxyProtocol" id="proxyProtocol" title="proxy protocol" lay-skin="primary">
297+
<input type="checkbox" name="def" id="def" title="default_server" lay-skin="primary">
298+
<input type="checkbox" name="proxyProtocol" id="proxy_protocol" title="proxy protocol" lay-skin="primary">
299299
<input type="checkbox" name="ipv6" id="ipv6" title="${serverStr.ipv6}" lay-skin="primary" >
300300
</div>
301301

0 commit comments

Comments
 (0)