Skip to content

Commit eaae02c

Browse files
authored
Merge pull request #3 from Alonza0314/fix/packet-write-to-chan
fix: wrong write
2 parents 714b49d + 49f21f0 commit eaae02c

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

client/client.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,14 +262,14 @@ func (c *DpTcpClient) packetEliminate(ctx context.Context) {
262262
}
263263

264264
func (c *DpTcpClient) packetEliminateMain(packet []byte) {
265-
c.writeToTun <- packet
266265
h := xxhash.Sum64(packet)
267266
if _, ok := c.packetMap.Get(h); ok {
268267
c.packetMap.Del(h)
269268
c.TunLog.Debugf("Eliminated packet %d", h)
270269
c.TunLog.Tracef("Eliminated packet %d, %x", h, packet)
271270
return
272271
}
272+
c.writeToTun <- packet
273273
c.packetMap.Set(h, struct{}{})
274274
c.TunLog.Debugf("Packet %d stored", h)
275275
c.TunLog.Tracef("Packet %d stored, %x", h, packet)

server/server.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,14 +261,14 @@ func (s *DpTcpServer) packetEliminate(ctx context.Context) {
261261
}
262262

263263
func (s *DpTcpServer) packetEliminateMain(packet []byte) {
264-
s.writeToTun <- packet
265264
h := xxhash.Sum64(packet)
266265
if _, ok := s.packetMap.Get(h); ok {
267266
s.packetMap.Del(h)
268267
s.TunLog.Debugf("Eliminated packet %d", h)
269268
s.TunLog.Tracef("Eliminated packet %d, %x", h, packet)
270269
return
271270
}
271+
s.writeToTun <- packet
272272
s.packetMap.Set(h, struct{}{})
273273
s.TunLog.Debugf("Packet %d stored", h)
274274
s.TunLog.Tracef("Packet %d stored, %x", h, packet)

0 commit comments

Comments
 (0)