Skip to content

Commit

Permalink
更新至2.44
Browse files Browse the repository at this point in the history
修复32位系统下百度云下载异常问题
检测到分段下载内容超过100%时该分段重新下载
分段数最大值调整回256
调大http buffer size,以提供文件写入效率
  • Loading branch information
monkeyWie committed Apr 2, 2018
1 parent 35e5809 commit b5094be
Show file tree
Hide file tree
Showing 15 changed files with 28 additions and 14 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
当任务下载链接失效了,下载没速度或失败则可以使用刷新下载链接的功能,使用新的链接继续下载,具体请[查看](https://github.com/monkeyWie/proxyee-down/blob/master/.guide/common/refresh/read.md)
### 百度云破解
#### 2018-03-29更新
百度云近期对批量下载的并发连接数做了限制,分段数需要建议不要超过64,否则可能会导致任务下载失败或下载速度慢。
百度云近期对**批量下载**的并发连接数做了限制,分段数需要建议不要超过64,否则可能会导致任务下载失败或下载速度慢。
#### 功能介绍
百度云大文件、合并下载限制突破,成功安装下载器后,打开百度云页面会有如下提示,然后在选择文件后点击下载按钮即可调用proxyee-down下载
![百度云破解](https://github.com/monkeyWie/proxyee-down/raw/master/.guide/common/bdy-hook.png)
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.43</version>
<version>2.44</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
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.43</version>
<version>2.44</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
package lee.study.down.boot;

import io.netty.bootstrap.Bootstrap;
import io.netty.channel.AdaptiveRecvByteBufAllocator;
import io.netty.channel.Channel;
import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelFutureListener;
import io.netty.channel.ChannelOption;
import io.netty.channel.RecvByteBufAllocator;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.socket.nio.NioSocketChannel;
import io.netty.handler.codec.http.DefaultLastHttpContent;
Expand Down Expand Up @@ -40,6 +43,11 @@ public abstract class AbstractHttpDownBootstrap {

protected static final Logger LOGGER = LoggerFactory.getLogger(AbstractHttpDownBootstrap.class);

//tcp bufferSize最大为128K
public static final int BUFFER_SIZE = 1024 * 128;
private static final RecvByteBufAllocator RECV_BYTE_BUF_ALLOCATOR = new AdaptiveRecvByteBufAllocator(
64, BUFFER_SIZE, BUFFER_SIZE);

protected static final String ATTR_CHANNEL = "channel";
protected static final String ATTR_FILE_CLOSEABLE = "fileCloseable";

Expand Down Expand Up @@ -95,6 +103,8 @@ protected void startChunkDown(ChunkInfo chunkInfo, int updateStatus) throws Exce
LOGGER.debug("开始下载:" + chunkInfo);
Bootstrap bootstrap = new Bootstrap()
.channel(NioSocketChannel.class)
.option(ChannelOption.RCVBUF_ALLOCATOR, RECV_BYTE_BUF_ALLOCATOR)
.option(ChannelOption.SO_RCVBUF, BUFFER_SIZE)
.group(clientLoopGroup)
.handler(new HttpDownInitializer(requestProto.getSsl(), this, chunkInfo));
if (httpDownInfo.getProxyConfig() != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,14 @@ public X86HttpDownBootstrap(HttpDownInfo httpDownInfo,
@Override
public int doFileWriter(ChunkInfo chunkInfo, ByteBuffer buffer) throws IOException {
int ret = buffer.remaining();
System.out.println(ret);
MappedByteBuffer mappedByteBuffer = null;
try (
FileChannel fileChannel = new RandomAccessFile(
getHttpDownInfo().getTaskInfo().buildTaskFilePath(), "rw").getChannel()
) {
mappedByteBuffer = fileChannel
.map(MapMode.READ_WRITE, chunkInfo.getNowStartPosition() + chunkInfo.getDownSize(), ret);
.map(MapMode.READ_WRITE, chunkInfo.getOriStartPosition() + chunkInfo.getDownSize(), ret);
mappedByteBuffer.put(buffer);
} finally {
if (mappedByteBuffer != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ protected void initChannel(Channel ch) throws Exception {
ch.pipeline().addLast(bootstrap.getClientSslContext().newHandler(ch.alloc()));
}
ch.pipeline()
.addLast("httpCodec", new HttpClientCodec());
.addLast("httpCodec",
new HttpClientCodec(4096, 8192, AbstractHttpDownBootstrap.BUFFER_SIZE));
ch.pipeline().addLast(new ChannelInboundHandlerAdapter() {

private Closeable closeable;
Expand Down Expand Up @@ -130,7 +131,7 @@ public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception
Integer responseCode = httpResponse.status().code();
if (responseCode.toString().indexOf("20") != 0) {
//应对百度近期同一时段多个连接返回400的问题
LOGGER.debug(
LOGGER.warn(
"响应状态码异常:" + responseCode + "\t" + chunkInfo);
if (responseCode == 401 || responseCode == 403 || responseCode == 404) {
chunkInfo.setStatus(HttpDownStatus.ERROR_WAIT_CONNECT);
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.43</version>
<version>2.44</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.43</version>
<version>2.44</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
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.43</version>
<version>2.44</version>
</parent>
<modelVersion>4.0.0</modelVersion>

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.43
app.version=2.44
spring.profiles.active=prd
view.server.port = 8999
tomcat.server.port = 26339
Expand Down
2 changes: 2 additions & 0 deletions ui/src/main/resources/logback-prd.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,6 @@
<root level="ERROR">
<appender-ref ref="FILE"/>
</root>

<logger name="lee.study.down" level="WARN"/>
</configuration>
2 changes: 1 addition & 1 deletion ui/view/src/components/ConfigPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<el-slider
v-model="form.connections"
:min="2"
:max="128"
:max="256"
:step="2"
show-input>
</el-slider>
Expand Down
2 changes: 1 addition & 1 deletion ui/view/src/components/NewTask.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<el-slider
v-model="form.connections"
:min="2"
:max="128"
:max="256"
:step="2"
:disabled="!form.supportRange||!!form.oldId"
show-input>
Expand Down
2 changes: 1 addition & 1 deletion ui/view/src/components/TaskList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -237,12 +237,12 @@
switch (task.status) {
case 7:
return 'success';
case 2:
case 6:
return 'exception';
case 5:
return 'pause';
case 1:
case 2:
case 8:
return 'ready';
default:
Expand Down
2 changes: 1 addition & 1 deletion update/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<groupId>lee.study</groupId>
<artifactId>proxyee-down-update</artifactId>
<packaging>jar</packaging>
<version>2.43</version>
<version>2.44</version>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand Down

0 comments on commit b5094be

Please sign in to comment.