mirror of
https://github.com/amnezia-vpn/amneziawg-go.git
synced 2026-05-17 00:05:50 +03:00
- fix the bug that transport packet interprets as init/resp/cookie with the same size - cleanup error responses - reduce buffer allocations
32 lines
555 B
Go
32 lines
555 B
Go
package device
|
|
|
|
import (
|
|
"encoding/binary"
|
|
"time"
|
|
)
|
|
|
|
func newTimestampObf(_ string) (obf, error) {
|
|
return ×tampObf{}, nil
|
|
}
|
|
|
|
type timestampObf struct{}
|
|
|
|
func (o *timestampObf) Obfuscate(dst, src []byte) {
|
|
t := uint32(time.Now().Unix())
|
|
binary.BigEndian.PutUint32(dst, t)
|
|
}
|
|
|
|
func (o *timestampObf) Deobfuscate(dst, src []byte) bool {
|
|
// replay attack check?
|
|
// requires time to be always synchronized
|
|
return true
|
|
}
|
|
|
|
func (o *timestampObf) ObfuscatedLen(n int) int {
|
|
return 4
|
|
}
|
|
|
|
func (o *timestampObf) DeobfuscatedLen(n int) int {
|
|
return 0
|
|
}
|