-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cd17884
commit 94f0582
Showing
6 changed files
with
84 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package network | ||
|
||
import ( | ||
"sync" | ||
|
||
"github.com/sagernet/sing/common/buf" | ||
M "github.com/sagernet/sing/common/metadata" | ||
) | ||
|
||
type PacketBuffer struct { | ||
Buffer *buf.Buffer | ||
Destination M.Socksaddr | ||
} | ||
|
||
var packetPool = sync.Pool{ | ||
New: func() any { | ||
return new(PacketBuffer) | ||
}, | ||
} | ||
|
||
func NewPacketBuffer() *PacketBuffer { | ||
return packetPool.Get().(*PacketBuffer) | ||
} | ||
|
||
func PutPacketBuffer(packet *PacketBuffer) { | ||
*packet = PacketBuffer{} | ||
packetPool.Put(packet) | ||
} | ||
|
||
func ReleaseMultiPacketBuffer(packetBuffers []*PacketBuffer) { | ||
for _, packet := range packetBuffers { | ||
packet.Buffer.Release() | ||
PutPacketBuffer(packet) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters