Go to file
kayos@tcp.direct b673da7b39
Slimfast: drop last dependency, dep free
2023-12-02 00:46:40 -08:00
cmd Refactor: rename parse to ifup2json 2023-12-02 00:17:50 -08:00
.gitignore add .gitignore 2023-12-02 00:22:37 -08:00
LICENSE add LICENSE 2023-12-01 20:27:30 -08:00
README.md add README.md 2023-12-02 00:23:09 -08:00
errors.go Refactor: rename module 2023-12-02 00:23:34 -08:00
go.mod Slimfast: drop last dependency, dep free 2023-12-02 00:46:40 -08:00
go.sum Slimfast: drop last dependency, dep free 2023-12-02 00:46:40 -08:00
ifaces.go Slimfast: drop last dependency, dep free 2023-12-02 00:46:40 -08:00
ifaces_test.go Feat: Interfaces io.Reader and fmt.Stringer 2023-12-02 00:21:18 -08:00
netif.go Slimfast: drop last dependency, dep free 2023-12-02 00:46:40 -08:00
netif_test.go Refactor: rename module 2023-12-02 00:23:34 -08:00
util.go Slimfast: drop last dependency, dep free 2023-12-02 00:46:40 -08:00

ifupdown

GoDoc

golang library for working with network interfaces defined via ifupdown. commonly recognized as /etc/network/interfaces.

library

features

  • read+parse interfaces file
  • write interfaces file
  • validate interfaces file (basic)
  • validate interfaces file (thorough)
  • translate interfaces file to JSON
  • translate JSON to interfaces file

cmd

  • ifup2json - translate interfaces file to JSON
  • json2ifup - translate JSON to interfaces file

example usage

ifup2json

cat /etc/network/interfaces | ifup2json

{
	"eth2": {
		"name": "eth2",
		"auto": true,
		"address": "192.168.69.5",
		"netmask": "////AA==",
		"gateway": "192.168.69.1",
		"config": 3,
		"version": 1,
		"hooks": {
			"pre_up": [
				"echo yeet"
			],
			"post_down": [
				"echo yeeted"
			]
		}
	},
	"lo": {
		"name": "lo",
		"auto": true,
		"config": 1,
		"version": 1,
		"hooks": {}
	},
	"ns3": {
		"name": "ns3",
		"auto": true,
		"address": "10.9.0.6",
		"netmask": "////AAAAAAAAAAAAAAAAAA==",
		"config": 3,
		"version": 1,
		"hooks": {
			"pre_up": [
				"ip link add dev ns3 type wireguard"
			],
			"post_up": [
				"wg setconf ns3 /etc/wireguard/ns3.conf"
			]
		}
	}
}
json2ifup

cat /etc/network/interfaces | ifup2json | json2ifup

auto eth2
iface eth2 inet static
	address 192.168.69.5
	netmask 255.255.255.0
	gateway 192.168.69.1
	pre-up echo yeet
	post-down echo yeeted

auto lo
iface lo inet loopback

auto ns3
iface ns3 inet static
	address 10.9.0.6
	netmask 255.255.255.0
	pre-up ip link add dev ns3 type wireguard
	post-up wg setconf ns3 /etc/wireguard/ns3.conf