mirror of
https://github.com/MetaCubeX/mihomo.git
synced 2024-11-16 03:32:33 +08:00
25 lines
666 B
Go
25 lines
666 B
Go
package packet
|
|
|
|
import (
|
|
"github.com/sagernet/sing/common/buf"
|
|
M "github.com/sagernet/sing/common/metadata"
|
|
N "github.com/sagernet/sing/common/network"
|
|
)
|
|
|
|
type threadSafeSingPacketConn struct {
|
|
*threadSafePacketConn
|
|
singPacketConn SingPacketConn
|
|
}
|
|
|
|
var _ N.NetPacketConn = (*threadSafeSingPacketConn)(nil)
|
|
|
|
func (c *threadSafeSingPacketConn) WritePacket(buffer *buf.Buffer, destination M.Socksaddr) error {
|
|
c.access.Lock()
|
|
defer c.access.Unlock()
|
|
return c.singPacketConn.WritePacket(buffer, destination)
|
|
}
|
|
|
|
func (c *threadSafeSingPacketConn) ReadPacket(buffer *buf.Buffer) (destination M.Socksaddr, err error) {
|
|
return c.singPacketConn.ReadPacket(buffer)
|
|
}
|