compute addresses

This commit is contained in:
Zack Scholl 2018-07-01 11:09:25 -07:00
parent b7f40b2181
commit 43026b9c2e
3 changed files with 5 additions and 0 deletions

View File

@ -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 {

View File

@ -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

View File

@ -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