4
0
mirror of https://github.com/cwinfo/yggdrasil-go.git synced 2025-07-09 13:24:05 +00:00

more TunAdapter migration

This commit is contained in:
Arceliar
2019-08-25 18:53:11 -05:00
parent aaf34c6304
commit b2a2e251ad
3 changed files with 84 additions and 78 deletions

View File

@ -27,12 +27,10 @@ type tunConn struct {
}
func (s *tunConn) close() {
s.tun.mutex.Lock()
defer s.tun.mutex.Unlock()
s._close_nomutex()
s.tun.RecvFrom(s, s._close_from_tun)
}
func (s *tunConn) _close_nomutex() {
func (s *tunConn) _close_from_tun() {
s.conn.Close()
delete(s.tun.addrToConn, s.addr)
delete(s.tun.subnetToConn, s.snet)
@ -118,6 +116,12 @@ func (s *tunConn) _read(bs []byte) (err error) {
return
}
func (s *tunConn) writeFrom(from phony.Actor, bs []byte) {
s.RecvFrom(from, func() {
s._write(bs)
})
}
func (s *tunConn) _write(bs []byte) (err error) {
select {
case <-s.stop: