github.com/metacubex/mihomo@v1.18.5/component/nat/proxy.go (about) 1 package nat 2 3 import ( 4 "net" 5 6 "github.com/metacubex/mihomo/common/atomic" 7 C "github.com/metacubex/mihomo/constant" 8 ) 9 10 type writeBackProxy struct { 11 wb atomic.TypedValue[C.WriteBack] 12 } 13 14 func (w *writeBackProxy) WriteBack(b []byte, addr net.Addr) (n int, err error) { 15 return w.wb.Load().WriteBack(b, addr) 16 } 17 18 func (w *writeBackProxy) UpdateWriteBack(wb C.WriteBack) { 19 w.wb.Store(wb) 20 } 21 22 func NewWriteBackProxy(wb C.WriteBack) C.WriteBackProxy { 23 w := &writeBackProxy{} 24 w.UpdateWriteBack(wb) 25 return w 26 }