mirror of
https://github.com/MetaCubeX/mihomo.git
synced 2024-12-26 20:26:06 +08:00
27 lines
503 B
Go
27 lines
503 B
Go
|
package nat
|
||
|
|
||
|
import (
|
||
|
"net"
|
||
|
|
||
|
"github.com/Dreamacro/clash/common/atomic"
|
||
|
C "github.com/Dreamacro/clash/constant"
|
||
|
)
|
||
|
|
||
|
type writeBackProxy struct {
|
||
|
wb atomic.TypedValue[C.WriteBack]
|
||
|
}
|
||
|
|
||
|
func (w *writeBackProxy) WriteBack(b []byte, addr net.Addr) (n int, err error) {
|
||
|
return w.wb.Load().WriteBack(b, addr)
|
||
|
}
|
||
|
|
||
|
func (w *writeBackProxy) UpdateWriteBack(wb C.WriteBack) {
|
||
|
w.wb.Store(wb)
|
||
|
}
|
||
|
|
||
|
func NewWriteBackProxy(wb C.WriteBack) C.WriteBackProxy {
|
||
|
w := &writeBackProxy{}
|
||
|
w.UpdateWriteBack(wb)
|
||
|
return w
|
||
|
}
|