Project

General

Profile

Download (5.53 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/*
3
 * services_igmpproxy.php
4
 *
5
 * part of pfSense (https://www.pfsense.org)
6
 * Copyright (c) 2004-2013 BSD Perimeter
7
 * Copyright (c) 2013-2016 Electric Sheep Fencing
8
 * Copyright (c) 2014-2023 Rubicon Communications, LLC (Netgate)
9
 * All rights reserved.
10
 *
11
 * originally based on m0n0wall (http://m0n0.ch/wall)
12
 * Copyright (c) 2003-2004 Manuel Kasper <mk@neon1.net>.
13
 * All rights reserved.
14
 *
15
 * Licensed under the Apache License, Version 2.0 (the "License");
16
 * you may not use this file except in compliance with the License.
17
 * You may obtain a copy of the License at
18
 *
19
 * http://www.apache.org/licenses/LICENSE-2.0
20
 *
21
 * Unless required by applicable law or agreed to in writing, software
22
 * distributed under the License is distributed on an "AS IS" BASIS,
23
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
24
 * See the License for the specific language governing permissions and
25
 * limitations under the License.
26
 */
27

    
28
##|+PRIV
29
##|*IDENT=page-services-igmpproxy
30
##|*NAME=Services: IGMP Proxy
31
##|*DESCR=Allow access to the 'Services: IGMP Proxy' page.
32
##|*MATCH=services_igmpproxy.php*
33
##|-PRIV
34

    
35
require_once("guiconfig.inc");
36

    
37
//igmpproxy_sort();
38

    
39
init_config_arr(array('igmpproxy', 'igmpentry'));
40
$a_igmpproxy = &$config['igmpproxy']['igmpentry'];
41

    
42
if ($_POST['apply']) {
43
	$pconfig = $_POST;
44

    
45
	$changes_applied = true;
46
	$retval = 0;
47
	/* reload all components that use igmpproxy */
48
	$retval |= services_igmpproxy_configure();
49

    
50
	clear_subsystem_dirty('igmpproxy');
51
}
52

    
53
if (isset($config['igmpproxy']['enable'])) {
54
	$pconfig['enable'] = true;
55
}
56
$pconfig['igmpxverbose'] = isset($config['syslog']['igmpxverbose']);
57

    
58
if ($_POST['save']) {
59
	unset($input_errors);
60
	$pconfig = $_POST;
61

    
62
	if (isset($pconfig['enable'])) {
63
		if (is_array($config['igmpproxy']['igmpentry']) && 
64
		    !empty($config['igmpproxy']['igmpentry'])) {
65
			foreach ($config['igmpproxy']['igmpentry'] as $igmpcf) {
66
				if ($igmpcf['type'] == 'upstream') {
67
				       $upstream = true;	
68
				} else {
69
				       $downstream = true;	
70
				}
71
			}
72
		}
73
		if (!$upstream || !$downstream) {
74
			$input_errors[] = gettext("At least one upstream and one downstream interface must be added.");
75
		}
76
	}
77

    
78
	if (!$input_errors) {
79
		if (isset($pconfig['enable'])) {
80
			config_set_path('igmpproxy/enable', true);
81
		} else {
82
			config_del_path('igmpproxy/enable');
83
		}
84
		config_set_path('syslog/igmpxverbose', $_POST['igmpxverbose'] ? true : false);
85
		write_config("IGMP Proxy settings saved");
86
		mark_subsystem_dirty('igmpproxy');
87
		header("Location: services_igmpproxy.php");
88
		exit;
89
	}
90
}
91

    
92
if ($_POST['act'] == "del") {
93
	if ($a_igmpproxy[$_POST['id']]) {
94
		unset($a_igmpproxy[$_POST['id']]);
95
		write_config("IGMP Proxy item deleted");
96
		mark_subsystem_dirty('igmpproxy');
97
		header("Location: services_igmpproxy.php");
98
		exit;
99
	}
100
}
101

    
102
$pgtitle = array(gettext("Services"), gettext("IGMP Proxy"));
103
include("head.inc");
104

    
105
if ($input_errors) {
106
	print_input_errors($input_errors);
107
}
108

    
109
if ($changes_applied) {
110
	print_apply_result_box($retval);
111
}
112

    
113
if (is_subsystem_dirty('igmpproxy')) {
114
	print_apply_box(gettext('The IGMP entry list has been changed.') . '<br />' . gettext('The changes must be applied for them to take effect.'));
115
}
116
?>
117

    
118
<?php
119

    
120
$form = new Form();
121

    
122
$section = new Form_Section('General IGMP Options');
123

    
124
$section->addInput(new Form_Checkbox(
125
	'enable',
126
	'Enable',
127
	'Enable IGMP',
128
	$pconfig['enable']
129
));
130

    
131
$section->addInput(new Form_Checkbox(
132
	'igmpxverbose',
133
	'Verbose Logging',
134
	'Enable verbose logging (Default is terse logging)',
135
	$pconfig['igmpxverbose']
136
));
137

    
138
$form->add($section);
139

    
140
print($form);
141

    
142
?>
143
<form action="services_igmpproxy.php" method="post">
144
	<div class="panel panel-default">
145
		<div class="panel-heading"><h2 class="panel-title"><?=gettext('IGMP Proxy')?></h2></div>
146
		<div class="panel-body">
147
			<div class="table-responsive">
148
				<table class="table table-striped table-hover table-condensed table-rowdblclickedit">
149
					<thead>
150
						<tr>
151
							<th><?=gettext("Name")?></th>
152
							<th><?=gettext("Type")?></th>
153
							<th><?=gettext("Values")?></th>
154
							<th><?=gettext("Description")?></th>
155
							<th><?=gettext("Actions")?></th>
156
						</tr>
157
					</thead>
158
					<tbody>
159
<?php
160
$i = 0;
161
foreach ($a_igmpproxy as $igmpentry):
162
?>
163
						<tr>
164
							<td>
165
								<?=htmlspecialchars(convert_friendly_interface_to_friendly_descr($igmpentry['ifname']))?>
166
							</td>
167
							<td>
168
								<?=htmlspecialchars($igmpentry['type'])?>
169
							</td>
170
							<td>
171
<?php
172
	$addresses = implode(", ", array_slice(explode(" ", $igmpentry['address']), 0, 10));
173
	print(htmlspecialchars($addresses));
174

    
175
	if (!is_array($igmpentry['address']) || count($igmpentry['address']) < 10) {
176
		print(' ');
177
	} else {
178
		print('...');
179
	}
180
?>
181
							</td>
182
							<td>
183
								<?=htmlspecialchars($igmpentry['descr'])?>&nbsp;
184
							</td>
185
							<td>
186
								<a class="fa fa-pencil"	title="<?=gettext('Edit IGMP entry')?>" href="services_igmpproxy_edit.php?id=<?=$i?>"></a>
187
								<a class="fa fa-trash"	title="<?=gettext('Delete IGMP entry')?>" href="services_igmpproxy.php?act=del&amp;id=<?=$i?>" usepost></a>
188
							</td>
189
						</tr>
190
<?php
191
	$i++;
192
endforeach;
193
?>
194
					</tbody>
195
				</table>
196
			</div>
197
		</div>
198
	</div>
199
</form>
200

    
201
<nav class="action-buttons">
202
	<a href="services_igmpproxy_edit.php" class="btn btn-success btn-sm">
203
		<i class="fa fa-plus icon-embed-btn"></i>
204
		<?=gettext('Add')?>
205
	</a>
206
</nav>
207

    
208
<div class="infoblock">
209
<?php print_info_box(gettext('Please add the interface for upstream, the allowed subnets, and the downstream interfaces for the proxy to allow. ' .
210
					   'Only one "upstream" interface can be configured.'), 'info', false); ?>
211
</div>
212
<?php
213
include("foot.inc");
(129-129/228)