github https://github.com/godbus/dbus

增加一个端口

go
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
package main

import (
	"github.com/godbus/dbus/v5"
)

func main() {
	cli, err := dbus.SystemBus()

	if err != nil {
		panic(err)
	}

	obj := cli.Object("org.fedoraproject.FirewallD1", "/org/fedoraproject/FirewallD1")
	call := obj.Call("oorg.fedoraproject.FirewallD1.zone.addPort", 0, "public", "81", "tcp", "30000")

	if call.Err != nil {
		panic(call.Err)
	}
}

go-dbus 简单教程 https://blog.csdn.net/mathmonkey/article/details/38095289