Ejemplo n.º 1
0
func newTap(name string, addr string) (iface *water.Interface, err error) {
	iface, err = water.NewTAP(name)
	if err != nil {
		return nil, err
	}
	logger.Info("interface %v created", iface.Name())

	cmd := exec.Command("ip", "link", "set", "dev", iface.Name(), "up")
	err = cmd.Run()
	if err != nil {
		return nil, err
	}

	//broadcast := net.ParseIP(addr)
	//[]byte(broadcast)[3] = 255

	cmd = exec.Command("ip", "addr", "add", addr, "dev", iface.Name())
	err = cmd.Run()
	if err != nil {
		return nil, err
	}

	return iface, nil
}
Ejemplo n.º 2
0
func newTAPer(ifaceName string) (io.ReadWriter, error) {
	return water.NewTAP(ifaceName)
}