Splice
A high-level and multi-os library for manipulating network interfaces, links, and routes.
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.
Getting Started
Add Splice to Your Workspace
go get gitlab.com/ArroyoNetworks/splice
Examples
Add an Address to an Interface
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)
}
}
Bring an Interface Down
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)
}
}
Add a Route to the Routing Table
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)
}
}
Supported Operating Systems
Linux
The following are supported on Linux systems:
- IP Address Configuration
- Interface Link Manipulation
- Route Manipulation
Dependencies
The following are third-party dependencies used for providing Linux support:
Unit Tests
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 gitlab.com/ArroyoNetworks/splice
-
Run the Unit Tests
sudo -E go test github.com/ArroyoNetworks/splice
macOS
Not yet implemented.
Windows
Not yet implemented.
License
Copyright 2017 Arroyo Networks, LLC. All rights reserved.
This project is governed by a BSD-style license. See LICENSE for the full license text.