Initial implementation of source caching

Yet untested.
This commit is contained in:
Mathias Hall-Andersen
2017-10-16 21:33:47 +02:00
parent a72b0f7ae5
commit e86d03dca2
10 changed files with 84 additions and 83 deletions

View File

@@ -133,7 +133,7 @@ func sockaddrToString(addr unix.RawSockaddrInet6) string {
}
}
func (end *Endpoint) DestinationIP() net.IP {
func (end *Endpoint) DstIP() net.IP {
switch end.dst.Family {
case unix.AF_INET6:
return end.dst.Addr[:]
@@ -150,20 +150,24 @@ func (end *Endpoint) DestinationIP() net.IP {
}
}
func (end *Endpoint) SourceToBytes() []byte {
func (end *Endpoint) SrcToBytes() []byte {
ptr := unsafe.Pointer(&end.src)
arr := (*[unix.SizeofSockaddrInet6]byte)(ptr)
return arr[:]
}
func (end *Endpoint) SourceToString() string {
func (end *Endpoint) SrcToString() string {
return sockaddrToString(end.src)
}
func (end *Endpoint) DestinationToString() string {
func (end *Endpoint) DstToString() string {
return sockaddrToString(end.dst)
}
func (end *Endpoint) ClearDst() {
end.dst = unix.RawSockaddrInet6{}
}
func (end *Endpoint) ClearSrc() {
end.src = unix.RawSockaddrInet6{}
}