I need to add an ip address to the Trust firewall zone. Wrote the code, trying to use the library. However, when calling the DBUS call method, the code in a strange way hangs up and the output is only via controller. I could only find the inserts of the library itself in the codebook. Unfortunately, I have so far more exploiter than the developer, do not scold much. I give my code as is. This is a prototype. Stop after e03. Thanks to everyone who responds, I have been fighting for work for a week now.
package main import ( "fmt" "log" "net" "github.com/godbus/dbus" ) func AEnableIp (ipin string) { ``` ipaddr := net.ParseIP(ipin) stipaddr := fmt.Sprintf("%s", ipaddr) var CallMethod string = "org.fedoraproject.FirewallD1.config.zone.addSource string:'"+stipaddr+"'" fmt.Println(CallMethod) log.Println("e01") //использую как dbus.SystemBusPrivate так и dbus.SystemBus conn, err := dbus.SystemBusPrivate() //conn, err := dbus.SystemBus() log.Println(conn) if err != nil { panic(err) } log.Println("e02") obj := conn.Object("org.fedoraproject.FirewallD1", "/org/fedoraproject/FirewallD1/config/zone/9") log.Println("e03") call := obj.Call(CallMethod, 0) log.Println("e04") if call.Err != nil { panic(call.Err) } ``` } func main() { var ipset string = "192.168.200.200" AEnableIp(ipset) }
sudo
- Bleser