1
1
Fork 0
mirror of https://github.com/schollz/croc.git synced 2025-10-11 05:11:06 +02:00

Vendoring

This commit is contained in:
Zack Scholl 2017-10-17 18:58:16 -06:00
parent c3956b059e
commit 0b9eaa1e1e
1111 changed files with 662538 additions and 1 deletions

19
main.go
View file

@ -1,6 +1,7 @@
package main
import (
"bufio"
"flag"
"fmt"
"os"
@ -24,7 +25,6 @@ func main() {
flag.StringVar(&serverAddress, "server", "", "(run as client) server address to connect to")
flag.StringVar(&fileName, "file", "", "(run as server) file to serve")
flag.StringVar(&codePhraseFlag, "code", "", "(run as server) file to serve")
flag.StringVar(&connectionTypeFlag, "type", "", "(run as server) file to serve")
flag.Parse()
// Check build flags too, which take precedent
if server != "" {
@ -40,6 +40,16 @@ func main() {
log.Fatal(err)
return
}
connectionTypeFlag = "s" // sender
if len(codePhraseFlag) == 0 {
codePhraseFlag = GetRandomName()
getInput("Your code phrase is '" + GetRandomName() + "' (press okay)")
}
} else {
connectionTypeFlag = "r" //receiver
if len(codePhraseFlag) == 0 {
codePhraseFlag = getInput("What is your code phrase? ")
}
}
log.SetFormatter(&log.TextFormatter{})
@ -57,3 +67,10 @@ func main() {
fmt.Println("You must specify either -file (for running as a server) or -server (for running as a client)")
}
}
func getInput(prompt string) string {
reader := bufio.NewReader(os.Stdin)
fmt.Print(prompt)
text, _ := reader.ReadString('\n')
return text
}