Skip to content

Commit 5b2dd86

Browse files
committed
Fix proxy bug on MAC OS
Add zh-TW language Fix pdown.js bug on safari
1 parent f6bbe46 commit 5b2dd86

File tree

12 files changed

+49
-127
lines changed

12 files changed

+49
-127
lines changed

front/src/i18n/zh-TW.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
export default {
22
nav: {
33
tasks: '任務管理',
4-
extension: '擴充功能管理',
4+
extension: '擴充管理',
55
setting: '軟體設定',
66
about: '關於專案',
77
support: '支援我們'

front/src/views/Setting.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
prop="appConfig.locale">
6565
<Select v-model="form.appConfig.locale">
6666
<Option value="zh-CN">中文(简体)</Option>
67+
<Option value="zh-TW">中文(繁體)</Option>
6768
<Option value="en-US">English(USA)</Option>
6869
</Select>
6970
</FormItem>

main/pom.xml

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -41,27 +41,6 @@
4141
<environment>prd</environment>
4242
</properties>
4343
</profile>
44-
<profile>
45-
<id>windows</id>
46-
<properties>
47-
<osType>windows</osType>
48-
</properties>
49-
<activation>
50-
<activeByDefault>true</activeByDefault>
51-
</activation>
52-
</profile>
53-
<profile>
54-
<id>mac</id>
55-
<properties>
56-
<osType>mac</osType>
57-
</properties>
58-
</profile>
59-
<profile>
60-
<id>linux</id>
61-
<properties>
62-
<osType>linux</osType>
63-
</properties>
64-
</profile>
6544
</profiles>
6645

6746
<dependencies>
@@ -103,7 +82,6 @@
10382
<exclude>application-prd.yml</exclude>
10483
<exclude>logback-dev.xml</exclude>
10584
<exclude>logback-prd.xml</exclude>
106-
<exclude>tool/mac-tool.so</exclude>
10785
</excludes>
10886
</resource>
10987
<resource>
@@ -113,7 +91,6 @@
11391
<include>logback-${environment}.xml</include>
11492
<include>application-${environment}.yml</include>
11593
<include>application.yml</include>
116-
<include>tool/${osType}-tool.so</include>
11794
</includes>
11895
</resource>
11996
</resources>
@@ -124,7 +101,7 @@
124101
<artifactId>maven-resources-plugin</artifactId>
125102
<configuration>
126103
<nonFilteredFileExtensions>
127-
<nonFilteredFileExtension>so</nonFilteredFileExtension>
104+
<nonFilteredFileExtension>bin</nonFilteredFileExtension>
128105
<nonFilteredFileExtension>css</nonFilteredFileExtension>
129106
<nonFilteredFileExtension>js</nonFilteredFileExtension>
130107
<nonFilteredFileExtension>eot</nonFilteredFileExtension>

main/src/main/java/org/pdown/gui/DownApplication.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public void start(Stage primaryStage) throws Exception {
8787
Platform.setImplicitExit(false);
8888
//load config
8989
initConfig();
90-
initMacTool();
90+
initMacMITMTool();
9191
initEmbedHttpServer();
9292
initExtension();
9393
initTray();
@@ -148,10 +148,10 @@ private void initExtension() {
148148
public static int macToolPort;
149149

150150
//加载mac tool
151-
private void initMacTool() {
151+
private void initMacMITMTool() {
152152
if (OsUtil.isMac()) {
153153
new Thread(() -> {
154-
String toolUri = "tool/mac-tool.so";
154+
String toolUri = "mac/mitm-tool.bin";
155155
Path toolPath = Paths.get(PathUtil.ROOT_PATH + File.separator + toolUri);
156156
try {
157157
if (!toolPath.toFile().exists()) {
@@ -168,18 +168,18 @@ private void initMacTool() {
168168
}
169169
}
170170
//取一个空闲端口来运行mac tool
171-
macToolPort = OsUtil.getFreePort(9393);
171+
macToolPort = OsUtil.getFreePort();
172172
//程序退出监听
173173
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
174174
try {
175175
ExecUtil.httpGet("http://127.0.0.1:" + macToolPort + "/quit");
176176
} catch (IOException e) {
177177
}
178178
}));
179-
ExecUtil.execSyncWithAdmin("'" + toolPath.toFile().getPath() + "' " + macToolPort);
179+
ExecUtil.execBlockWithAdmin("'" + toolPath.toFile().getPath() + "' " + macToolPort);
180180
} catch (Exception e) {
181-
LOGGER.error("initMacTool error", e);
182-
alertAndExit("initMacTool error:" + e.getMessage());
181+
LOGGER.error("initMacMITMTool error", e);
182+
alertAndExit("Init mitm-tool error:" + e.getMessage());
183183
}
184184
System.exit(0);
185185
}).start();

main/src/main/java/org/pdown/gui/extension/mitm/util/ExtensionCertUtil.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
public class ExtensionCertUtil {
2525

2626

27-
2827
/**
2928
* 在指定目录生成一个ca证书和私钥
3029
*/
@@ -49,7 +48,7 @@ public static void buildCert(String path, String subjectName) throws Exception {
4948
public static void installCert(File file) throws IOException {
5049
String path = file.getPath();
5150
if (OsUtil.isWindows()) {
52-
ExecUtil.execSync("certutil",
51+
ExecUtil.execBlock("certutil",
5352
"-addstore",
5453
"-user",
5554
"root",
@@ -98,7 +97,7 @@ public static void uninstallCert(String subjectName) throws IOException {
9897
Matcher matcher = pattern.matcher(certList);
9998
while (matcher.find()) {
10099
String hash = matcher.group(1).replaceAll("\\s", "");
101-
ExecUtil.execSync("certutil",
100+
ExecUtil.execBlock("certutil",
102101
"-delstore",
103102
"-user",
104103
"root",
@@ -125,13 +124,14 @@ private static String findCertList(String subjectName) throws IOException {
125124
"root",
126125
subjectName);
127126
} else if (OsUtil.isMac()) {
128-
return ExecUtil.exec("/bin/bash",
129-
"security find-certificate "
130-
+ "-a "
131-
+ "-c " + subjectName + " "
132-
+ "-p "
133-
+ "-Z "
134-
+ "/Library/Keychains/System.keychain");
127+
return ExecUtil.exec("security",
128+
"find-certificate",
129+
"-a",
130+
"-c",
131+
subjectName,
132+
"-p",
133+
"-Z",
134+
"/Library/Keychains/System.keychain");
135135
}
136136
return null;
137137
}

main/src/main/java/org/pdown/gui/extension/mitm/util/ExtensionProxyUtil.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public static void enabledPACProxy(String url) throws IOException {
4949
refreshOptions(list);
5050
} else if (OsUtil.isMac()) {
5151
String networkService = disabledProxy();
52-
ExecUtil.httpGet("http://127.0.0.1:" + DownApplication.macToolPort + "/proxy/enabledHTTP"
52+
ExecUtil.httpGet("http://127.0.0.1:" + DownApplication.macToolPort + "/proxy/enabledPAC"
5353
+ "?ns=" + networkService
5454
+ "&url=" + url);
5555
}

main/src/main/java/org/pdown/gui/http/controller/NativeController.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,9 +137,9 @@ public FullHttpResponse showFile(Channel channel, FullHttpRequest request) throw
137137
if (!file.exists() || OsUtil.isUnix()) {
138138
Desktop.getDesktop().open(file.getParentFile());
139139
} else if (OsUtil.isWindows()) {
140-
ExecUtil.execSync("explorer.exe", "/select,", file.getPath());
140+
ExecUtil.execBlock("explorer.exe", "/select,", file.getPath());
141141
} else if (OsUtil.isMac()) {
142-
ExecUtil.execSync("open", "-R", file.getPath());
142+
ExecUtil.execBlock("open", "-R", file.getPath());
143143
}
144144
}
145145
return new DefaultFullHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.OK);

main/src/main/java/org/pdown/gui/util/ExecUtil.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public static String exec(String... shell) throws IOException {
3535
/**
3636
* 同步执行shell,阻塞当前线程
3737
*/
38-
public static void execSync(String... shell) throws IOException {
38+
public static void execBlock(String... shell) throws IOException {
3939
Process process = Runtime.getRuntime().exec(shell);
4040
try (
4141
InputStream inputStream = process.getInputStream()
@@ -52,7 +52,7 @@ public static void execSync(String... shell) throws IOException {
5252
/**
5353
* 以管理员权限,同步执行shell,阻塞当前线程
5454
*/
55-
public static void execSyncWithAdmin(String shell) throws IOException {
55+
public static void execBlockWithAdmin(String shell) throws IOException {
5656
//osascript -e "do shell script \"shell\" with administrator privileges"
5757
Process process = Runtime.getRuntime().exec(new String[]{
5858
"osascript",

main/src/main/resources/pdown.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
}
6060
return xhr
6161
},
62-
proxySend(async, method, url, data, onSuccess, onError) {
62+
proxySend: function (async, method, url, data, onSuccess, onError) {
6363
var xhr = this.buildXHR();
6464
xhr.open('post', '/', async)
6565
var data = {method: method, url: url, data: data}

0 commit comments

Comments
 (0)