remove encryption

This commit is contained in:
dingfeng.wong
2025-07-25 17:56:07 +08:00
parent f333402bd9
commit 7a67b9687c
4 changed files with 17 additions and 62 deletions
+4 -18
View File
@@ -13,7 +13,6 @@ import (
"sync"
"time"
"golang.org/x/crypto/chacha20poly1305"
"golang.org/x/net/ipv4"
"golang.org/x/net/ipv6"
"golang.zx2c4.com/wireguard/conn"
@@ -431,15 +430,12 @@ func calculatePaddingSize(packetSize, mtu int) int {
return paddedSize - lastUnit
}
/* Encrypts the elements in the queue
/* Processes the elements in the queue without encryption
* and marks them for sequential consumption (by releasing the mutex)
*
* Obs. One instance per core
*/
func (device *Device) RoutineEncryption(id int) {
var paddingZeros [PaddingMultiple]byte
var nonce [chacha20poly1305.NonceSize]byte
defer device.log.Verbosef("Routine: encryption worker %d - stopped", id)
device.log.Verbosef("Routine: encryption worker %d - started", id)
@@ -456,19 +452,9 @@ func (device *Device) RoutineEncryption(id int) {
binary.LittleEndian.PutUint32(fieldReceiver, elem.keypair.remoteIndex)
binary.LittleEndian.PutUint64(fieldNonce, elem.nonce)
// pad content to multiple of 16
paddingSize := calculatePaddingSize(len(elem.packet), int(device.tun.mtu.Load()))
elem.packet = append(elem.packet, paddingZeros[:paddingSize]...)
// encrypt content and release to consumer
binary.LittleEndian.PutUint64(nonce[4:], elem.nonce)
elem.packet = elem.keypair.send.Seal(
header,
nonce[:],
elem.packet,
nil,
)
// append content directly to header without encryption
copy(elem.buffer[MessageTransportHeaderSize:], elem.packet)
elem.packet = elem.buffer[:MessageTransportHeaderSize+len(elem.packet)]
}
elemsContainer.Unlock()
}