Compare commits

...

2 Commits
main ... v0.4.0

Author SHA1 Message Date
Zack Scholl a68efa4e76 Add option to hide logo 2017-12-14 16:32:22 -07:00
Zack Scholl a4888f4a8e Add cleanup on Ctl+C 2017-12-14 16:32:15 -07:00
2 changed files with 39 additions and 13 deletions

View File

@ -7,15 +7,17 @@ import (
"io"
"net"
"os"
"os/signal"
"path"
"strconv"
"strings"
"sync"
"syscall"
"time"
humanize "github.com/dustin/go-humanize"
"github.com/schollz/progressbar"
"github.com/schollz/tarinator-go"
tarinator "github.com/schollz/tarinator-go"
"github.com/pkg/errors"
log "github.com/sirupsen/logrus"
@ -100,7 +102,27 @@ func NewConnection(flags *Flags) (*Connection, error) {
return c, nil
}
func (c *Connection) cleanup() {
log.Debug("cleaning")
for id := 1; id <= 8; id++ {
os.Remove(path.Join(c.Path, c.File.Name+".enc."+strconv.Itoa(id)))
}
os.Remove(path.Join(c.Path, c.File.Name+".enc"))
}
func (c *Connection) Run() error {
// catch the Ctl+C
catchCtlC := make(chan os.Signal, 2)
signal.Notify(catchCtlC, os.Interrupt, syscall.SIGTERM)
go func() {
<-catchCtlC
c.cleanup()
fmt.Println("\nExiting")
os.Exit(1)
}()
defer c.cleanup()
forceSingleThreaded := false
if c.IsSender {
fsize, err := FileSize(path.Join(c.File.Path, c.File.Name))

28
main.go
View File

@ -13,6 +13,7 @@ const BUFFERSIZE = 1024
var oneGigabytePerSecond = 1000000 // expressed as kbps
type Flags struct {
HideLogo bool
Relay bool
Debug bool
Wait bool
@ -29,19 +30,8 @@ type Flags struct {
var version string
func main() {
// fmt.Println(`
// ,_
// >' )
// croc version ` + fmt.Sprintf("%5s", version) + ` ( ( \
// || \
// /^^^^\ ||
// /^^\________/0 \ ||
// ( ` + "`" + `~+++,,_||__,,++~^^^^^^^
// ...V^V^V^V^V^V^\...............................
// `)
fmt.Printf("croc version %s\n", version)
flags := new(Flags)
flag.BoolVar(&flags.HideLogo, "hidelogo", false, "run as relay")
flag.BoolVar(&flags.Relay, "relay", false, "run as relay")
flag.BoolVar(&flags.Debug, "debug", false, "debug mode")
flag.BoolVar(&flags.Wait, "wait", false, "wait for code to be sent")
@ -54,6 +44,20 @@ func main() {
flag.BoolVar(&flags.DontEncrypt, "no-encrypt", false, "turn off encryption")
flag.IntVar(&flags.NumberOfConnections, "threads", 4, "number of threads to use")
flag.Parse()
if !flags.HideLogo {
fmt.Println(`
,_
>' )
croc version ` + fmt.Sprintf("%5s", version) + ` ( ( \
|| \
/^^^^\ ||
/^^\________/0 \ ||
( ` + "`" + `~+++,,_||__,,++~^^^^^^^
...V^V^V^V^V^V^\...............................
`)
}
fmt.Printf("croc version %s\n", version)
if flags.Relay {
r := NewRelay(flags)