Deleting an entry in an alias removes the top-most entry instead.



  • Deleting an entry in an alias removes the top-most entry instead.

    I'm on version 2.3.r.20160409.1610_1.


  • Netgate

    Working for me. What kind of alias? More details please.



  • Any type of alias under Firewall / Aliases.

    I'm using the default theme and have tried it on latest Chrome and Firefox.


  • Netgate

    I can't duplicate.



  • This is just a guess, but I think it's happening due to the button IDs.

    In pfSenseHelpers.js, there's the following function:

    function delete_row(rowDelBtn) {
    	var rowLabel;
    
    	// If we are deleting row zero, we need to save/restore the label
    	if (rowDelBtn == "deleterow0") {
    		rowLabel = $('#' + rowDelBtn).parent('div').parent('div').find('label').text();
    	}
    
    	$('#' + rowDelBtn).parent('div').parent('div').remove();
    	renumber();
    	checkLastRow();
    
    	if (rowDelBtn == "deleterow0") {
    		$('#' + rowDelBtn).parent('div').parent('div').find('label').text(rowLabel);
    	}
    }
    

    Specifically, when calling "$('#' + rowDelBtn).parent('div').parent('div').remove();", and because the button IDs are all "deleterow0", jQuery returns the first row that it finds (top-most one), and it gets deleted.



  • Where you seeing IDs all "deleterow0".  Mine are all a unique integer.  ex: id=12



  • I was trying to find the code that increments the button IDs, but I couldn't find it. They are all "deleterow0":

    
    	<label class="col-sm-2 control-label"></label>
    
    			/
    			<select disabled="" class="form-control" name="address_subnet1" id="address_subnet1"><option value="128">128</option><option value="127">127</option><option value="126">126</option><option value="125">125</option><option value="124">124</option><option value="123">123</option><option value="122">122</option><option value="121">121</option><option value="120">120</option><option value="119">119</option><option value="118">118</option><option value="117">117</option><option value="116">116</option><option value="115">115</option><option value="114">114</option><option value="113">113</option><option value="112">112</option><option value="111">111</option><option value="110">110</option><option value="109">109</option><option value="108">108</option><option value="107">107</option><option value="106">106</option><option value="105">105</option><option value="104">104</option><option value="103">103</option><option value="102">102</option><option value="101">101</option><option value="100">100</option><option value="99">99</option><option value="98">98</option><option value="97">97</option><option value="96">96</option><option value="95">95</option><option value="94">94</option><option value="93">93</option><option value="92">92</option><option value="91">91</option><option value="90">90</option><option value="89">89</option><option value="88">88</option><option value="87">87</option><option value="86">86</option><option value="85">85</option><option value="84">84</option><option value="83">83</option><option value="82">82</option><option value="81">81</option><option value="80">80</option><option value="79">79</option><option value="78">78</option><option value="77">77</option><option value="76">76</option><option value="75">75</option><option value="74">74</option><option value="73">73</option><option value="72">72</option><option value="71">71</option><option value="70">70</option><option value="69">69</option><option value="68">68</option><option value="67">67</option><option value="66">66</option><option value="65">65</option><option value="64">64</option><option value="63">63</option><option value="62">62</option><option value="61">61</option><option value="60">60</option><option value="59">59</option><option value="58">58</option><option value="57">57</option><option value="56">56</option><option value="55">55</option><option value="54">54</option><option value="53">53</option><option value="52">52</option><option value="51">51</option><option value="50">50</option><option value="49">49</option><option value="48">48</option><option value="47">47</option><option value="46">46</option><option value="45">45</option><option value="44">44</option><option value="43">43</option><option value="42">42</option><option value="41">41</option><option value="40">40</option><option value="39">39</option><option value="38">38</option><option value="37">37</option><option value="36">36</option><option value="35">35</option><option value="34">34</option><option value="33">33</option><option value="32">32</option><option value="31">31</option><option value="30">30</option><option value="29">29</option><option value="28">28</option><option value="27">27</option><option value="26">26</option><option value="25">25</option><option value="24">24</option><option value="23">23</option><option value="22">22</option><option value="21">21</option><option value="20">20</option><option value="19">19</option><option value="18">18</option><option value="17">17</option><option value="16">16</option><option value="15">15</option><option value="14">14</option><option value="13">13</option><option value="12">12</option><option value="11">11</option><option value="10">10</option><option value="9">9</option><option value="8">8</option><option value="7">7</option><option value="6">6</option><option value="5">5</option><option value="4">4</option><option value="3">3</option><option value="2">2</option><option value="1">1</option></select>
    
    


  • If you edit an existing alias, then the PHP that sets everything up builds rows of entries in the alias with Delete button ids deleterow0, deleterow1, deleterow2… - that part is all good.

    Then if you add rows, they become a copy of the last row that was in the initial list - so if starting a new alias (or an existing alias with a single entry) you get deleterow0 over and over. When you press any of the delete buttons then the top row goes.

    If you start editing an alias that has, for example, 3 entries, then the Delete button of the last entry is deleterow2. Then add a few more rows, they are all deleterow2. Then decide you don't want one of the new entries (rows), press its Delete button - actually the third row (deleterow2) is deleted. That is really unexpected, you have now lost one of the original entries. If you don't notice then you will really be in a mess.

    Redmine issue raised: https://redmine.pfsense.org/issues/6101



  • Thanks Phil, good catch.

    For now, just save the alias, then edit it, and you can delete correctly.



  • Ah your in aliases  edit.  Missed that.  :-[
    (gives me an excuse to use the embarrassed emoticon)



  • Proposed fix in PR https://github.com/pfsense/pfsense/pull/2854 - needs good review and test to make sure there are no unwanted side-effects elsewhere in the system.


  • Developer Netgate

    Reviewed, tested and pushed. Thank you Phil.



  • It show me "Alias created" on DNS lookup function but i don't see any alias in FIrewall->ALias . What should i do?

    66.155.40.249
    66.155.40.250
    ns1.mobiusltd.com.
    ns2.mobiusltd.com.

    Alias created with name wordpress_org



  • @sinhkh87:

    It show me "Alias created" on DNS lookup function but i don't see any alias in FIrewall->ALias . What should i do?

    66.155.40.249
    66.155.40.250
    ns1.mobiusltd.com.
    ns2.mobiusltd.com.

    Alias created with name wordpress_org

    It worked for me looking up the exact same name wordpress.org and pressing "Add alias".
    There was some work done on that a week ago - the code should be in the latest 2.3 builds, so make sure you are up-to-date.
    https://github.com/pfsense/pfsense/commits/master/src/usr/local/www/diag_dns.php



  • Not that it's likely to be an issue, but it looks like phil.davis and sinhkh87 were using two different alias names -

    sinhkh87:

    Alias created with name wordpress_org

    phil.davis:

    It worked for me looking up the exact same name wordpress.org and pressing "Add alias".

    Still much more likely to be "updated-before-current-changes" problem, but just in case….....