func (i *Ipvs) Save() error {
	out, err := backendRun([]string{"ipvsadm", "-S", "-n"})
	if err != nil {
		return err
	}

	i.Services = make([]Service, 0, 0)
	serviceStrings := strings.Split(string(out), "-A")
	for j := range serviceStrings {
		if serviceStrings[j] == "" {
			continue
		}
		serverStrings := strings.Split(serviceStrings[j], "-a")
		serviceString := serverStrings[0]
		serverStrings = serverStrings[1:]
		// fmt.Println("Service: ", serviceString)
		service := parseService(serviceString)
		for k := range serverStrings {
			// fmt.Println("Server: ", serverStrings[j])
			server := parseServer(serverStrings[k])
			service.Servers = append(service.Servers, server)
		}
		i.Services = append(i.Services, service)
	}
	return nil
}
func (i *Ipvs) Save() error {
	out, err := backendRun([]string{"ipvsadm", "-S", "-n"})
	if err != nil {
		return err
	}

	i.Services = make([]Service, 0, 0)
	serviceStrings := strings.Split(string(out), "-A")
	for j := range serviceStrings {
		if serviceStrings[j] == "" {
			continue
		}
		serverStrings := strings.Split(serviceStrings[j], "-a")
		serviceString := serverStrings[0]
		serverStrings = serverStrings[1:]
		
		service := parseService(serviceString)
		for k := range serverStrings {
			
			server := parseServer(serverStrings[k])
			service.Servers = append(service.Servers, server)
		}
		i.Services = append(i.Services, service)
	}
	return nil
}
func ( i * Ipvs ) Save ( ) error { out , err := backendRun ( [ ] string { " " , " " , " " } ) if err != nil { return err } i . Services = make ( [ ] Service , 0 , 0 ) serviceStrings := strings . Split ( string ( out ) , " " ) for j := range serviceStrings { if serviceStrings [ j ] == " " { continue } serverStrings := strings . Split ( serviceStrings [ j ] , " " ) serviceString := serverStrings [ 0 ] serverStrings = serverStrings [ 1 : ] // fmt.Println("Service: ", serviceString) service := parseService ( serviceString ) for k := range serverStrings { // fmt.Println("Server: ", serverStrings[j]) server := parseServer ( serverStrings [ k ] ) service . Servers = append ( service . Servers , server ) } i . Services = append ( i . Services , service ) } return nil }
// save reads the applied ipvsadm rules from the host and saves them as i.Services
save reads the applied ipvsadm rules from the host and saves them as i . Services