* remote address with port
* client's name
-For each torrent, corresponding HASH.torrent file will be created.
+For each torrent, corresponding .torrent file will be created.
Additional symbolic link with torrent's name will lead to HASH.torrent.
HASH.bf file is piece completion database. HASH.tx contains overall
outgoing payload traffic amount and it is updated each 10sec.
import (
"bufio"
+ "bytes"
"encoding/hex"
"fmt"
"log"
return lines
}
+func saveTorrent(t *torrent.Torrent) error {
+ pth := t.Name() + TorrentExt
+ if _, err := os.Stat(pth); err == nil {
+ return nil
+ }
+ var b bytes.Buffer
+ t.Metainfo().Write(&b)
+ return os.WriteFile(pth, b.Bytes(), 0666)
+}
+
func fifoAdd(c *torrent.Client) {
pth := path.Join(FIFOsDir, "add")
recreateFIFO(pth)
package main
import (
- "bytes"
"flag"
"log"
"net"
const TorrentExt = ".torrent"
-func saveTorrent(t *torrent.Torrent) error {
- pth := t.InfoHash().HexString() + TorrentExt
- if _, err := os.Stat(pth); err == nil {
- return nil
- }
- var b bytes.Buffer
- t.Metainfo().Write(&b)
- if err := os.WriteFile(pth, b.Bytes(), 0666); err != nil {
- return err
- }
- return os.Symlink(pth, t.Name()+TorrentExt)
-}
-
func main() {
log.SetFlags(log.Ldate | log.Ltime)
dhtBoot := flag.String("dht", "dht.cypherpunks.ru:8991", "Comma-separated list of DHT bootstrap nodes")