Skip to content

Commit 6c54d59

Browse files
Copilotgsanchietti
andauthored
Fix NaN handling in mssfix and tun_mtu validation (#139)
* Initial plan * fix(ui): Add NaN validation for mssfix and tun_mtu inputs Co-authored-by: gsanchietti <[email protected]> * refactor: Store parsed values to avoid redundant parsing Co-authored-by: gsanchietti <[email protected]> * fix: Add radix parameter to parseInt calls Co-authored-by: gsanchietti <[email protected]> * fix(ui): Add missing error messages for tun_mtu and mssfix validation Co-authored-by: gsanchietti <[email protected]> * fix: Add radix parameter to all parseInt calls for consistency Co-authored-by: gsanchietti <[email protected]> * Apply suggestion from @gsanchietti * Apply suggestion from @gsanchietti * Apply suggestion from @gsanchietti * Apply suggestion from @gsanchietti --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: gsanchietti <[email protected]> Co-authored-by: Giacomo Sanchietti <[email protected]>
1 parent 160f9ff commit 6c54d59

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

ui/src/views/Settings.vue

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -589,14 +589,16 @@ export default {
589589
}
590590
591591
// validate tun_mtu: minimum 576
592-
if (parseInt(this.tun_mtu) < 576) {
592+
const tunMtuValue = parseInt(this.tun_mtu, 10);
593+
if (isNaN(tunMtuValue) || tunMtuValue < 576) {
593594
this.error.tun_mtu = this.$t("error.tun_mtu_min");
594595
this.focusElement("tun_mtu");
595596
isValidationOk = false;
596597
}
597598
598599
// validate mssfix: minimum 0
599-
if (parseInt(this.mssfix) < 0) {
600+
const mssfixValue = parseInt(this.mssfix, 10);
601+
if (isNaN(mssfixValue) || mssfixValue < 0) {
600602
this.error.mssfix = this.$t("error.mssfix_min");
601603
this.focusElement("mssfix");
602604
isValidationOk = false;
@@ -699,11 +701,11 @@ export default {
699701
ovpn_netmask: this.netmask,
700702
ovpn_cn: this.cn,
701703
api_user: this.user,
702-
loki_retention: parseInt(this.loki_retention),
703-
prometheus_retention: parseInt(this.prometheus_retention),
704+
loki_retention: parseInt(this.loki_retention, 180),
705+
prometheus_retention: parseInt(this.prometheus_retention, 15),
704706
maxmind_license: this.maxmind_license,
705-
tun_mtu: parseInt(this.tun_mtu),
706-
mssfix: parseInt(this.mssfix),
707+
tun_mtu: parseInt(this.tun_mtu, 1500),
708+
mssfix: parseInt(this.mssfix, 1455),
707709
allowed_ips: this.allowed_ips
708710
.split("\n")
709711
.map((ip) => ip.trim())

0 commit comments

Comments
 (0)