@@ -151,28 +151,25 @@ class APIFirewallNATOutboundMappingUpdate extends APIModel {
151151 if (isset ($ this ->initial_data ['target ' ])) {
152152 # Require the target to be a valid IPv4 subnet, address, alias or empty string for iface address
153153 if (APITools \is_ip_subnet_or_alias ($ this ->initial_data ['target ' ]) === "ipv4_subnet " ) {
154- $ this ->validated_data ["target " ] = "other-subnet " ;
155- $ this ->validated_data ['targetip ' ] = explode ("/ " , $ this ->initial_data ["target " ])[0 ];
156- $ this ->validated_data ['targetip_subnet ' ] = explode ("/ " , $ this ->initial_data ["target " ])[1 ];
157- } elseif (APITools \is_ip_subnet_or_alias ($ this ->initial_data ['target ' ]) === "ipv4_addr " ) {
158- $ this ->validated_data ["target " ] = "other-subnet " ;
159- $ this ->validated_data ["targetip " ] = $ this ->initial_data ['target ' ];
160- $ this ->validated_data ['targetip_subnet ' ] = 32 ;
161- } elseif (APITools \is_ip_subnet_or_alias ($ this ->initial_data ['target ' ]) === "alias " ) {
162- # Only allow an alias if default or round-robin is chosen as the pool option
163- if (in_array ($ this ->validated_data ["poolopts " ], ["" , "round-robin " , "round-robin sticky-address " ])) {
164- # Remove existing target IPs/subnets and add our alias as the target
165- unset($ this ->validated_data ["targetip " ]);
166- unset($ this ->validated_data ["targetip_subnet " ]);
154+ $ this ->validated_data ['target ' ] = explode ("/ " , $ this ->initial_data ["target " ])[0 ];
155+ $ this ->validated_data ['target_subnet ' ] = explode ("/ " , $ this ->initial_data ["target " ])[1 ];
156+ }
157+ elseif (APITools \is_ip_subnet_or_alias ($ this ->initial_data ['target ' ]) === "ipv4_addr " ) {
158+ $ this ->validated_data ["target " ] = $ this ->initial_data ['target ' ];
159+ $ this ->validated_data ['target_subnet ' ] = 32 ;
160+ }
161+ elseif (APITools \is_ip_subnet_or_alias ($ this ->initial_data ['target ' ]) === "alias " ) {
162+ # Only allow an alias if round-robin is chosen as the pool option
163+ if (in_array ($ this ->validated_data ["poolopts " ], ["round-robin " , "round-robin sticky-address " ])) {
167164 $ this ->validated_data ["target " ] = $ this ->initial_data ['target ' ];
168165 } else {
169166 $ this ->errors [] = APIResponse \get (4096 );
170167 }
171- } elseif ( $ this -> initial_data [ " target " ] === "" ) {
172- $ this ->validated_data ["target " ] = "" ;
173- $ this ->validated_data [' targetip ' ] = " " ;
174- $ this -> validated_data [ ' targetip_subnet ' ] = "" ;
175- } else {
168+ }
169+ elseif ( $ this -> initial_data [ " target " ] === "" or $ this ->initial_data ["target " ] === $ this -> validated_data [ " interface " ]. " ip " ) {
170+ $ this ->validated_data [" target " ] = $ this -> validated_data [ " interface " ]. " ip " ;
171+ }
172+ else {
176173 $ this ->errors [] = APIResponse \get (4095 );
177174 }
178175 }
0 commit comments