根據Taipei-Torrent修改出的三個bt工具
目前就是測試版本,均修改main.go然後編譯即可
tracker
//package xtracker
package main
import (
"log"
"os"
"os/signal"
"path"
"github.com/jackpal/Taipei-Torrent/torrent"
"github.com/jackpal/Taipei-Torrent/tracker"
"golang.org/x/net/proxy"
)
func main() {
err := startTracker("0.0.0.0:6969", []string{"test.torrent"})
if err != nil {
log.Fatal("Tracker returned error:", err)
}
return
}
func startTracker(addr string, torrentFiles []string) (err error) {
t := tracker.NewTracker()
// TODO(jackpal) Allow caller to choose port number
t.Addr = addr
dial := proxy.FromEnvironment()
for _, torrentFile := range torrentFiles {
var metaInfo *torrent.MetaInfo
metaInfo, err = torrent.GetMetaInfo(dial, torrentFile)
if err != nil {
return
}
name := metaInfo.Info.Name
if name == "" {
name = path.Base(torrentFile)
}
err = t.Register(metaInfo.InfoHash, name)
if err != nil {
return
}
}
go func() {
quitChan := listenSigInt()
select {
case <-quitChan:
log.Printf("got control-C")
t.Quit()
}
}()
err = t.ListenAndServe()
if err != nil {
return
}
return
}
func listenSigInt() chan os.Signal {
c := make(chan os.Signal, 1)
signal.Notify(c, os.Interrupt, os.Kill)
return c
}
bt客戶端
//package xbt
package main
import (
"log"
"math"
"github.com/jackpal/Taipei-Torrent/torrent"
"golang.org/x/net/proxy"
)
var (
cpuprofile = "" //If not empty, collects CPU profile samples and writes the profile to the given file before the program exits
memprofile = "" //If not empty, writes memory heap allocations to the given file before the program exits
createTorrent = "" //If not empty, creates a torrent file from the given root. Writes to stdout
createTracker = "" //Creates a tracker serving the given torrent file on the given address. Example --createTracker=:8080 to serve on port 8080.
port = 7777 //Port to listen on. 0 means pick random port. Note that 6881 is blacklisted by some trackers.
fileDir = "." //path to directory where files are stored
seedRatio = math.Inf(0) //Seed until ratio >= this value before quitting.
useDeadlockDetector = false //Panic and print stack dumps when the program is stuck.
useLPD = false //Use Local Peer Discovery
useUPnP = false //Use UPnP to open port in firewall.
useNATPMP = false //Use NAT-PMP to open port in firewall.
gateway = "" //IP Address of gateway.
useDHT = false //Use DHT to get peers.
trackerlessMode = false //Do not get peers from the tracker. Good for testing DHT mode.
proxyAddress = "" //Address of a SOCKS5 proxy to use.
initialCheck = true //Do an initial hash check on files when adding torrents.
useSFTP = "" //SFTP connection string, to store torrents over SFTP. e.g. 'username:password@192.168.1.25:22/path/'
useRamCache = 0 //Size in MiB of cache in ram, to reduce traffic on torrent storage.
useHdCache = 0 //Size in MiB of cache in OS temp directory, to reduce traffic on torrent storage.
execOnSeeding = "" //Command to execute when torrent has fully downloaded and has begun seeding.
quickResume = false //Save torrenting data to resume faster. '-initialCheck' should be set to false, to prevent hash check on resume.
maxActive = 16 //How many torrents should be active at a time. Torrents added beyond this value are queued.
memoryPerTorrent = -1 //Maximum memory (in MiB) per torrent used for Active Pieces. 0 means minimum. -1 (default) means unlimited.
torrentFiles []string
)
func parseTorrentFlags() (flags *torrent.TorrentFlags, err error) {
dialer := proxy.FromEnvironment()
flags = &torrent.TorrentFlags{
Dial: dialer,
Port: port,
FileDir: fileDir,
SeedRatio: seedRatio,
UseDeadlockDetector: useDeadlockDetector,
UseLPD: useLPD,
UseDHT: useDHT,
UseUPnP: useUPnP,
UseNATPMP: useNATPMP,
TrackerlessMode: trackerlessMode,
// IP address of gateway
Gateway: gateway,
InitialCheck: initialCheck,
FileSystemProvider: torrent.OsFsProvider{},
Cacher: nil,
ExecOnSeeding: execOnSeeding,
QuickResume: quickResume,
MaxActive: maxActive,
MemoryPerTorrent: memoryPerTorrent,
}
return
}
func main() {
torrentFiles = []string{"test.torrent"}
torrentFlags, err := parseTorrentFlags()
if err != nil {
log.Fatal("Could not parse flags:", err)
}
log.Println("Starting.")
err = torrent.RunTorrents(torrentFlags, torrentFiles)
if err != nil {
log.Fatal("Could not run torrents", err)
}
}
bt種子生成
//package maketorrent
package main
import (
"github.com/jackpal/Taipei-Torrent/torrent"
"log"
"os"
)
var (
createTorrent = "sbt_client.with-apt-boost" //If not empty, creates a torrent file from the given root. Writes to stdout
createTracker = "192.168.64.131:6969" //Creates a tracker serving the given torrent file on the given address. Example --createTracker=:8080 to serve on port 8080.
)
func main() {
err := torrent.WriteMetaInfoBytes(createTorrent, createTracker, os.Stdout)
if err != nil {
log.Fatal("Could not create torrent file:", err)
}
}
相關文章
- 根據MAC地質反查IP工具-LanHelperMac
- webstorm根據.eslintrc檔案自動修復WebORMEsLint
- 根據一個筆試題引出的思考筆試
- jQuery根據多個屬性匹配元素jQuery
- 根據開源資料庫選擇合適的工具資料庫
- DocTemplateTool - 可根據模板生成word或pdf檔案的工具
- OpenAPI Generator,根據Swagger/OpenAPI生成程式碼的工具APISwagger
- 根據除錯工具看Vue原始碼之watch除錯Vue原始碼
- 根據提示操作
- Java : List中 根據map的某個key去重Java
- Taipei-Torrent使用AI
- SAP RETAIL 如何根據分配表查到根據它建立的採購訂單?AI
- java 實現根據年月得到這個月的日曆Java
- Map根據Value排序排序
- 二維陣列根據某個欄位排序陣列排序
- 根據除錯工具看原始碼之虛擬dom(一)除錯原始碼
- 根據除錯工具看Vue原始碼之computed(二)除錯Vue原始碼
- 根據生日求年齡的SQLSQL
- 根據Interceptor 分析 OkHttp(一)HTTP
- 根據ip獲取城市
- java 根據日期取得星期Java
- js根據時間排序JS排序
- List根據時間排序排序
- 根據欄位查表名
- js記一個根據欄位排序物件函式JS排序物件函式
- 根據Promises/A+規範實現一個原生PromisePromise
- PHP二維陣列根據某個欄位排序PHP陣列排序
- 根據除錯工具看Vue原始碼之元件通訊(一)除錯Vue原始碼元件
- 根據除錯工具看Vue原始碼之虛擬dom(二)除錯Vue原始碼
- PHP 如何根據鍵值刪除一個陣列中的元素PHP陣列
- 根據業務摸索出的一個selenium程式碼模版(python)Python
- 分享一個session過期後根據guard跳轉的實現Session
- 根據一個點獲取視窗控制程式碼的APIAPI
- mysql like查詢 - 根據多個條件的模糊匹配查詢MySql
- 根據陣列的值刪除元素陣列
- django | 根據 model 建立對應的表Django
- JavaScript字串物件 之 根據字元返回位置、根據位置返回字元、字串操作方法JavaScript字串物件字元
- sql根據多個欄位查詢重複記錄SQL