Project

General

Profile

« Previous | Next » 

Revision cddc70a2

Added by Stephen Beaver almost 10 years ago

Fixed #5102
javascript revised to accommodate VPN masks

View differences:

src/usr/local/www/classes/Form/IpAddress.class.php
38 38
		$this->_attributes['pattern'] = '[a-f0-9:.]*';
39 39
	}
40 40

  
41
	public function addMask($name, $value, $max = 128)
41
	// $min is provided to allow for VPN masks in which '0' is valid
42
	public function addMask($name, $value, $max = 128, $min = 1)
42 43
	{
43 44
		$this->_mask = new Form_Select(
44 45
			$name,
45 46
			null,
46 47
			$value,
47
			array_combine(range($max, 1), range($max, 1))
48
			array_combine(range($max, $min), range($max, $min))
48 49
		);
49 50

  
50 51
		return $this;
51 52
	}
52 53

  
53
	// Masks on vpn_ipsec* pages allow a mask of '0'
54
	public function addVPNMask($name, $value, $max = 128)
55
	{
56
		$this->_mask = new Form_Select(
57
			$name,
58
			null,
59
			$value,
60
			array_combine(range($max, 0), range($max, 0))
61
		);
62

  
63
		return $this;
64
	}
65
	
66 54
	public function setIsRepeated()
67 55
	{
68 56
		if (isset($this->_mask))
src/usr/local/www/jquery/pfSense.js
95 95
		});
96 96
	})();
97 97

  
98
	// Automatically change IpAddress mask selectors to 128/32 options for IPv6/IPvd addresses
98 99
	$('span.pfIpMask + select').each(function (idx, select){
99 100
		var input = $(select).prevAll('input[type=text]');
100

  
101
			
101 102
		input.on('change', function(e){
102 103
			var isV6 = (input.val().indexOf(':') != -1), min = 0, max = 128;
103 104
			if (!isV6)
......
106 107
			if (input.val() == "")
107 108
				return;
108 109

  
109
			while (select.options.length > max)
110
			// Eat all of the options with a value greater than max. We don't want them to be available 
111
			while (select.options[0].value > max)
110 112
				select.remove(0);
111

  
112
			if (select.options.length < max)
113
			{
113
			
114
			if (select.options.length < max) {
114 115
				for (var i=select.options.length; i<=max; i++)
115 116
					select.options.add(new Option(i, i), 0);
116 117
			}
src/usr/local/www/vpn_ipsec_phase2.php
532 532
	'localid_address',
533 533
	null,
534 534
	$pconfig['localid_address']
535
))->setHelp('Address')->addVPNMask(localid_netbits, $pconfig['localid_netbits']);
535
))->setHelp('Address')->addMask(localid_netbits, $pconfig['localid_netbits'], 128, 0);
536 536

  
537 537
$section->add($group);
538 538

  
......
557 557
	'natlocalid_address',
558 558
	null,
559 559
	$pconfig['localid_address']
560
))->setHelp('Address')->addVPNMask(natlocalid_netbits, $pconfig['natlocalid_netbits']);
560
))->setHelp('Address')->addMask(natlocalid_netbits, $pconfig['natlocalid_netbits'], 128, 0);
561 561

  
562 562
$group->setHelp('If NAT/BINAT is required on this network specify the address to be translated');
563 563
$section->add($group);
......
576 576
	'remoteid_address',
577 577
	null,
578 578
	$pconfig['remoteid_address']
579
))->setHelp('Address')->addVPNMask(remoteid_netbits, $pconfig['remoteid_netbits']);
579
))->setHelp('Address')->addMask(remoteid_netbits, $pconfig['remoteid_netbits'], 128, 0);
580 580

  
581 581
$section->add($group);
582 582

  

Also available in: Unified diff