mirror of https://github.com/schollz/croc.git
ok windows seems to work now
This commit is contained in:
parent
5397634217
commit
26f0fc3319
4
main.go
4
main.go
|
@ -69,6 +69,7 @@ func main() {
|
||||||
cli.BoolFlag{Name: "debug", Usage: "increase verbosity (a lot)"},
|
cli.BoolFlag{Name: "debug", Usage: "increase verbosity (a lot)"},
|
||||||
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: "force-tcp", Usage: "force TCP"},
|
||||||
cli.StringFlag{Name: "port", Value: "8153", Usage: "port that the websocket listens on"},
|
cli.StringFlag{Name: "port", Value: "8153", Usage: "port that the websocket listens on"},
|
||||||
cli.StringFlag{Name: "tcp-port", Value: "8154", Usage: "port that the tcp server listens on"},
|
cli.StringFlag{Name: "tcp-port", Value: "8154", Usage: "port that the tcp server listens on"},
|
||||||
cli.StringFlag{Name: "curve", Value: "siec", Usage: "specify elliptic curve to use (p224, p256, p384, p521, siec)"},
|
cli.StringFlag{Name: "curve", Value: "siec", Usage: "specify elliptic curve to use (p224, p256, p384, p521, siec)"},
|
||||||
|
@ -96,6 +97,9 @@ func main() {
|
||||||
cr.RelayWebsocketPort = c.String("port")
|
cr.RelayWebsocketPort = c.String("port")
|
||||||
cr.RelayTCPPort = c.String("tcp-port")
|
cr.RelayTCPPort = c.String("tcp-port")
|
||||||
cr.CurveType = c.String("curve")
|
cr.CurveType = c.String("curve")
|
||||||
|
if c.GlobalBool("force-tcp") {
|
||||||
|
cr.ForceSend = 2
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -70,26 +70,20 @@ func (c Comm) Read() (buf []byte, numBytes int, bs []byte, err error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, 0, nil, err
|
return nil, 0, nil, err
|
||||||
}
|
}
|
||||||
buf = make([]byte, numBytes)
|
buf = []byte{}
|
||||||
tmp = make([]byte, numBytes)
|
tmp = make([]byte, numBytes)
|
||||||
bufStart := 0
|
|
||||||
for {
|
for {
|
||||||
n, err := c.connection.Read(tmp)
|
n, err := c.connection.Read(tmp)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, 0, nil, err
|
return nil, 0, nil, err
|
||||||
}
|
}
|
||||||
tmpCopy := make([]byte, n)
|
tmpCopy = make([]byte, n)
|
||||||
// Copy the buffer so it doesn't get changed while read by the recipient.
|
// Copy the buffer so it doesn't get changed while read by the recipient.
|
||||||
copy(tmpCopy, tmp[:n])
|
copy(tmpCopy, tmp[:n])
|
||||||
|
buf = append(buf, bytes.TrimRight(tmpCopy, "\x00")...)
|
||||||
tmpCopy = bytes.TrimSpace(tmpCopy)
|
if len(buf) < numBytes {
|
||||||
tmpCopy = bytes.Replace(tmpCopy, []byte(" "), []byte{}, -1)
|
|
||||||
tmpCopy = bytes.Trim(tmpCopy, "\x00")
|
|
||||||
copy(buf[bufStart:bufStart+len(tmpCopy)], tmpCopy[:])
|
|
||||||
bufStart = len(buf)
|
|
||||||
if bufStart < numBytes {
|
|
||||||
// shrink the amount we need to read
|
// shrink the amount we need to read
|
||||||
tmp = tmp[:numBytes-bufStart]
|
tmp = tmp[:numBytes-len(buf)]
|
||||||
} else {
|
} else {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
|
@ -221,7 +221,7 @@ func receive(forceSend int, serverAddress, serverTCP string, isLocal bool, c *we
|
||||||
var enc crypt.Encryption
|
var enc crypt.Encryption
|
||||||
err = json.Unmarshal(message, &enc)
|
err = json.Unmarshal(message, &enc)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorf("%s: %s (%d/%d) %+v", err.Error(), message, len(message), numBytes, bs)
|
log.Errorf("%s: [%s] [%+v] (%d/%d) %+v", err.Error(), message, message, len(message), numBytes, bs)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
decrypted, err := enc.Decrypt(sessionKey, !fstats.IsEncrypted)
|
decrypted, err := enc.Decrypt(sessionKey, !fstats.IsEncrypted)
|
||||||
|
|
Loading…
Reference in New Issue