This library is still considered beta, the interfaces may change until 1.0 is released.
Splice provides a high-level library for manipulating network interfaces, network links, and routes. Splice provides a common interface for multiple operating systems.
go get github.com/arroyonetworks/splice
package main
import (
"fmt"
"net"
"gitlab.com/ArroyoNetworks/splice"
)
func main() {
var err error
_, address, err := net.ParseCIDR("127.1.1.0/24")
intf, err := net.InterfaceByName("eth0")
err = splice.AddressAdd(intf, address)
if err != nil {
fmt.Println("Failed to Add Address")
fmt.Println(err)
}
}
package main
import (
"fmt"
"net"
"gitlab.com/ArroyoNetworks/splice"
)
func main() {
var err error
intf, err := net.InterfaceByName("wlan0")
err = splice.LinkBringDown(intf)
if err != nil {
fmt.Println("Failed to Bring Down Interface")
fmt.Println(err)
}
}
package main
import (
"fmt"
"net"
"gitlab.com/ArroyoNetworks/splice"
)
func main() {
var err error
_, dest, err := net.ParseCIDR("172.10.0.0/24")
intf, err := net.InterfaceByName("wlan0")
err = splice.RouteAddViaInterface(dest, intf)
if err != nil {
fmt.Println("Failed to Add Route")
fmt.Println(err)
}
}
The following are supported on Linux systems:
- IP Address Configuration
- Interface Link Manipulation
- Route Manipulation
The following are third-party dependencies used for providing Linux support:
Linux unit tests are automatically ran in a temporary networking namespace in order to prevent accidental alteration of the system's networking configuration. Because of this, test for Linux require the
cap_net_admin
capability.
-
Download the Test Dependencies
go get -t github.com/ArroyoNetworks/splice
-
Run the Unit Tests
sudo -E go test github.com/ArroyoNetworks/splice
The following are supported on Darwin systems:
- IP Address Configuration
- Interface Link Manipulation
The following are NOT yet supported:
- Route Manipulation (Accepting Merge Requests)
The following are third-party dependencies used for providing Darwin support:
Unit tests are not yet available for Darwin.
Not yet implemented.
Copyright 2018 Arroyo Networks, LLC. All rights reserved.
This project is governed by a BSD-style license. See LICENSE for the full license text.
- github.com/songgao/water: A native Go library for TUN/TAP interfaces. Includes support for Linux, macOS, and Windows.