Add self-destructing option
This commit is contained in:
4
main.go
4
main.go
@ -93,6 +93,7 @@ var (
|
|||||||
mirror = flag.String("mirror", "https://dist.torproject.org/torbrowser/", "Mirror to use")
|
mirror = flag.String("mirror", "https://dist.torproject.org/torbrowser/", "Mirror to use")
|
||||||
solidarity = flag.Bool("onion", false, "Serve an onion site which shows some I2P propaganda")
|
solidarity = flag.Bool("onion", false, "Serve an onion site which shows some I2P propaganda")
|
||||||
torrent = flag.Bool("torrent", tbget.TorrentReady(), "Create a torrent of the downloaded files and seed it over I2P using an Open Tracker")
|
torrent = flag.Bool("torrent", tbget.TorrentReady(), "Create a torrent of the downloaded files and seed it over I2P using an Open Tracker")
|
||||||
|
destruct = flag.Bool("destruct", false, "Destructively delete the working directory when finished")
|
||||||
/*ptop = flag.Bool("p2p", false, "Use bittorrent over I2P to download the initial copy of Tor Browser")*/
|
/*ptop = flag.Bool("p2p", false, "Use bittorrent over I2P to download the initial copy of Tor Browser")*/
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -121,6 +122,9 @@ func main() {
|
|||||||
if *snowflake {
|
if *snowflake {
|
||||||
go Snowflake()
|
go Snowflake()
|
||||||
}
|
}
|
||||||
|
if *destruct {
|
||||||
|
defer OverwriteDirectoryContents(*directory)
|
||||||
|
}
|
||||||
tbget.WORKING_DIR = *directory
|
tbget.WORKING_DIR = *directory
|
||||||
if filename == "i2pbrowser" {
|
if filename == "i2pbrowser" {
|
||||||
log.Println("Starting I2P in Tor Browser")
|
log.Println("Starting I2P in Tor Browser")
|
||||||
|
32
rmdir.go
Normal file
32
rmdir.go
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"log"
|
||||||
|
"os"
|
||||||
|
"path/filepath"
|
||||||
|
)
|
||||||
|
|
||||||
|
func OverwriteDirectoryContents(directory string) {
|
||||||
|
//walk the contents of directory recursively
|
||||||
|
//and zero-out the files to the length of the file
|
||||||
|
filepath.Walk(directory, func(path string, info os.FileInfo, err error) error {
|
||||||
|
go func() {
|
||||||
|
if err != nil {
|
||||||
|
log.Println("Error:", err)
|
||||||
|
}
|
||||||
|
if info.IsDir() {
|
||||||
|
log.Println("Error:", err)
|
||||||
|
}
|
||||||
|
file, err := os.OpenFile(path, os.O_RDWR, 0)
|
||||||
|
if err != nil {
|
||||||
|
log.Println("Error:", err)
|
||||||
|
}
|
||||||
|
defer file.Close()
|
||||||
|
bytes := info.Size()
|
||||||
|
file.Truncate(0)
|
||||||
|
file.Write(make([]byte, bytes))
|
||||||
|
log.Println("Error:", err)
|
||||||
|
}()
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
}
|
Reference in New Issue
Block a user