mirror of
https://github.com/yggdrasil-network/yggdrasil-go.git
synced 2025-04-29 06:35:07 +03:00
update to latest phony, adjust interface use accordingly
This commit is contained in:
parent
4d9c6342a7
commit
3845f81357
14 changed files with 80 additions and 76 deletions
|
@ -80,7 +80,7 @@ func (sinfo *sessionInfo) reconfigure(e chan error) {
|
|||
|
||||
// TODO remove this, call SyncExec directly
|
||||
func (sinfo *sessionInfo) doFunc(f func()) {
|
||||
<-sinfo.SyncExec(f)
|
||||
phony.Block(sinfo, f)
|
||||
}
|
||||
|
||||
// Represents a session ping/pong packet, andincludes information like public keys, a session handle, coords, a timestamp to prevent replays, and the tun/tap MTU.
|
||||
|
@ -164,7 +164,7 @@ func (ss *sessions) init(r *router) {
|
|||
func (ss *sessions) reconfigure(e chan error) {
|
||||
defer close(e)
|
||||
responses := make(map[crypto.Handle]chan error)
|
||||
<-ss.router.SyncExec(func() {
|
||||
phony.Block(ss.router, func() {
|
||||
for index, session := range ss.sinfos {
|
||||
responses[index] = make(chan error)
|
||||
go session.reconfigure(responses[index])
|
||||
|
@ -287,7 +287,7 @@ func (ss *sessions) cleanup() {
|
|||
}
|
||||
|
||||
func (sinfo *sessionInfo) doRemove() {
|
||||
sinfo.sessions.router.RecvFrom(nil, func() {
|
||||
sinfo.sessions.router.Act(nil, func() {
|
||||
sinfo.sessions.removeSession(sinfo)
|
||||
})
|
||||
}
|
||||
|
@ -341,7 +341,7 @@ func (ss *sessions) getSharedKey(myPriv *crypto.BoxPrivKey,
|
|||
|
||||
// Sends a session ping by calling sendPingPong in ping mode.
|
||||
func (sinfo *sessionInfo) ping(from phony.Actor) {
|
||||
sinfo.RecvFrom(from, func() {
|
||||
sinfo.Act(from, func() {
|
||||
sinfo._sendPingPong(false)
|
||||
})
|
||||
}
|
||||
|
@ -362,14 +362,14 @@ func (sinfo *sessionInfo) _sendPingPong(isPong bool) {
|
|||
}
|
||||
packet := p.encode()
|
||||
// TODO rewrite the below if/when the peer struct becomes an actor, to not go through the router first
|
||||
sinfo.sessions.router.RecvFrom(sinfo, func() { sinfo.sessions.router.out(packet) })
|
||||
sinfo.sessions.router.Act(sinfo, func() { sinfo.sessions.router.out(packet) })
|
||||
if sinfo.pingTime.Before(sinfo.time) {
|
||||
sinfo.pingTime = time.Now()
|
||||
}
|
||||
}
|
||||
|
||||
func (sinfo *sessionInfo) setConn(from phony.Actor, conn *Conn) {
|
||||
sinfo.RecvFrom(from, func() {
|
||||
sinfo.Act(from, func() {
|
||||
sinfo.conn = conn
|
||||
sinfo.conn.setMTU(sinfo, sinfo._getMTU())
|
||||
})
|
||||
|
@ -404,7 +404,7 @@ func (ss *sessions) handlePing(ping *sessionPing) {
|
|||
ss.listenerMutex.Unlock()
|
||||
}
|
||||
if sinfo != nil {
|
||||
sinfo.RecvFrom(ss.router, func() {
|
||||
sinfo.Act(ss.router, func() {
|
||||
// Update the session
|
||||
if !sinfo._update(ping) { /*panic("Should not happen in testing")*/
|
||||
return
|
||||
|
@ -472,7 +472,7 @@ func (sinfo *sessionInfo) _updateNonce(theirNonce *crypto.BoxNonce) {
|
|||
// Called after coord changes, so attemtps to use a session will trigger a new ping and notify the remote end of the coord change.
|
||||
func (ss *sessions) reset() {
|
||||
for _, sinfo := range ss.sinfos {
|
||||
sinfo.RecvFrom(ss.router, func() {
|
||||
sinfo.Act(ss.router, func() {
|
||||
sinfo.reset = true
|
||||
})
|
||||
}
|
||||
|
@ -488,7 +488,7 @@ type FlowKeyMessage struct {
|
|||
}
|
||||
|
||||
func (sinfo *sessionInfo) recv(from phony.Actor, packet *wire_trafficPacket) {
|
||||
sinfo.RecvFrom(from, func() {
|
||||
sinfo.Act(from, func() {
|
||||
sinfo._recvPacket(packet)
|
||||
})
|
||||
}
|
||||
|
@ -562,7 +562,7 @@ func (sinfo *sessionInfo) _send(msg FlowKeyMessage) {
|
|||
util.PutBytes(p.Payload)
|
||||
// Send the packet
|
||||
// TODO replace this with a send to the peer struct if that becomes an actor
|
||||
sinfo.sessions.router.RecvFrom(sinfo, func() {
|
||||
sinfo.sessions.router.Act(sinfo, func() {
|
||||
sinfo.sessions.router.out(packet)
|
||||
})
|
||||
}
|
||||
|
@ -574,7 +574,7 @@ func (sinfo *sessionInfo) _send(msg FlowKeyMessage) {
|
|||
}
|
||||
|
||||
func (sinfo *sessionInfo) checkCallbacks() {
|
||||
sinfo.RecvFrom(nil, func() {
|
||||
sinfo.Act(nil, func() {
|
||||
if len(sinfo.callbacks) > 0 {
|
||||
select {
|
||||
case callback := <-sinfo.callbacks[0]:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue