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

share public ip as info

This commit is contained in:
Zack Scholl 2019-05-01 17:44:09 -06:00
parent b109b419de
commit 359dc4549b

View file

@ -58,10 +58,10 @@ type Options struct {
} }
type Client struct { type Client struct {
Options Options Options Options
Pake *pake.Pake Pake *pake.Pake
Key crypt.Encryption Key crypt.Encryption
ExternalIP string ExternalIP, ExternalIPConnected string
// steps involved in forming relationship // steps involved in forming relationship
Step1ChannelSecured bool Step1ChannelSecured bool
@ -429,8 +429,9 @@ func (c *Client) processMessage(payload []byte) (done bool, err error) {
salt := make([]byte, 8) salt := make([]byte, 8)
rand.Read(salt) rand.Read(salt)
err = message.Send(c.conn[0], c.Key, message.Message{ err = message.Send(c.conn[0], c.Key, message.Message{
Type: "salt", Type: "salt",
Bytes: salt, Bytes: salt,
Message: c.ExternalIP,
}) })
if err != nil { if err != nil {
return return
@ -466,8 +467,9 @@ func (c *Client) processMessage(payload []byte) (done bool, err error) {
if !c.Options.IsSender { if !c.Options.IsSender {
log.Debug("sending salt back") log.Debug("sending salt back")
err = message.Send(c.conn[0], c.Key, message.Message{ err = message.Send(c.conn[0], c.Key, message.Message{
Type: "salt", Type: "salt",
Bytes: m.Bytes, Bytes: m.Bytes,
Message: c.ExternalIP,
}) })
} }
log.Debugf("session key is verified, generating encryption with salt: %x", m.Bytes) log.Debugf("session key is verified, generating encryption with salt: %x", m.Bytes)
@ -479,6 +481,8 @@ func (c *Client) processMessage(payload []byte) (done bool, err error) {
if err != nil { if err != nil {
return true, err return true, err
} }
c.ExternalIPConnected = m.Message
log.Debugf("connected as %s -> %s", c.ExternalIP, c.ExternalIPConnected)
c.Step1ChannelSecured = true c.Step1ChannelSecured = true
case "error": case "error":
// c.spinner.Stop() // c.spinner.Stop()