mirror of
https://github.com/schollz/croc.git
synced 2025-10-11 13:21:00 +02:00
add back prompt for code
This commit is contained in:
parent
e7d2f05399
commit
d4fa4bc9c0
6 changed files with 27 additions and 25 deletions
|
@ -22,11 +22,11 @@ _These two gifs should run in sync if you force-reload (Ctl+F5)_
|
||||||
|
|
||||||
**Sender:**
|
**Sender:**
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
**Receiver:**
|
**Receiver:**
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
|
||||||
**Sender:**
|
**Sender:**
|
||||||
|
|
18
connect.go
18
connect.go
|
@ -108,7 +108,7 @@ func NewConnection(config *AppConfig) (*Connection, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if info.Mode().IsDir() { // if our file is a dir
|
if info.Mode().IsDir() { // if our file is a dir
|
||||||
fmt.Println("compressing directory...")
|
fmt.Println("Compressing folder...")
|
||||||
|
|
||||||
// we "tarify" the file
|
// we "tarify" the file
|
||||||
err = tarinator.Tarinate([]string{config.File}, path.Base(config.File)+".tar")
|
err = tarinator.Tarinate([]string{config.File}, path.Base(config.File)+".tar")
|
||||||
|
@ -208,7 +208,11 @@ func (c *Connection) Run() error {
|
||||||
|
|
||||||
log.Debug("checking code validity")
|
log.Debug("checking code validity")
|
||||||
if len(c.Code) == 0 {
|
if len(c.Code) == 0 {
|
||||||
c.Code = GetRandomName()
|
if c.IsSender {
|
||||||
|
c.Code = GetRandomName()
|
||||||
|
} else {
|
||||||
|
c.Code = getInput("Enter receive code: ")
|
||||||
|
}
|
||||||
log.Debug("changed code to ", c.Code)
|
log.Debug("changed code to ", c.Code)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -507,10 +511,14 @@ func (c *Connection) runClient() error {
|
||||||
fmt.Println("Timeout waiting for receiver")
|
fmt.Println("Timeout waiting for receiver")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
fmt.Print("\nFile sent")
|
fileOrFolder := "File"
|
||||||
|
if c.File.IsDir {
|
||||||
|
fileOrFolder = "Folder"
|
||||||
|
}
|
||||||
|
fmt.Printf("\n%s sent", fileOrFolder)
|
||||||
} else { // Is a Receiver
|
} else { // Is a Receiver
|
||||||
if responses.notPresent {
|
if responses.notPresent {
|
||||||
fmt.Println("Sender is not ready. Use -wait to wait until sender connects.")
|
fmt.Println("Either code is incorrect or sender is not ready. Use -wait to wait until sender connects.")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
if !responses.gotOK {
|
if !responses.gotOK {
|
||||||
|
@ -550,7 +558,7 @@ func (c *Connection) runClient() error {
|
||||||
return fmt.Errorf("\nUh oh! %s is corrupted! Sorry, try again.\n", c.File.Name)
|
return fmt.Errorf("\nUh oh! %s is corrupted! Sorry, try again.\n", c.File.Name)
|
||||||
}
|
}
|
||||||
if c.File.IsDir { // if the file was originally a dir
|
if c.File.IsDir { // if the file was originally a dir
|
||||||
fmt.Print("\ndecompressing folder")
|
fmt.Print("\nDecompressing folder...")
|
||||||
log.Debug("untarring " + c.File.Name)
|
log.Debug("untarring " + c.File.Name)
|
||||||
err := tarinator.UnTarinate(c.Path, path.Join(c.Path, c.File.Name))
|
err := tarinator.UnTarinate(c.Path, path.Join(c.Path, c.File.Name))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
13
help.go
13
help.go
|
@ -1,6 +1,17 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
var helpTemplate = `NAME:
|
var helpTemplate = `
|
||||||
|
,_
|
||||||
|
>' )
|
||||||
|
( ( \
|
||||||
|
|| \
|
||||||
|
/^^^^\ ||
|
||||||
|
/^^\________/0 \ ||
|
||||||
|
( ` + "`" + `~+++,,_||__,,++~^^^^^^^
|
||||||
|
...V^V^V^V^V^V^\...............................
|
||||||
|
|
||||||
|
|
||||||
|
NAME:
|
||||||
{{.Name}} - {{.Usage}}
|
{{.Name}} - {{.Usage}}
|
||||||
|
|
||||||
USAGE:
|
USAGE:
|
||||||
|
|
BIN
logo/receiver.gif
Normal file
BIN
logo/receiver.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 84 KiB |
BIN
logo/sender.gif
Normal file
BIN
logo/sender.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 50 KiB |
17
main.go
17
main.go
|
@ -13,7 +13,6 @@ import (
|
||||||
const BUFFERSIZE = 1024
|
const BUFFERSIZE = 1024
|
||||||
|
|
||||||
type AppConfig struct {
|
type AppConfig struct {
|
||||||
HideLogo bool `yaml:"hidelogo" flagName:"hidelogo" flagSName:"hl" flagDescribe:"Hidden logo" default:"false"`
|
|
||||||
Relay bool `yaml:"relay" flagName:"relay" flagSName:"r" flagDescribe:"Run as relay" default:"false"`
|
Relay bool `yaml:"relay" flagName:"relay" flagSName:"r" flagDescribe:"Run as relay" default:"false"`
|
||||||
Debug bool `yaml:"debug" flagName:"debug" flagSName:"d" flagDescribe:"Debug mode" default:"false"`
|
Debug bool `yaml:"debug" flagName:"debug" flagSName:"d" flagDescribe:"Debug mode" default:"false"`
|
||||||
Wait bool `yaml:"wait" flagName:"wait" flagSName:"w" flagDescribe:"Wait for code to be sent" default:"false"`
|
Wait bool `yaml:"wait" flagName:"wait" flagSName:"w" flagDescribe:"Wait for code to be sent" default:"false"`
|
||||||
|
@ -77,22 +76,6 @@ func main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
ApplyFlags(cliFlags, flagMappings, c, appOptions)
|
ApplyFlags(cliFlags, flagMappings, c, appOptions)
|
||||||
if appOptions.UseStdout {
|
|
||||||
appOptions.HideLogo = true
|
|
||||||
}
|
|
||||||
if !appOptions.HideLogo {
|
|
||||||
fmt.Println(`
|
|
||||||
,_
|
|
||||||
>' )
|
|
||||||
croc version ` + fmt.Sprintf("%5s", version) + ` ( ( \
|
|
||||||
|| \
|
|
||||||
/^^^^\ ||
|
|
||||||
/^^\________/0 \ ||
|
|
||||||
( ` + "`" + `~+++,,_||__,,++~^^^^^^^
|
|
||||||
...V^V^V^V^V^V^\...............................
|
|
||||||
|
|
||||||
`)
|
|
||||||
}
|
|
||||||
|
|
||||||
if appOptions.Relay {
|
if appOptions.Relay {
|
||||||
fmt.Println("running relay on local address " + GetLocalIP())
|
fmt.Println("running relay on local address " + GetLocalIP())
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue