Project

General

Profile

Download (11.7 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/*
3
 * globals.inc
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-2021 Rubicon Communications, LLC (Netgate)
9
 * All rights reserved.
10
 *
11
 * Licensed under the Apache License, Version 2.0 (the "License");
12
 * you may not use this file except in compliance with the License.
13
 * You may obtain a copy of the License at
14
 *
15
 * http://www.apache.org/licenses/LICENSE-2.0
16
 *
17
 * Unless required by applicable law or agreed to in writing, software
18
 * distributed under the License is distributed on an "AS IS" BASIS,
19
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20
 * See the License for the specific language governing permissions and
21
 * limitations under the License.
22
 */
23

    
24
// Global defines
25

    
26
// Automatic panel collapse
27
define('COLLAPSIBLE', 0x08);
28
define('SEC_CLOSED', 0x04);
29
define('SEC_OPEN', 0x00);
30

    
31
// IP address types
32
define("IPV4", 4);
33
define("IPV6", 6);
34
define("IPV4V6", 2);
35
define("ALIAS", 1);
36

    
37
// Interface Name Size
38
define("IF_NAMESIZE", 15);	/* 16 minus the terminating NULL */
39

    
40
// AddPassword method defines
41
define('DMYPWD', "********");
42

    
43
global $g;
44
$g = array(
45
	"acbbackuppath" => "/cf/conf/acb/",
46
	"event_address" => "unix:///var/run/check_reload_status",
47
	"factory_shipped_username" => "admin",
48
	"factory_shipped_password" => "pfsense",
49
	"upload_path" => "/root",
50
	"dhcpd_chroot_path" => "/var/dhcpd",
51
	"unbound_chroot_path" => "/var/unbound",
52
	"var_path" => "/var",
53
	"varrun_path" => "/var/run",
54
	"varetc_path" => "/var/etc",
55
	"vardb_path" => "/var/db",
56
	"varlog_path" => "/var/log",
57
	"etc_path" => "/etc",
58
	"tmp_path" => "/tmp",
59
	"tmp_path_user_code" => "/tmp/user_code",
60
	"conf_path" => "/conf",
61
	"conf_default_path" => "/conf.default",
62
	"cf_path" => "/cf",
63
	"cf_conf_path" => "/cf/conf",
64
	"www_path" => "/usr/local/www",
65
	"xml_rootobj" => "pfsense",
66
	"admin_group" => "admins",
67
	"product_name" => "pfSense",
68
	"product_label" => "pfSense",
69
	"product_label_html" => "Netgate pfSense<sup>&#174;</sup>",
70
	"product_version" => trim(file_get_contents("/etc/version"), " \n"),
71
	"product_copyright_years" => "2004 - ".date("Y"),
72
	"disablehelpmenu" => false,
73
	"disablehelpicon" => false,
74
	"disablecrashreporter" => false,
75
	"debug" => false,
76
	"latest_config" => "22.2",
77
	"minimum_ram_warning" => "101",
78
	"minimum_ram_warning_text" => "128 MB",
79
	"wan_interface_name" => "wan",
80
	"captiveportal_path" => "/usr/local/captiveportal",
81
	"captiveportal_element_path" => "/var/db/cpelements",
82
	"captiveportal_element_sizelimit" => 1048576,
83
	"captiveportal_rules_interval" => 50,
84
	"services_dhcp_server_enable" => true,
85
	"wireless_regex" => "/^(ath|athp|bwi|bwn|ipw|iwi|iwm|iwn|malo|mwl|ral|rsu|rtwn|rum|run|uath|upgt|ural|urtw|urtwn|wi|wpi|wtap|zyd)[0-9]+/",
86
	"help_base_url" => "/help.php",
87
	"pkg_prefix" => "pfSense-pkg-",
88
	"default_timezone" => "Etc/UTC",
89
	"language" => "en_US",
90
	"default_config_backup_count" => 30,
91
	"default_cert_expiredays" => 27,
92
	"default_log_entries" => 500,
93
	"default_log_size" => 512000,
94
	"minimumtableentries_bogonsv6" => 400000,
95
	"alternativemetaports" => array("vmware", "php72", "php73", "php74"),
96
	"backuppath" => array(
97
		'captiveportal' => "/var/db/captiveportal*.db",
98
		'dhcpd' => "/var/dhcpd/var/db/dhcpd.leases",
99
		'dhcpdv6' => "/var/dhcpd/var/db/dhcpd6.leases",
100
		'voucher' => "/var/db/voucher_*.db"
101
	)
102
);
103

    
104
/* IP TOS flags */
105
$iptos = array("lowdelay", "throughput", "reliability");
106

    
107
/* TCP flags */
108
$tcpflags = array("syn", "ack", "fin", "rst", "psh", "urg", "ece", "cwr");
109

    
110
if (file_exists("/etc/version.patch")) {
111
	$g["product_version_patch"] = trim(file_get_contents("/etc/version.patch"), " \n");
112
} else {
113
	$g["product_version_patch"] = "0";
114
}
115

    
116
$g['product_version_string'] = $g['product_version'];
117
if (is_numeric($g["product_version_patch"]) && $g["product_version_patch"] != "0") {
118
	$g['product_version_string'] .= "-p{$g['product_version_patch']}";
119
}
120

    
121
if (file_exists("{$g['etc_path']}/default-config-flavor")) {
122
	$flavor_array = file("{$g['etc_path']}/default-config-flavor");
123
	$g['default-config-flavor'] = chop($flavor_array[0]);
124
} else {
125
	$g['default-config-flavor'] = '';
126
}
127

    
128
$g['openvpn_base'] = "{$g['varetc_path']}/openvpn";
129

    
130
/* Default sysctls */
131
$sysctls = array("net.inet.ip.portrange.first" => "1024",
132
	"net.inet.tcp.blackhole" => "2",
133
	"net.inet.udp.blackhole" => "1",
134
	"net.inet.ip.random_id" => "1",
135
	"net.inet.tcp.drop_synfin" => "1",
136
	"net.inet.ip.redirect" => "1",
137
	"net.inet6.ip6.redirect" => "1",
138
	"net.inet6.ip6.use_tempaddr" => "0",
139
	"net.inet6.ip6.prefer_tempaddr" => "0",
140
	"net.inet.tcp.syncookies" => "1",
141
	"net.inet.tcp.recvspace" => "65228",
142
	"net.inet.tcp.sendspace" => "65228",
143
	"net.inet.tcp.delayed_ack" => "0",
144
	"net.inet.udp.maxdgram" => "57344",
145
	"net.link.bridge.pfil_onlyip" => "0",
146
	"net.link.bridge.pfil_member" => "1",
147
	"net.link.bridge.pfil_bridge" => "0",
148
	"net.link.tap.user_open" => "1",
149
	"net.link.vlan.mtag_pcp" => "1",
150
	"kern.randompid" => "347",
151
	"net.inet.ip.intr_queue_maxlen" => "1000",
152
	"hw.syscons.kbd_reboot" => "0",
153
	"net.inet.tcp.log_debug" => "0",
154
	"net.inet.tcp.tso" => "1",
155
	"net.inet.icmp.icmplim" => "0",
156
	"vfs.read_max" => "32",
157
	"kern.ipc.maxsockbuf" => "4262144",
158
	"net.inet.ip.process_options" => 0,
159
	"kern.random.harvest.mask" => "351",
160
	"net.route.netisr_maxqlen" => 1024,
161
	"net.inet.udp.checksum" => 1,
162
	"net.inet.icmp.reply_from_interface" => 1,
163
	"net.inet6.ip6.rfc6204w3" => 1,
164
	"net.key.preferred_oldsa" => "0",
165
	"net.inet.carp.senderr_demotion_factor" => 0, /* Do not demote CARP for interface send errors */
166
	"net.pfsync.carp_demotion_factor" => 0, /* Do not demote CARP for pfsync errors */
167
	"net.raw.recvspace" => 65536,
168
	"net.raw.sendspace" => 65536,
169
	"net.inet.raw.recvspace" => 131072,
170
	"net.inet.raw.maxdgram" => 131072,
171
	"kern.corefile" => "/root/%N.core" /* Write all core files to /root/ so they do not consume space on other slices */
172
);
173

    
174
$machine_type = php_uname('m');
175
if (($machine_type == 'arm') || ($machine_type == 'arm64')) {
176
	$sysctls['kern.shutdown.secure_halt'] = 1;
177
}
178

    
179
/* Include override values for the above if needed. If the file doesn't exist, don't try to load it. */
180
if (file_exists("/etc/inc/globals_override.inc")) {
181
	@include_once("globals_override.inc");
182
}
183

    
184
/* Read all XML files in following dir and load menu entries */
185
$g["ext_menu_path"] = "/usr/local/share/{$g['product_name']}/menu";
186

    
187
/* Cache file used to store pfSense version */
188
$g["version_cache_file"] = "{$g['varrun_path']}/{$g['product_name']}_version";
189
$g['version_cache_refresh'] = 2 * 60 * 60; /* 2h */
190

    
191
function platform_booting($on_console = false) {
192
	global $g;
193

    
194
	if ($g['booting'] || file_exists("{$g['varrun_path']}/booting")) {
195
		if ($on_console == false || php_sapi_name() != 'fpm-fcgi') {
196
			return true;
197
		}
198
	}
199

    
200
	return false;
201
}
202

    
203
if (file_exists("{$g['cf_conf_path']}/enableserial_force")) {
204
	$g['enableserial_force'] = true;
205
}
206

    
207
$config_parsed = false;
208

    
209
/* Factory default check IP service. */
210
$factory_default_checkipservice = array(
211
	"enable" => true,
212
	"name" => 'Default',
213
	"url" => 'http://checkip.dyndns.org',
214
//	"username" => '',
215
//	"password" => '',
216
//	"verifysslpeer" => true,
217
	"descr" => 'Default Check IP Service'
218
);
219

    
220
$dyndns_split_domain_types = array("namecheap", "cloudflare", "cloudflare-v6", "gratisdns", "cloudns", "godaddy", "godaddy-v6", "linode", "linode-v6");
221

    
222
/* pf tokens from FreeBSD source sbin/pfctl/parse.y (plus our custom entries at the end)*/
223
global $pf_reserved_keywords;
224
$pf_reserved_keywords = array(
225
	"pass", "block", "scrub", "return", "in", "os", "out", "log", "quick", "on", "from", "to", "flags", "returnrst",
226
	"returnicmp", "returnicmp6", "proto", "inet", "inet6", "all", "any", "icmptype", "icmp6type", "code", "keep",
227
	"modulate", "state", "port", "rdr", "nat", "binat", "arrow", "nodf", "minttl", "error", "allowopts", "fastroute",
228
	"filename", "routeto", "dupto", "replyto", "no", "label", "noroute", "urpffailed", "fragment", "user", "group",
229
	"maxmss", "maximum", "ttl", "tos", "drop", "table", "reassemble", "fragdrop", "fragcrop", "anchor", "natanchor",
230
	"rdranchor", "binatanchor", "set", "optimization", "timeout", "limit", "loginterface", "blockpolicy", "randomid",
231
	"requireorder", "synproxy", "fingerprints", "nosync", "debug", "skip", "hostid", "antispoof", "for", "include",
232
	"bitmask", "random", "sourcehash", "roundrobin", "staticport", "probability", "altq", "cbq", "codel", "priq",
233
	"hfsc", "fairq", "bandwidth", "tbrsize", "linkshare", "realtime", "upperlimit", "queue", "priority", "qlimit",
234
	"hogs", "buckets", "rtable", "target", "interval", "load", "ruleset_optimization", "prio", "stickyaddress",
235
	"maxsrcstates", "maxsrcnodes", "sourcetrack", "global", "rule", "maxsrcconn", "maxsrcconnrate", "overload",
236
	"flush", "sloppy", "tagged", "tag", "ifbound", "floating", "statepolicy", "statedefaults", "route", "settos",
237
	"divertto", "divertreply", "max", "min", "pptp", "pppoe", "L2TP", "OpenVPN", "IPsec");
238

    
239
/* Reserved table names to avoid collision */
240
global $reserved_table_names;
241
$reserved_table_names = array(
242
	"bogons",
243
	"bogonsv6",
244
	"negate_networks",
245
	"snort2c",
246
	"sshguard",
247
	"tonatsubnets",
248
	"virusprot",
249
	"vpn_networks",
250
);
251

    
252
/* VLAN Prio values. */
253
$vlanprio_values = array(
254
	"bk" => 0,
255
	"be" => 1,
256
	"ee" => 2,
257
	"ca" => 3,
258
	"vi" => 4,
259
	"vo" => 5,
260
	"ic" => 6,
261
	"nc" => 7
262
);
263

    
264
$vlanprio = array(
265
	"bk" => "Background (BK, 0)",
266
	"be" => "Best Effort (BE, 1)",
267
	"ee" => "Excellent Effort (EE, 2)",
268
	"ca" => "Critical Applications (CA, 3)",
269
	"vi" => "Video (VI, 4)",
270
	"vo" => "Voice (VO, 5)",
271
	"ic" => "Internetwork Control (IC, 6)",
272
	"nc" => "Network Control (NC, 7)"
273
);
274

    
275
global $system_log_files;
276
$system_log_files = array(
277
	"system", "filter", "dhcpd", "vpn", "poes", "l2tps", "openvpn",
278
	"portalauth", "ipsec", "ppp", "wireless", "nginx", "ntpd", "gateways",
279
	"resolver", "routing", "auth");
280

    
281
global $system_log_non_syslog_files;
282
$system_log_non_syslog_files = array('dmesg.boot', 'utx.log', 'userlog');
283

    
284
global $system_log_compression_types;
285
$system_log_compression_types = array(
286
	'bzip2' => array(
287
			'flag' => 'J',
288
			'cat' => '/usr/bin/bzcat -qf',
289
			'ext' => 'bz2',
290
		),
291
	'gzip' => array(
292
			'flag' => 'Z',
293
			'cat' => '/usr/bin/zcat -qf',
294
			'ext' => 'gz',
295
		),
296
	'xz' => array(
297
			'flag' => 'X',
298
			'cat' => '/usr/bin/xzcat -qf',
299
			'ext' => 'xz',
300
		),
301
	'zstd' => array(
302
			'flag' => 'Y',
303
			'cat' => '/usr/bin/zstdcat -qqf',
304
			'ext' => 'zst',
305
		),
306
	'none' => array(
307
			'flag' => '',
308
			'cat' => '/bin/cat',
309
			'ext' => '',
310
		),
311
);
312

    
313
global $ddnsdomainkeyalgorithms;
314
$ddnsdomainkeyalgorithms = array(
315
		'hmac-md5' => 'HMAC-MD5 (legacy default)',
316
		'hmac-sha1' => 'HMAC-SHA1',
317
		'hmac-sha224' => 'HMAC-SHA224',
318
		'hmac-sha256' => 'HMAC-SHA256 (current bind9 default)',
319
		'hmac-sha384' => 'HMAC-SHA384',
320
		'hmac-sha512' => 'HMAC-SHA512 (most secure)');
321

    
322
global $ipsec_filtermodes;
323
$ipsec_filtermodes = array(
324
	'enc' => 'Filter IPsec Tunnel, Transport, and VTI on IPsec tab (enc0)',
325
	'if_ipsec' => 'Filter IPsec VTI and Transport on assigned interfaces, block all tunnel mode traffic'
326
);
327

    
328
global $ipsec_filter_sysctl;
329
$ipsec_filter_sysctl = array(
330
	'enc' => array(
331
		"net.inet.ipsec.filtertunnel"   => "0x0000",
332
		"net.inet6.ipsec6.filtertunnel" => "0x0000",
333
		"net.enc.out.ipsec_bpf_mask"    => "0x0001",
334
		"net.enc.out.ipsec_filter_mask" => "0x0001",
335
		"net.enc.in.ipsec_bpf_mask"     => "0x0002",
336
		"net.enc.in.ipsec_filter_mask"  => "0x0002"
337
	),
338
	'if_ipsec' => array(
339
		"net.inet.ipsec.filtertunnel"   => "0x0001",
340
		"net.inet6.ipsec6.filtertunnel" => "0x0001",
341
		"net.enc.out.ipsec_bpf_mask"    => "0x0000",
342
		"net.enc.out.ipsec_filter_mask" => "0x0000",
343
		"net.enc.in.ipsec_bpf_mask"     => "0x0000",
344
		"net.enc.in.ipsec_filter_mask"  => "0x0000"
345
	),
346
);
347

    
348
global $vpn_and_ppp_ifs;
349
$vpn_and_ppp_ifs = array("l2tp", "pppoe", "enc0", "openvpn");
350

    
351
global $ssh_keys;
352
$ssh_keys = array(
353
	array('type' => 'rsa',     'suffix' => 'rsa_'),
354
	array('type' => 'ed25519', 'suffix' => 'ed25519_')
355
);
356

    
357
global $sshConfigDir;
358
$sshConfigDir = "/etc/ssh";
359

    
360
?>
(19-19/61)