@@ -123,7 +123,15 @@ class APIFirewallNATPortForwardUpdate extends APIModel {
123123 if (isset ($ this ->initial_data ['src ' ])) {
124124 $ rule_check = APITools \is_valid_rule_addr ($ this ->initial_data ['src ' ], "source " );
125125 if ($ rule_check ["valid " ]) {
126+ # Retain the source port and update the source array
127+ $ origin_port = $ this ->validated_data ["source " ]["port " ];
126128 $ this ->validated_data ["source " ] = $ rule_check ["data " ]["source " ];
129+
130+ # If we had a source port, rewrite it
131+ if (isset ($ origin_port )) {
132+ $ this ->validated_data ["source " ]["port " ] = $ origin_port ;
133+ }
134+
127135 } else {
128136 $ this ->errors [] = APIResponse \get (4011 );
129137 }
@@ -135,7 +143,14 @@ class APIFirewallNATPortForwardUpdate extends APIModel {
135143 if (isset ($ this ->initial_data ['dst ' ])) {
136144 $ rule_check = APITools \is_valid_rule_addr ($ this ->initial_data ['dst ' ], "destination " );
137145 if ($ rule_check ["valid " ]) {
146+ # Retain the destination port and update the destination array
147+ $ origin_port = $ this ->validated_data ["destination " ]["port " ];
138148 $ this ->validated_data ["destination " ] = $ rule_check ["data " ]["destination " ];
149+
150+ # If we had a destination port, rewrite it
151+ if (isset ($ origin_port )) {
152+ $ this ->validated_data ["destination " ]["port " ] = $ origin_port ;
153+ }
139154 } else {
140155 $ this ->errors [] = APIResponse \get (4012 );
141156 }
0 commit comments