Skip to content

Commit

Permalink
Merge branch 'v2.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
monkeyWie committed Feb 9, 2018
2 parents ed05a8e + 7c785a6 commit b90a425
Show file tree
Hide file tree
Showing 30 changed files with 189 additions and 64 deletions.
5 changes: 4 additions & 1 deletion .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<!--请根据以下模版提issue,不提供必要信息的issue将直接关闭-->
<!--
请根据以下模版提issue,不提供必要信息的issue将直接关闭
日志文件在proxyee-down安装目录/main/log文件夹里
-->
### 问题描述(必要)
### 版本号(必要)
### 相关截图
Expand Down
2 changes: 1 addition & 1 deletion .guide/FAQ.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<details>
<summary>下载进度一直不动或任务状态显示失败怎么解决?</summary>

**这种情况一般都是下载链接失效了,需要刷新下载链接,具体[查看](https://github.com/monkeyWie/proxyee-down/blob/master/.guide/refresh/read.md)**
**这种情况一般都是下载链接失效了,需要刷新下载链接,具体[查看](https://github.com/monkeyWie/proxyee-down/blob/master/.guide/common/refresh/read.md)**
</details>
<details>
<summary>关闭软件后无法正常上网?</summary>
Expand Down
Binary file added .guide/common/firefox-ca/imgs/1-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .guide/common/firefox-ca/imgs/1-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .guide/common/firefox-ca/imgs/2-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .guide/common/firefox-ca/imgs/2-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .guide/common/firefox-ca/imgs/2-3-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .guide/common/firefox-ca/imgs/2-3-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .guide/common/firefox-ca/imgs/4-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions .guide/common/firefox-ca/read.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
## 下载证书
1. 右击软件托盘,点下载证书
![](https://github.com/monkeyWie/proxyee-down/raw/master/.guide/common/firefox-ca/imgs/1-1.png)
2. 之后会跳转到下载页面,点击ProxyeeRoot ca.crt进行下载
![](https://github.com/monkeyWie/proxyee-down/raw/master/.guide/common/firefox-ca/imgs/1-2.png)
## 安装证书
1. 打开火狐浏览器并进入设置页面
![](https://github.com/monkeyWie/proxyee-down/raw/master/.guide/common/firefox-ca/imgs/2-1.png)
2. 进入火狐浏览器证书管理页面
在设置页面内找到隐私与安全->证书->查看证书,在打开的证书管理页面选中证书机构
![](https://github.com/monkeyWie/proxyee-down/raw/master/.guide/common/firefox-ca/imgs/2-2.png)
3. 导入刚刚下载的证书
点击导入,选中刚刚下载的证书
![](https://github.com/monkeyWie/proxyee-down/raw/master/.guide/common/firefox-ca/imgs/2-3-1.png)
把信任框都勾上点击确定
![](https://github.com/monkeyWie/proxyee-down/raw/master/.guide/common/firefox-ca/imgs/2-3-2.png)
## 完成
证书导入完成,刷新页面即可
## 导入了证书还是提示不安全?
可能是证书导入时没有勾选信任框,进入火狐浏览器证书管理页面找到ProxyeeRoot证书,选中之后点击编辑信任,在弹出的页面里将信任框都勾上并确定。
![](https://github.com/monkeyWie/proxyee-down/raw/master/.guide/common/firefox-ca/imgs/4-1.png)
2 changes: 2 additions & 0 deletions .guide/windows/read.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
## 解压并运行
将下载好的proxyee-down-x.xx-windows-xxx.zip解压至电脑任意目录。双击proxyee-down.exe运行软件,运行成功后会有提示和托盘出现。
![1-1](https://github.com/monkeyWie/proxyee-down/raw/master/.guide/windows/imgs/1-1.png)
## 火狐浏览器
由于火狐浏览器的特殊性,需要自行安装根证书,查看[安装步骤](https://github.com/monkeyWie/proxyee-down/blob/master/.guide/common/firefox-ca/read.md)
## 完成
打开浏览器,选择要下载的资源进行下载就会弹出下载页面了。

12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,24 @@
### 安装成功
在安装成功之后,浏览器下载资源时会跳转到创建任务页面,然后选择保存的路径和分段数进行创建下载任务。
![新建任务](https://github.com/monkeyWie/proxyee-down/raw/master/.guide/common/new-task.png)
## 功能
## 常见问题(**必看**)
在开始使用前务必看一遍[常见问题列表](https://github.com/monkeyWie/proxyee-down/blob/master/.guide/FAQ.md),可以解决你使用proxyee-down下载遇到的绝大多数问题。
## 常用功能
### 手动创建任务
[查看](https://github.com/monkeyWie/proxyee-down/blob/master/.guide/common/create/read.md)
可以根据链接来创建一个任务,支持自定义请求头和请求体,具体请[查看](https://github.com/monkeyWie/proxyee-down/blob/master/.guide/common/create/read.md)
### 刷新任务下载链接
[查看](https://github.com/monkeyWie/proxyee-down/blob/master/.guide/common/refresh/read.md)
当任务下载链接失效了,下载没速度或失败则可以使用刷新下载链接的功能,使用新的链接继续下载,具体请[查看](https://github.com/monkeyWie/proxyee-down/blob/master/.guide/common/refresh/read.md)
### 百度云破解
百度云大文件、合并下载限制突破,成功安装下载器后,打开百度云页面会有如下提示
![百度云破解](https://github.com/monkeyWie/proxyee-down/raw/master/.guide/common/bdy-hook.png)
### 百度云解压工具
在下载器工具页面里进入百度云解压工具,选择百度云批量下载的文件进行解压
![百度云解压](https://github.com/monkeyWie/proxyee-down/raw/master/.guide/common/bdy-unzip.png)
## 常见问题
[查看](https://github.com/monkeyWie/proxyee-down/blob/master/.guide/FAQ.md)
## 其他
### SwitchyOmega插件安装与设置
[查看](https://github.com/monkeyWie/proxyee-down/blob/master/.guide/common/switchy/read.md)
### 火狐浏览器证书安装
[查看](https://github.com/monkeyWie/proxyee-down/blob/master/.guide/common/firefox-ca/read.md)
### QQ群
1群**11352304**(已满)、2群**20236964**

Expand Down
2 changes: 1 addition & 1 deletion common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>proxyee-down</artifactId>
<groupId>lee.study</groupId>
<version>2.21</version>
<version>2.22</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
54 changes: 43 additions & 11 deletions common/src/main/java/lee/study/down/util/ByteUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import io.netty.buffer.ByteBuf;
import java.io.BufferedReader;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
Expand All @@ -15,13 +15,13 @@
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;
import java.nio.charset.Charset;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.UUID;
import lee.study.down.constant.HttpDownStatus;
import lee.study.down.model.ChunkInfo;
import lee.study.down.model.TaskInfo;

public class ByteUtil {

private static final Logger LOGGER = LoggerFactory.getLogger(ByteUtil.class);

/**
* 大端序
*/
Expand Down Expand Up @@ -104,12 +104,12 @@ public static void serialize(Serializable object, String path, String bakPath, b
RandomAccessFile raf = new RandomAccessFile(path, "rw")
) {
raf.write(bts);
FileUtil.initFile(bakPath, isHidden);
try (
RandomAccessFile raf2 = new RandomAccessFile(bakPath, "rw")
) {
raf2.write(bts);
}
}
FileUtil.initFile(bakPath, isHidden);
try (
RandomAccessFile raf2 = new RandomAccessFile(bakPath, "rw")
) {
raf2.write(bts);
}
}

Expand Down Expand Up @@ -311,4 +311,36 @@ public static boolean matchToken(FileChannel fileChannel, long start, long posit
fileChannel.position(rawPosition);
return ret;
}

public static void main(String[] args) throws IOException {
/*String file = args[0];
long totalSize = Long.parseLong(args[1]);*/
String file = "F:\\【批量下载】c .part7等.zip";
long totalSize = 12312;
File downFile = new File(file);
File[] chunks = new File(
downFile.getParentFile().getAbsolutePath() + File.separator + "." + downFile.getName()
+ "_cks").listFiles();
TaskInfo taskInfo = new TaskInfo()
.setId(UUID.randomUUID().toString())
.setFilePath(downFile.getParentFile().getAbsolutePath())
.setFileName(downFile.getName())
.setConnections(chunks.length)
.setSupportRange(true)
.setStatus(HttpDownStatus.RUNNING)
.setTotalSize(totalSize)
.setStartTime(System.currentTimeMillis())
.buildChunkInfoList();
long downSize = 0;
for (int i = 0; i < chunks.length; i++) {
downSize += chunks[i].length();
ChunkInfo chunkInfo = taskInfo.getChunkInfoList().get(i);
chunkInfo.setDownSize(chunks[i].length());
chunkInfo.setStatus(HttpDownStatus.RUNNING);
chunkInfo.setStartTime(System.currentTimeMillis());
chunkInfo.setIndex(i);
}
taskInfo.setDownSize(downSize);
serialize(taskInfo, taskInfo.buildTaskRecordFilePath(), taskInfo.buildTaskRecordBakFilePath());
}
}
2 changes: 1 addition & 1 deletion core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>proxyee-down</artifactId>
<groupId>lee.study</groupId>
<version>2.21</version>
<version>2.22</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public class HttpDownBootstrapFactory {

public static AbstractHttpDownBootstrap create(HttpDownInfo httpDownInfo, int retryCount,
SslContext clientSslContext, NioEventLoopGroup clientLoopGroup, HttpDownCallback callback) {
if (OsUtil.is64()) {
if (!OsUtil.is64()) {
return new X64HttpDownBootstrap(httpDownInfo, retryCount, clientSslContext, clientLoopGroup,
callback);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,10 +161,10 @@ public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws E
Channel nowChannel = bootstrap.getChannel(chunkInfo);
safeClose(ctx.channel());
if (nowChannel == ctx.channel()) {
bootstrap.retryChunkDown(chunkInfo);
if (callback != null) {
callback.onChunkError(bootstrap.getHttpDownInfo(), chunkInfo, cause);
}
bootstrap.retryChunkDown(chunkInfo);
}
}

Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>lee.study</groupId>
<artifactId>proxyee-down</artifactId>
<version>2.21</version>
<version>2.22</version>
<packaging>pom</packaging>

<modules>
Expand Down
2 changes: 1 addition & 1 deletion sniff/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>proxyee-down</artifactId>
<groupId>lee.study</groupId>
<version>2.21</version>
<version>2.22</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,12 @@ public void afterResponse(Channel clientChannel, Channel proxyChannel, HttpRespo
//有两种情况进行下载 1.url后缀为.xxx 2.带有CONTENT_DISPOSITION:ATTACHMENT响应头
String disposition = httpResHeaders.get(HttpHeaderNames.CONTENT_DISPOSITION);
if ((disposition != null
&& accept != null
&& !accept.equals("*/*")
&& disposition.contains(HttpHeaderValues.ATTACHMENT)
&& disposition.contains(HttpHeaderValues.FILENAME))
|| (pipeline.getHttpRequest().uri().matches("^.*\\.[^./]{1,5}(\\?[^?]*)?$")
|| (!pipeline.getHttpRequest().uri().matches("^.*/favicon\\.ico(\\?[^?]*)?$")
&& pipeline.getHttpRequest().uri().matches("^.*\\.[^./]{1,5}(\\?[^?]*)?$")
&& isDownAccept(accept, contentType))) {
downFlag = true;
}
Expand Down Expand Up @@ -107,10 +110,13 @@ private boolean isDownAccept(String accepts, String contentType) {
String[] acceptArray = accepts.split(",");
String contentType0 = contentType.split(";")[0];
for (String accpet : acceptArray) {
if (accpet.equals("*/*") && contentType.matches("^(?i)application/x.*$")) {
return false;
accpet = accpet.split(";")[0];
if (accpet.equals("*/*")) {
if (contentType.matches("^(?i)application/x.*$")) {
return false;
}
} else {
String accpet0 = "^(?i)" + accpet.split(";")[0].replaceAll("\\*", ".*") + "$";
String accpet0 = "^(?i)" + accpet.replaceAll("\\*", ".*") + "$";
if (contentType0.matches(accpet0)) {
return false;
}
Expand All @@ -121,8 +127,4 @@ private boolean isDownAccept(String accepts, String contentType) {
return false;
}
}

public static void main(String[] args) {
System.out.println(new HttpDownSniffIntercept().isDownAccept("*/*", "image/gif"));
}
}
2 changes: 1 addition & 1 deletion ui/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>proxyee-down</artifactId>
<groupId>lee.study</groupId>
<version>2.21</version>
<version>2.22</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
8 changes: 6 additions & 2 deletions ui/src/main/java/lee/study/down/content/DownContent.java
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,12 @@ public void init() {
String taskDetailBakPath = taskInfo.buildTaskRecordBakFilePath();
//存在下载进度信息则更新,否则重新下载
if (FileUtil.existsAny(taskDetailPath, taskDetailBakPath)) {
taskInfo = (TaskInfo) ByteUtil.deserialize(taskDetailPath, taskDetailBakPath);
httpDownInfo.setTaskInfo(taskInfo);
try {
taskInfo = (TaskInfo) ByteUtil.deserialize(taskDetailPath, taskDetailBakPath);
httpDownInfo.setTaskInfo(taskInfo);
} catch (IOException | ClassNotFoundException e) {
taskInfo.reset();
}
} else {
taskInfo.reset();
}
Expand Down
26 changes: 25 additions & 1 deletion ui/src/main/java/lee/study/down/gui/HttpDownApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
import java.util.List;
import javafx.application.Application;
import javafx.application.Platform;
import javafx.beans.value.ObservableValue;
import javafx.concurrent.Worker.State;
import javafx.geometry.HPos;
import javafx.geometry.Rectangle2D;
import javafx.geometry.VPos;
Expand All @@ -34,6 +36,7 @@
import lee.study.down.util.OsUtil;
import lee.study.down.util.PathUtil;
import lee.study.down.util.WindowsUtil;
import netscape.javascript.JSObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.builder.SpringApplicationBuilder;
Expand Down Expand Up @@ -226,7 +229,7 @@ private void addTray() {
proxyMenu.setEnabled(false);
} else {
CheckboxMenuItemGroup mig = new CheckboxMenuItemGroup();
CheckboxMenuItem globalProxyItem = new CheckboxMenuItem("全局");
CheckboxMenuItem globalProxyItem = new CheckboxMenuItem("全网");
globalProxyItem.setName("1");
CheckboxMenuItem bdyProxyItem = new CheckboxMenuItem("百度云");
bdyProxyItem.setName("2");
Expand Down Expand Up @@ -264,6 +267,7 @@ private void addTray() {
"http://127.0.0.1:" + ConfigUtil.getValue("tomcat.server.port")
+ "/res/pd.pac?t=" + System.currentTimeMillis());
} else {
ContentManager.CONFIG.get().setSniffModel(3);
WindowsUtil.disabledProxy();
}
ContentManager.CONFIG.save();
Expand Down Expand Up @@ -360,6 +364,14 @@ class Browser extends Region {

public Browser() {
getChildren().add(browser);
webEngine.getLoadWorker().stateProperty().addListener(
(ObservableValue<? extends State> ov, State oldState,
State newState) -> {
if (newState == State.SUCCEEDED) {
JSObject win = (JSObject) webEngine.executeScript("window");
win.setMember("jNative", new JNative());
}
});
}

@Override
Expand All @@ -374,6 +386,18 @@ public void load(String url) {
}
}

public class JNative {

public void open(String url) {
try {
OsUtil.openBrowse(url);
} catch (Exception e) {
LOGGER.warn("can't openBrowse:", e);
}
}

}

public static void main(String[] args) {
launch(args);
}
Expand Down
3 changes: 1 addition & 2 deletions ui/src/main/java/lee/study/down/model/ConfigBaseInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@

import java.io.Serializable;
import lombok.Data;
import lombok.EqualsAndHashCode;

@Data
public class ConfigBaseInfo implements Serializable {

private int proxyPort; //代理端口号
private int sniffModel; //嗅探模式 1.全局 2.百度云 3.关闭
private int sniffModel; //嗅探模式 1.全网 2.百度云 3.关闭
private int uiModel; //嗅探模式 1.GUI 2.浏览器
private int connections; //默认分段数
private int timeout; //超时重试时间
Expand Down
2 changes: 1 addition & 1 deletion ui/src/main/resources/application.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
app.version=2.21
app.version=2.22
spring.profiles.active=prd
view.server.port = 8999
tomcat.server.port = 9000
Expand Down
13 changes: 12 additions & 1 deletion ui/view/src/common/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,22 @@ export default {
}
}
},
getFileNameNoSuffix(fileName){
getFileNameNoSuffix(fileName) {
let index = fileName.lastIndexOf(".");
if (index != -1) {
return fileName.substring(0, index);
}
return fileName;
},
getUnzipFilePath(filePath, fileName) {
debugger;
if (!filePath) {
return '';
}
if (filePath.lastIndexOf('\\') == filePath.length - 1) {
return filePath + this.getFileNameNoSuffix(fileName);
} else {
return filePath + '\\' + this.getFileNameNoSuffix(fileName);
}
},
}
Loading

0 comments on commit b90a425

Please sign in to comment.