Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a68efa4e76 | ||
|
|
a4888f4a8e |
24
connect.go
24
connect.go
|
|
@ -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
28
main.go
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Reference in New Issue