- if new_resource.dest_ports
- rule << "#{proto} dport { #{nftables_dest_ports} }"
- end
-
- if new_resource.source == "osm"
- rule << "#{ip} saddr @#{ip}-osm-addresses"
- elsif new_resource.source =~ /^net:(.*)$/
- addresses = Regexp.last_match(1).split(",").join(", ")
-
- rule << "#{ip} saddr { #{addresses} }"
- end
-
- if new_resource.dest == "osm"
- rule << "#{ip} daddr @#{ip}-osm-addresses"
- elsif new_resource.dest =~ /^net:(.*)$/
- addresses = Regexp.last_match(1).split(",").join(", ")
-
- rule << "#{ip} daddr { #{addresses} }"
- end
+ rule << "#{protocol} sport #{format_ports(new_resource.source_ports)}" if new_resource.source_ports
+ rule << "#{protocol} dport #{format_ports(new_resource.dest_ports)}" if new_resource.dest_ports
+ rule << "#{ip} saddr #{format_addresses(source, ip)}" if new_resource.source
+ rule << "#{ip} daddr #{format_addresses(dest, ip)}" if new_resource.dest
+ rule << "ct state new" if new_resource.protocol == :tcp