Giter VIP home page Giter VIP logo

p2pin3's Introduction

P2Pin2

如何使用

1.生成仿照torrent文件的json文件

参照以下示例代码以生成:

        outPath := "./downloaded/"
	var hashmapPath = "./hashmap/hashmap.json"
	name := "[Sakurato] Kono Subarashii Sekai ni Bakuen wo! [12][AVC-8bit 1080p AAC][CHS].mp4"

	filePath := "./testdata/" + name
	newtorrent, err := torrent.NewTorrentFile(filePath, "http://localhost:8090/announce", 12*1024)
	if err != nil {
		log.Fatal(err)
	}

	err = newtorrent.SaveTorrentFile(filePath, "./have/"+name+".json", hashmapPath)
	if err != nil {
		log.Fatal(err)
	}

2.为server添加peer的地址并运行server

server用于为下载方返回拥有资源的peer的地址

使用以下代码运行server:

go run ./server/server.go

3.运行peer以监听并发送请求的资源:

修改peer.go的配置后运行以下代码以启动服务

go run ./peer/peer.go

可以更改peer.go中的port以启动多个服务

4.运行main以下载文件

修改main.go的配置以后运行以下代码以开始下载

go run ./cmd/main.go

p2pin3's People

Contributors

lvkeliang avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.