forked from GopeedLab/gopeed
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
55 changed files
with
276 additions
and
234 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,35 @@ | ||
## gopeed | ||
支持多协议(HTTP、BitTorrent)下载的客户端,提供命令行、RESTful API、WebSocket、Go类库方式来使用。 | ||
|
||
支持多协议(HTTP、BitTorrent)下载的客户端,提供命令行、RESTful API、WebSocket、Go 类库方式来使用。 | ||
|
||
## 安装 | ||
|
||
```sh | ||
go install github.com/monkeyWie/gopeed-core | ||
``` | ||
|
||
## 示例 | ||
|
||
```go | ||
|
||
``` | ||
|
||
## TODO | ||
- [x] HTTP下载实现 | ||
- [ ] BitTorrent下载实现 | ||
- [x] .torrent文件解析 | ||
- [x] tracker协议实现 | ||
- [x] peer wire protocol协议实现 | ||
- [ ] DHT协议实现 | ||
- [ ] 磁力链接支持 | ||
- [ ] uTP协议实现 | ||
- [ ] 下载接口抽象(不关心具体协议) | ||
|
||
- [x] HTTP 下载实现 | ||
- [ ] BitTorrent 下载实现 | ||
- [x] .torrent 文件解析 | ||
- [x] tracker 协议实现 | ||
- [x] peer wire protocol 协议实现 | ||
- [ ] DHT 协议实现 | ||
- [ ] 磁力链接支持 | ||
- [ ] uTP 协议实现 | ||
- [x] 下载接口抽象(不关心具体协议) | ||
- [ ] 支持自定义配置 | ||
- [ ] 限速功能实现 | ||
- [ ] 命令行工具提供 | ||
- [ ] RESTful服务提供 | ||
- [x] 命令行工具提供 | ||
- [ ] RESTful 服务提供 | ||
|
||
## 参与 | ||
由于项目目前还未定型,代码可能随时有大的调整,所以暂不接受PR,当然如果有什么好的想法可以在issue区提出来。 | ||
|
||
由于项目目前还未定型,代码可能随时有大的调整,所以暂不接受 PR,当然如果有什么好的想法可以在 issue 区提出来。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package fetcher | ||
|
||
import ( | ||
"github.com/monkeyWie/gopeed-core/internal/controller" | ||
"github.com/monkeyWie/gopeed-core/pkg/base" | ||
) | ||
|
||
// 对应协议的下载支持 | ||
type Fetcher interface { | ||
Setup(ctl controller.Controller) | ||
// 解析请求 | ||
Resolve(req *base.Request) (res *base.Resource, err error) | ||
// 创建任务 | ||
Create(res *base.Resource, opts *base.Options) (err error) | ||
Start() (err error) | ||
Pause() (err error) | ||
Continue() (err error) | ||
|
||
// 获取任务各个文件下载进度 | ||
Progress() Progress | ||
// 该方法会一直阻塞,直到任务下载结束 | ||
Wait() (err error) | ||
} | ||
|
||
type DefaultFetcher struct { | ||
Ctl controller.Controller | ||
DoneCh chan error | ||
} | ||
|
||
func (f *DefaultFetcher) Setup(ctl controller.Controller) { | ||
f.Ctl = ctl | ||
f.DoneCh = make(chan error, 1) | ||
} | ||
|
||
func (f *DefaultFetcher) Wait() (err error) { | ||
return <-f.DoneCh | ||
} | ||
|
||
// 获取任务中各个文件的已下载字节数 | ||
type Progress []int64 | ||
|
||
// TotalDownloaded 获取任务总下载字节数 | ||
func (p Progress) TotalDownloaded() int64 { | ||
total := int64(0) | ||
for _, d := range p { | ||
total += d | ||
} | ||
return total | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.