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:
@ -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:
|
||||
|
Reference in New Issue
Block a user