Closed tanishbajaj101 closed 7 months ago
Could you provide the command you ran, and possibly a link to a way for me to reproduce this?
There was some prior work done to export to Java, I think there might be some overlap in what is required. See https://github.com/arranlomas/Trickl and @axet's https://gitlab.com/axet/android-torrent-client.
Could you provide the command you ran, and possibly a link to a way for me to reproduce this?
go build -buidlmode=c-shared -o /tmp/torrent_download ./cmd/torrent I ran this command from main directory where go.mod file was there
hey @anacrolix I have decided to code the torrent client in Dart itself rather use any bindings, I have found a library that can download and seed the torrent, but I want to add a feature to 'create' the torrent from a local file as well. Can you tell me the logic behind creating the torrent? My understanding till now is that I would need a dictionary (info) that would have data like name, length (in bytes) of file, number of pieces, piece size, etc. and this would be bencoded and then hashed using SHA1. When I opened libtorrent docs and your code, I found a keyword 'offset' which I'm not sure what it means Also a major uncertainity I have is how I would divide a local file into its pieces and make SHA1 of each piece. How would that be made possible? Do i do a file_length/piece_size or something else?
Edit: I think I understood some of it using pieces.go file from your code func GeneratePieces(r io.Reader, pieceLength int64, b []byte) ([]byte, error) { for { h := sha1.New() written, err := io.CopyN(h, r, pieceLength) if written > 0 { b = h.Sum(b) } if err == io.EOF { return b, nil } if err != nil { return b, err } } } But please tell me all you can as I don't have much prior experience here
Could you provide the command you ran, and possibly a link to a way for me to reproduce this?
go build -buidlmode=c-shared -o /tmp/torrent_download ./cmd/torrent I ran this command from main directory where go.mod file was there
This command ran without error on my system. darwin/arm64.
hey @anacrolix I have decided to code the torrent client in Dart itself rather use any bindings, I have found a library that can download and seed the torrent, but I want to add a feature to 'create' the torrent from a local file as well. Can you tell me the logic behind creating the torrent? My understanding till now is that I would need a dictionary (info) that would have data like name, length (in bytes) of file, number of pieces, piece size, etc. and this would be bencoded and then hashed using SHA1. When I opened libtorrent docs and your code, I found a keyword 'offset' which I'm not sure what it means Also a major uncertainity I have is how I would divide a local file into its pieces and make SHA1 of each piece. How would that be made possible? Do i do a file_length/piece_size or something else?
Edit: I think I understood some of it using pieces.go file from your code func GeneratePieces(r io.Reader, pieceLength int64, b []byte) ([]byte, error) { for { h := sha1.New() written, err := io.CopyN(h, r, pieceLength) if written > 0 { b = h.Sum(b) } if err == io.EOF { return b, nil } if err != nil { return b, err } } } But please tell me all you can as I don't have much prior experience here
Sorry I don't have the bandwidth to assist with other projects.
I'll close, I'm not sure how else I can help.
Terminal output
./create.go:21:20: Go type not supported in export: bargle.Command ./create.go:21:20: Go type not supported in export: bargle.Command ./download.go:95:6: Go type not supported in export: context.Context ./download.go:96:10: Go type not supported in export: torrent.Client ./download.go:256:20: Go type not supported in export: struct { Debug bool DownloadCmd } ./download.go:98:6: Go type not supported in export: sync.WaitGroup ./download.go:95:6: Go type not supported in export: context.Context ./download.go:96:10: Go type not supported in export: torrent.Client ./download.go:256:20: Go type not supported in export: struct { Debug bool DownloadCmd } ./download.go:98:6: Go type not supported in export: sync.WaitGroup