func setupTun(tun *tuntap.Interface, addr *net.IPNet) error { if err := exec.Command("sudo", "ip", "-6", "addr", "add", "dev", tun.Name(), "local", addr.String()).Run(); err != nil { return err } if err := exec.Command("sudo", "ip", "link", "set", tun.Name(), "mtu", "1280", "up").Run(); err != nil { return err } return nil }
func runPacketCaptureLoop(iface *tuntap.Interface, tunio *TunIO) { for { packet, err := iface.ReadPacket() if err != nil { log.Fatalf("ReadPacket: %q", err) } if err := tunio.HandlePacket(iface, packet); err != nil { log.Fatalf("handlePacket: %q", err) } } }