mirror of
https://github.com/KusakabeShi/EtherGuard-VPN.git
synced 2025-08-19 05:05:54 +02:00
global: begin modularization
This commit is contained in:
53
device/endpoint_test.go
Normal file
53
device/endpoint_test.go
Normal file
@@ -0,0 +1,53 @@
|
||||
/* SPDX-License-Identifier: MIT
|
||||
*
|
||||
* Copyright (C) 2017-2019 WireGuard LLC. All Rights Reserved.
|
||||
*/
|
||||
|
||||
package device
|
||||
|
||||
import (
|
||||
"math/rand"
|
||||
"net"
|
||||
)
|
||||
|
||||
type DummyEndpoint struct {
|
||||
src [16]byte
|
||||
dst [16]byte
|
||||
}
|
||||
|
||||
func CreateDummyEndpoint() (*DummyEndpoint, error) {
|
||||
var end DummyEndpoint
|
||||
if _, err := rand.Read(end.src[:]); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
_, err := rand.Read(end.dst[:])
|
||||
return &end, err
|
||||
}
|
||||
|
||||
func (e *DummyEndpoint) ClearSrc() {}
|
||||
|
||||
func (e *DummyEndpoint) SrcToString() string {
|
||||
var addr net.UDPAddr
|
||||
addr.IP = e.SrcIP()
|
||||
addr.Port = 1000
|
||||
return addr.String()
|
||||
}
|
||||
|
||||
func (e *DummyEndpoint) DstToString() string {
|
||||
var addr net.UDPAddr
|
||||
addr.IP = e.DstIP()
|
||||
addr.Port = 1000
|
||||
return addr.String()
|
||||
}
|
||||
|
||||
func (e *DummyEndpoint) SrcToBytes() []byte {
|
||||
return e.src[:]
|
||||
}
|
||||
|
||||
func (e *DummyEndpoint) DstIP() net.IP {
|
||||
return e.dst[:]
|
||||
}
|
||||
|
||||
func (e *DummyEndpoint) SrcIP() net.IP {
|
||||
return e.src[:]
|
||||
}
|
Reference in New Issue
Block a user