torrentfs

package module
v1.0.62 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 22, 2024 License: GPL-3.0 Imports: 27 Imported by: 4

README

Torrentfs

Torrentfs is a elastic file system, you can pull or push any files by following torrentfs protocol anywhere, anytime

Install

go install github.com/CortexFoundation/torrentfs/cmd/torrent@latest

Import

go get github.com/CortexFoundation/torrentfs

How to use

https://github.com/CortexFoundation/torrentfs.git
cd torrentfs
make
Create torrent file by 4k pieces
./build/bin/torrent-create workspace/data -p=4096 > workspace/test-torrent
Load info hash from torrent file
./build/bin/torrent-magnet < workspace/test-torrent
magnet:?xt=urn:btih:9196320d998fdab966bcb3a08f3f087e1f993c12&dn=data&tr=udp%3A%2F%2Ftracker.cortexlabs.ai%3A5008
Seed file to dht
mkdir -p mnt/9196320d998fdab966bcb3a08f3f087e1f993c12/data
cp workspace/test-torrent mnt/9196320d998fdab966bcb3a08f3f087e1f993c12/torrent
cp -r workspace/data/* mnt/9196320d998fdab966bcb3a08f3f087e1f993c12/data
./build/bin/seeding -dataDir=mnt
Download file
./build/bin/torrent download 'infohash:9196320d998fdab966bcb3a08f3f087e1f993c12'
How to test your network for torrent ?
./build/bin/torrent download 'infohash:6b75cc1354495ec763a6b295ee407ea864a0c292'
./build/bin/torrent download 'infohash:b2f5b0036877be22c6101bdfa5f2c7927fc35ef8'
./build/bin/torrent download 'infohash:5a49fed84aaf368cbf472cc06e42f93a93d92db5'
./build/bin/torrent download 'infohash:1f1706fa53ce0723ba1c577418b222acbfa5a200'
./build/bin/torrent download 'infohash:3f1f6c007e8da3e16f7c3378a20a746e70f1c2b0'

downloaded ALL the torrents !!!!!!!!!!!!!!!!!!!

Server running

https://github.com/CortexFoundation/torrentfs/pull/216

Seeding or Sharing

https://github.com/CortexFoundation/torrentfs/pull/224

Special thanks

Anacrolix BitTorrent client package and utilities

Documentation

Index

Constants

View Source
const (
	STATUS_PENDING = 1
	STATUS_RUNNING = 2
	STATUS_SEEDING = 0
	STATUS_UNKNOWN = 3
)

Variables

This section is empty.

Functions

This section is empty.

Types

type CortexStorage

type CortexStorage interface {
	//Available(ctx context.Context, infohash string, rawSize uint64) (bool, error)
	//GetFile(ctx context.Context, infohash, path string) ([]byte, error)
	GetFileWithSize(ctx context.Context, infohash string, rawSize uint64, path string) ([]byte, error)
	Stop() error

	Download(ctx context.Context, ih string, request uint64) error
	SeedingLocal(ctx context.Context, filePath string, isLinkMode bool) (string, error)
	PauseLocalSeed(ctx context.Context, ih string) error
	ResumeLocalSeed(ctx context.Context, ih string) error
	ListAllTorrents(ctx context.Context) map[string]map[string]int

	//0 finish, 1 pending, 2 downloading, 3 none
	Status(ctx context.Context, ih string) (int, error)
}

func GetStorage

func GetStorage() CortexStorage

type MsgInfo

type MsgInfo struct {
	Desc string `json:"desc"`
}

type Peer

type Peer struct {
	// contains filtered or unexported fields
}

func (*Peer) ID

func (peer *Peer) ID() []byte

func (*Peer) Info

func (peer *Peer) Info() *PeerInfo

type PeerInfo

type PeerInfo struct {
	Listen uint64      `json:"listen"`
	Root   common.Hash `json:"root"` // SHA3 hash of the peer's best owned block
	Files  uint64      `json:"files"`
	Leafs  uint64      `json:"leafs"`
}

type PublicTorrentAPI

type PublicTorrentAPI struct {
	// contains filtered or unexported fields
}

func NewPublicTorrentAPI

func NewPublicTorrentAPI(w *TorrentFS) *PublicTorrentAPI

func (*PublicTorrentAPI) Version

func (api *PublicTorrentAPI) Version(ctx context.Context) string

type Query

type Query struct {
	Hash string `json:"hash"`
	Size uint64 `json:"size"`
}

type TorrentFS

type TorrentFS struct {
	// contains filtered or unexported fields
}

TorrentFS contains the torrent file system internals.

func New

func New(config *params.Config, cache, compress, listen bool) (t *TorrentFS, err error)

New creates a new torrentfs instance with the given configuration.

func (*TorrentFS) APIs

func (fs *TorrentFS) APIs() []rpc.API

APIs implements the node.Service interface.

func (*TorrentFS) Candidate

func (fs *TorrentFS) Candidate() int

func (*TorrentFS) Congress

func (fs *TorrentFS) Congress() int

func (*TorrentFS) Download

func (fs *TorrentFS) Download(ctx context.Context, ih string, request uint64) error

func (*TorrentFS) Drop

func (fs *TorrentFS) Drop(ih string) error

func (*TorrentFS) Envelopes

func (fs *TorrentFS) Envelopes() *ttlmap.Map

func (*TorrentFS) GetFileWithSize

func (fs *TorrentFS) GetFileWithSize(ctx context.Context, infohash string, rawSize uint64, subpath string) ([]byte, error)

func (*TorrentFS) HandlePeer

func (fs *TorrentFS) HandlePeer(peer *p2p.Peer, rw p2p.MsgReadWriter) error

func (*TorrentFS) IsActive

func (fs *TorrentFS) IsActive(err error) bool

func (*TorrentFS) ListAllTorrents

func (fs *TorrentFS) ListAllTorrents(ctx context.Context) map[string]map[string]int

List All Torrents Status (read-only)

func (*TorrentFS) LocalPort

func (fs *TorrentFS) LocalPort() int

func (*TorrentFS) MaxMessageSize

func (fs *TorrentFS) MaxMessageSize() uint32

func (*TorrentFS) NasCounter

func (fs *TorrentFS) NasCounter() uint64

func (*TorrentFS) Neighbors

func (fs *TorrentFS) Neighbors() int

func (*TorrentFS) Nominee

func (fs *TorrentFS) Nominee() int

func (*TorrentFS) PauseLocalSeed

func (fs *TorrentFS) PauseLocalSeed(ctx context.Context, ih string) error

PauseSeeding Local File

func (*TorrentFS) Protocols

func (fs *TorrentFS) Protocols() []p2p.Protocol

Protocols implements the node.Service interface.

func (*TorrentFS) ResumeLocalSeed

func (fs *TorrentFS) ResumeLocalSeed(ctx context.Context, ih string) error

ResumeSeeding Local File

func (*TorrentFS) SeedingLocal

func (fs *TorrentFS) SeedingLocal(ctx context.Context, filePath string, isLinkMode bool) (infoHash string, err error)

Seeding Local File, validate folder, seeding and load files, default mode is copyMode, linkMode will limit user's operations for original files

func (*TorrentFS) Start

func (fs *TorrentFS) Start(srvr *p2p.Server) (err error)

Start starts the data collection thread and the listening server of the dashboard. Implements the node.Service interface.

func (*TorrentFS) Status

func (fs *TorrentFS) Status(ctx context.Context, ih string) (int, error)

func (*TorrentFS) Stop

func (fs *TorrentFS) Stop() error

Stop stops the data collection thread and the connection listener of the dashboard. Implements the node.Service interface.

func (*TorrentFS) Tunnel

func (fs *TorrentFS) Tunnel(ctx context.Context, ih string) error

func (*TorrentFS) Version

func (fs *TorrentFS) Version() uint

Directories

Path Synopsis
job
cmd
pack-blocklist
Takes P2P blocklist text format in stdin, and outputs the packed format from the iplist package.
Takes P2P blocklist text format in stdin, and outputs the packed format from the iplist package.
seeding
Mounts a FUSE filesystem backed by torrents and magnet links.
Mounts a FUSE filesystem backed by torrents and magnet links.
torrent
Downloads torrents from the command-line.
Downloads torrents from the command-line.
torrentfs
Mounts a FUSE filesystem backed by torrents and magnet links.
Mounts a FUSE filesystem backed by torrents and magnet links.
rlp
Package rlp implements the RLP serialization format.
Package rlp implements the RLP serialization format.
internal/rlpstruct
Package rlpstruct implements struct processing for RLP encoding/decoding.
Package rlpstruct implements struct processing for RLP encoding/decoding.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL