github.com/anacrolix/torrent@v1.61.0/iplist/cmd/pack-blocklist/main.go (about) 1 // Takes P2P blocklist text format in stdin, and outputs the packed format 2 // from the iplist package. 3 package main 4 5 import ( 6 "bufio" 7 "os" 8 9 "github.com/anacrolix/missinggo/v2" 10 "github.com/anacrolix/tagflag" 11 12 "github.com/anacrolix/torrent/iplist" 13 ) 14 15 func main() { 16 tagflag.Parse(nil) 17 l, err := iplist.NewFromReader(os.Stdin) 18 if err != nil { 19 missinggo.Fatal(err) 20 } 21 wb := bufio.NewWriter(os.Stdout) 22 defer wb.Flush() 23 err = l.WritePacked(wb) 24 if err != nil { 25 missinggo.Fatal(err) 26 } 27 }