Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a68efa4e76 | ||
|
|
a4888f4a8e |
24
connect.go
24
connect.go
|
|
@ -7,15 +7,17 @@ import (
|
||||||
"io"
|
"io"
|
||||||
"net"
|
"net"
|
||||||
"os"
|
"os"
|
||||||
|
"os/signal"
|
||||||
"path"
|
"path"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
humanize "github.com/dustin/go-humanize"
|
humanize "github.com/dustin/go-humanize"
|
||||||
"github.com/schollz/progressbar"
|
"github.com/schollz/progressbar"
|
||||||
"github.com/schollz/tarinator-go"
|
tarinator "github.com/schollz/tarinator-go"
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
|
|
@ -100,7 +102,27 @@ func NewConnection(flags *Flags) (*Connection, error) {
|
||||||
return c, nil
|
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 {
|
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
|
forceSingleThreaded := false
|
||||||
if c.IsSender {
|
if c.IsSender {
|
||||||
fsize, err := FileSize(path.Join(c.File.Path, c.File.Name))
|
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
|
var oneGigabytePerSecond = 1000000 // expressed as kbps
|
||||||
|
|
||||||
type Flags struct {
|
type Flags struct {
|
||||||
|
HideLogo bool
|
||||||
Relay bool
|
Relay bool
|
||||||
Debug bool
|
Debug bool
|
||||||
Wait bool
|
Wait bool
|
||||||
|
|
@ -29,19 +30,8 @@ type Flags struct {
|
||||||
var version string
|
var version string
|
||||||
|
|
||||||
func main() {
|
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)
|
flags := new(Flags)
|
||||||
|
flag.BoolVar(&flags.HideLogo, "hidelogo", false, "run as relay")
|
||||||
flag.BoolVar(&flags.Relay, "relay", false, "run as relay")
|
flag.BoolVar(&flags.Relay, "relay", false, "run as relay")
|
||||||
flag.BoolVar(&flags.Debug, "debug", false, "debug mode")
|
flag.BoolVar(&flags.Debug, "debug", false, "debug mode")
|
||||||
flag.BoolVar(&flags.Wait, "wait", false, "wait for code to be sent")
|
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.BoolVar(&flags.DontEncrypt, "no-encrypt", false, "turn off encryption")
|
||||||
flag.IntVar(&flags.NumberOfConnections, "threads", 4, "number of threads to use")
|
flag.IntVar(&flags.NumberOfConnections, "threads", 4, "number of threads to use")
|
||||||
flag.Parse()
|
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 {
|
if flags.Relay {
|
||||||
r := NewRelay(flags)
|
r := NewRelay(flags)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue