Begin work on source address caching (linux)

This commit is contained in:
Mathias Hall-Andersen
2017-09-24 21:35:25 +02:00
parent c545d63bb9
commit eefa47b0f9
5 changed files with 273 additions and 11 deletions

View File

@@ -1,9 +1,31 @@
package main
import (
"errors"
"net"
)
func parseEndpoint(s string) (*net.UDPAddr, error) {
// ensure that the host is an IP address
host, _, err := net.SplitHostPort(s)
if err != nil {
return nil, err
}
if ip := net.ParseIP(host); ip == nil {
return nil, errors.New("Failed to parse IP address: " + host)
}
// parse address and port
addr, err := net.ResolveUDPAddr("udp", s)
if err != nil {
return nil, err
}
return addr, err
}
func updateUDPConn(device *Device) error {
netc := &device.net
netc.mutex.Lock()