mirror of https://github.com/schollz/croc.git
add option to disable compression Fixes #239
This commit is contained in:
parent
555ddec5e3
commit
87e54acd8a
|
@ -78,6 +78,7 @@ func Run() (err error) {
|
||||||
cli.BoolFlag{Name: "debug", Usage: "toggle debug mode"},
|
cli.BoolFlag{Name: "debug", Usage: "toggle debug mode"},
|
||||||
cli.BoolFlag{Name: "yes", Usage: "automatically agree to all prompts"},
|
cli.BoolFlag{Name: "yes", Usage: "automatically agree to all prompts"},
|
||||||
cli.BoolFlag{Name: "stdout", Usage: "redirect file to stdout"},
|
cli.BoolFlag{Name: "stdout", Usage: "redirect file to stdout"},
|
||||||
|
cli.BoolFlag{Name: "no-compress", Usage: "disable compression"},
|
||||||
cli.BoolFlag{Name: "ask", Usage: "make sure sender and recipient are prompted"},
|
cli.BoolFlag{Name: "ask", Usage: "make sure sender and recipient are prompted"},
|
||||||
cli.StringFlag{Name: "relay", Value: models.DEFAULT_RELAY, Usage: "address of the relay"},
|
cli.StringFlag{Name: "relay", Value: models.DEFAULT_RELAY, Usage: "address of the relay"},
|
||||||
cli.StringFlag{Name: "relay6", Value: models.DEFAULT_RELAY6, Usage: "ipv6 address of the relay"},
|
cli.StringFlag{Name: "relay6", Value: models.DEFAULT_RELAY6, Usage: "ipv6 address of the relay"},
|
||||||
|
@ -162,6 +163,7 @@ func send(c *cli.Context) (err error) {
|
||||||
NoMultiplexing: c.Bool("no-multi"),
|
NoMultiplexing: c.Bool("no-multi"),
|
||||||
RelayPassword: determinePass(c),
|
RelayPassword: determinePass(c),
|
||||||
SendingText: c.String("text") != "",
|
SendingText: c.String("text") != "",
|
||||||
|
NoCompress: c.GlobalBool("no-compress"),
|
||||||
}
|
}
|
||||||
if crocOptions.RelayAddress != models.DEFAULT_RELAY {
|
if crocOptions.RelayAddress != models.DEFAULT_RELAY {
|
||||||
crocOptions.RelayAddress6 = ""
|
crocOptions.RelayAddress6 = ""
|
||||||
|
|
|
@ -62,6 +62,7 @@ type Options struct {
|
||||||
DisableLocal bool
|
DisableLocal bool
|
||||||
Ask bool
|
Ask bool
|
||||||
SendingText bool
|
SendingText bool
|
||||||
|
NoCompress bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// Client holds the state of the croc transfer
|
// Client holds the state of the croc transfer
|
||||||
|
@ -140,6 +141,7 @@ type SenderInfo struct {
|
||||||
MachineID string
|
MachineID string
|
||||||
Ask bool
|
Ask bool
|
||||||
SendingText bool
|
SendingText bool
|
||||||
|
NoCompress bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// New establishes a new connection for transferring files between two instances.
|
// New establishes a new connection for transferring files between two instances.
|
||||||
|
@ -700,6 +702,10 @@ func (c *Client) processMessageFileInfo(m message.Message) (done bool, err error
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
c.Options.SendingText = senderInfo.SendingText
|
c.Options.SendingText = senderInfo.SendingText
|
||||||
|
c.Options.NoCompress = senderInfo.NoCompress
|
||||||
|
if c.Options.NoCompress {
|
||||||
|
log.Debug("disabling compression")
|
||||||
|
}
|
||||||
if c.Options.SendingText {
|
if c.Options.SendingText {
|
||||||
c.Options.Stdout = true
|
c.Options.Stdout = true
|
||||||
}
|
}
|
||||||
|
@ -960,6 +966,7 @@ func (c *Client) updateIfSenderChannelSecured() (err error) {
|
||||||
MachineID: machID,
|
MachineID: machID,
|
||||||
Ask: c.Options.Ask,
|
Ask: c.Options.Ask,
|
||||||
SendingText: c.Options.SendingText,
|
SendingText: c.Options.SendingText,
|
||||||
|
NoCompress: c.Options.NoCompress,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error(err)
|
log.Error(err)
|
||||||
|
@ -1281,7 +1288,9 @@ func (c *Client) receiveData(i int) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
data = compress.Decompress(data)
|
if !c.Options.NoCompress {
|
||||||
|
data = compress.Decompress(data)
|
||||||
|
}
|
||||||
|
|
||||||
// get position
|
// get position
|
||||||
var position uint64
|
var position uint64
|
||||||
|
@ -1366,13 +1375,22 @@ func (c *Client) sendData(i int) {
|
||||||
// log.Debugf("sending chunk %d", pos)
|
// log.Debugf("sending chunk %d", pos)
|
||||||
posByte := make([]byte, 8)
|
posByte := make([]byte, 8)
|
||||||
binary.LittleEndian.PutUint64(posByte, pos)
|
binary.LittleEndian.PutUint64(posByte, pos)
|
||||||
|
var err error
|
||||||
dataToSend, err := crypt.Encrypt(
|
var dataToSend []byte
|
||||||
compress.Compress(
|
if c.Options.NoCompress {
|
||||||
|
dataToSend, err = crypt.Encrypt(
|
||||||
append(posByte, data[:n]...),
|
append(posByte, data[:n]...),
|
||||||
),
|
c.Key,
|
||||||
c.Key,
|
)
|
||||||
)
|
} else {
|
||||||
|
|
||||||
|
dataToSend, err = crypt.Encrypt(
|
||||||
|
compress.Compress(
|
||||||
|
append(posByte, data[:n]...),
|
||||||
|
),
|
||||||
|
c.Key,
|
||||||
|
)
|
||||||
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue