mirror of https://github.com/schollz/croc.git
compute addresses
This commit is contained in:
parent
b7f40b2181
commit
43026b9c2e
|
@ -203,6 +203,7 @@ func (c *Croc) processState(cd channelData) (err error) {
|
|||
// copy over the rest of the state
|
||||
c.cs.channel.Ports = cd.Ports
|
||||
c.cs.channel.EncryptedFileMetaData = cd.EncryptedFileMetaData
|
||||
c.cs.channel.Addresses = cd.Addresses
|
||||
|
||||
// update the Pake
|
||||
if cd.Pake != nil && cd.Pake.Role != c.cs.channel.Role {
|
||||
|
|
|
@ -128,6 +128,8 @@ type channelData struct {
|
|||
ReadyToRead bool `json:"ready_to_read"`
|
||||
// Error is sent if there is an error
|
||||
Error string `json:"error"`
|
||||
// Addresses of the sender and recipient, as determined by the relay
|
||||
Addresses [2]string `json:"addresses"`
|
||||
|
||||
// Sent on initialization, specific to a single user
|
||||
// UUID is sent out only to one person at a time
|
||||
|
|
|
@ -149,6 +149,8 @@ func (c *Croc) joinChannel(ws *websocket.Conn, cd channelData) (channel string,
|
|||
c.rs.channel[cd.Channel].Curve = "p256"
|
||||
}
|
||||
c.rs.channel[cd.Channel].websocketConn[cd.Role] = ws
|
||||
// assign the name
|
||||
c.rs.channel[cd.Channel].Addresses[cd.Role] = ws.RemoteAddr().String()
|
||||
|
||||
log.Debugf("assigned role %d in channel '%s'", cd.Role, cd.Channel)
|
||||
return
|
||||
|
|
Loading…
Reference in New Issue