mirror of
https://github.com/schollz/croc.git
synced 2025-10-11 13:21:00 +02:00
debugging
This commit is contained in:
parent
e5f59fa0f9
commit
ff4307c3c6
1 changed files with 18 additions and 1 deletions
|
@ -189,7 +189,6 @@ func (s *server) clientCommunication(port string, c *comm.Comm) (room string, er
|
||||||
room = pingRoom
|
room = pingRoom
|
||||||
log.Debug("sending back pong")
|
log.Debug("sending back pong")
|
||||||
c.Send([]byte("pong"))
|
c.Send([]byte("pong"))
|
||||||
time.Sleep(100 * time.Millisecond)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
err = B.Update(Abytes)
|
err = B.Update(Abytes)
|
||||||
|
@ -443,62 +442,75 @@ func ConnectToTCPServer(address, password, room string, timelimit ...time.Durati
|
||||||
c, err = comm.NewConnection(address)
|
c, err = comm.NewConnection(address)
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Debug(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// get PAKE connection with server to establish strong key to transfer info
|
// get PAKE connection with server to establish strong key to transfer info
|
||||||
A, err := pake.InitCurve(weakKey, 0, "siec")
|
A, err := pake.InitCurve(weakKey, 0, "siec")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Debug(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
err = c.Send(A.Bytes())
|
err = c.Send(A.Bytes())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Debug(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
Bbytes, err := c.Receive()
|
Bbytes, err := c.Receive()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Debug(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
err = A.Update(Bbytes)
|
err = A.Update(Bbytes)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Debug(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
strongKey, err := A.SessionKey()
|
strongKey, err := A.SessionKey()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Debug(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
log.Debugf("strong key: %x", strongKey)
|
log.Debugf("strong key: %x", strongKey)
|
||||||
|
|
||||||
strongKeyForEncryption, salt, err := crypt.New(strongKey, nil)
|
strongKeyForEncryption, salt, err := crypt.New(strongKey, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Debug(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// send salt
|
// send salt
|
||||||
err = c.Send(salt)
|
err = c.Send(salt)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Debug(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Debug("sending password")
|
log.Debug("sending password")
|
||||||
bSend, err := crypt.Encrypt([]byte(password), strongKeyForEncryption)
|
bSend, err := crypt.Encrypt([]byte(password), strongKeyForEncryption)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Debug(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
err = c.Send(bSend)
|
err = c.Send(bSend)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Debug(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
log.Debug("waiting for first ok")
|
log.Debug("waiting for first ok")
|
||||||
enc, err := c.Receive()
|
enc, err := c.Receive()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Debug(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
data, err := crypt.Decrypt(enc, strongKeyForEncryption)
|
data, err := crypt.Decrypt(enc, strongKeyForEncryption)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Debug(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if !strings.Contains(string(data), "|||") {
|
if !strings.Contains(string(data), "|||") {
|
||||||
err = fmt.Errorf("bad response: %s", string(data))
|
err = fmt.Errorf("bad response: %s", string(data))
|
||||||
|
log.Debug(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
banner = strings.Split(string(data), "|||")[0]
|
banner = strings.Split(string(data), "|||")[0]
|
||||||
|
@ -506,23 +518,28 @@ func ConnectToTCPServer(address, password, room string, timelimit ...time.Durati
|
||||||
log.Debug("sending room")
|
log.Debug("sending room")
|
||||||
bSend, err = crypt.Encrypt([]byte(room), strongKeyForEncryption)
|
bSend, err = crypt.Encrypt([]byte(room), strongKeyForEncryption)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Debug(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
err = c.Send(bSend)
|
err = c.Send(bSend)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Debug(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
log.Debug("waiting for room confirmation")
|
log.Debug("waiting for room confirmation")
|
||||||
enc, err = c.Receive()
|
enc, err = c.Receive()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Debug(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
data, err = crypt.Decrypt(enc, strongKeyForEncryption)
|
data, err = crypt.Decrypt(enc, strongKeyForEncryption)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Debug(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if !bytes.Equal(data, []byte("ok")) {
|
if !bytes.Equal(data, []byte("ok")) {
|
||||||
err = fmt.Errorf("got bad response: %s", data)
|
err = fmt.Errorf("got bad response: %s", data)
|
||||||
|
log.Debug(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
log.Debug("all set")
|
log.Debug("all set")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue