1
0
mirror of https://github.com/schollz/croc.git synced 2024-11-28 01:16:10 +03:00
croc/main.go

59 lines
1.3 KiB
Go
Raw Normal View History

2017-10-17 18:21:47 +03:00
package main
import (
2017-10-18 03:58:16 +03:00
"bufio"
2017-10-17 18:21:47 +03:00
"flag"
"fmt"
2017-10-18 03:43:12 +03:00
"os"
2017-10-18 04:02:25 +03:00
"strings"
2017-10-17 18:21:47 +03:00
)
const BUFFERSIZE = 1024
2017-10-18 16:05:48 +03:00
type Flags struct {
Relay bool
Debug bool
DontEncrypt bool
Server string
File string
Code string
NumberOfConnections int
}
2017-10-17 18:21:47 +03:00
2017-10-18 23:11:35 +03:00
var version string
2017-10-17 18:21:47 +03:00
func main() {
2017-10-18 23:11:35 +03:00
fmt.Println(`
/\_/\
____/ o o \
/~____ =ø= /
(______)__m_m)
croc version `+version+`
`)
2017-10-18 16:05:48 +03:00
flags := new(Flags)
flag.BoolVar(&flags.Relay, "relay", false, "run as relay")
flag.BoolVar(&flags.Debug, "debug", false, "debug mode")
flag.StringVar(&flags.Server, "server", "cowyo.com", "address of relay server")
flag.StringVar(&flags.File, "send", "", "file to send")
flag.StringVar(&flags.Code, "code", "", "use your own code phrase")
flag.BoolVar(&flags.DontEncrypt, "no-encrypt", false, "turn off encryption")
flag.IntVar(&flags.NumberOfConnections, "threads", 4, "number of threads to use")
2017-10-17 18:21:47 +03:00
flag.Parse()
2017-10-18 03:43:12 +03:00
2017-10-18 16:05:48 +03:00
if flags.Relay {
r := NewRelay(flags)
r.Run()
2017-10-17 18:21:47 +03:00
} else {
2017-10-18 16:05:48 +03:00
c := NewConnection(flags)
c.Run()
2017-10-17 18:21:47 +03:00
}
}
2017-10-18 03:58:16 +03:00
func getInput(prompt string) string {
reader := bufio.NewReader(os.Stdin)
fmt.Print(prompt)
text, _ := reader.ReadString('\n')
2017-10-18 04:02:25 +03:00
return strings.TrimSpace(text)
2017-10-18 03:58:16 +03:00
}