mirror of
https://github.com/schollz/croc.git
synced 2025-10-11 13:21:00 +02:00
compute addresses
This commit is contained in:
parent
b7f40b2181
commit
43026b9c2e
3 changed files with 5 additions and 0 deletions
|
@ -203,6 +203,7 @@ func (c *Croc) processState(cd channelData) (err error) {
|
||||||
// copy over the rest of the state
|
// copy over the rest of the state
|
||||||
c.cs.channel.Ports = cd.Ports
|
c.cs.channel.Ports = cd.Ports
|
||||||
c.cs.channel.EncryptedFileMetaData = cd.EncryptedFileMetaData
|
c.cs.channel.EncryptedFileMetaData = cd.EncryptedFileMetaData
|
||||||
|
c.cs.channel.Addresses = cd.Addresses
|
||||||
|
|
||||||
// update the Pake
|
// update the Pake
|
||||||
if cd.Pake != nil && cd.Pake.Role != c.cs.channel.Role {
|
if cd.Pake != nil && cd.Pake.Role != c.cs.channel.Role {
|
||||||
|
|
|
@ -128,6 +128,8 @@ type channelData struct {
|
||||||
ReadyToRead bool `json:"ready_to_read"`
|
ReadyToRead bool `json:"ready_to_read"`
|
||||||
// Error is sent if there is an error
|
// Error is sent if there is an error
|
||||||
Error string `json:"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
|
// Sent on initialization, specific to a single user
|
||||||
// UUID is sent out only to one person at a time
|
// 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].Curve = "p256"
|
||||||
}
|
}
|
||||||
c.rs.channel[cd.Channel].websocketConn[cd.Role] = ws
|
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)
|
log.Debugf("assigned role %d in channel '%s'", cd.Role, cd.Channel)
|
||||||
return
|
return
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue