Project

General

Profile

Download (9.79 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-2019 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
	"event_address" => "unix:///var/run/check_reload_status",
46
	"factory_shipped_username" => "admin",
47
	"factory_shipped_password" => "pfsense",
48
	"upload_path" => "/root",
49
	"dhcpd_chroot_path" => "/var/dhcpd",
50
	"unbound_chroot_path" => "/var/unbound",
51
	"var_path" => "/var",
52
	"varrun_path" => "/var/run",
53
	"varetc_path" => "/var/etc",
54
	"vardb_path" => "/var/db",
55
	"varlog_path" => "/var/log",
56
	"etc_path" => "/etc",
57
	"tmp_path" => "/tmp",
58
	"tmp_path_user_code" => "/tmp/user_code",
59
	"conf_path" => "/conf",
60
	"conf_default_path" => "/conf.default",
61
	"cf_path" => "/cf",
62
	"cf_conf_path" => "/cf/conf",
63
	"www_path" => "/usr/local/www",
64
	"xml_rootobj" => "pfsense",
65
	"admin_group" => "admins",
66
	"product_name" => "pfSense",
67
	"product_version" => trim(file_get_contents("/etc/version"), " \n"),
68
	"product_copyright_years" => "2004 - ".date("Y"),
69
	"disablehelpmenu" => false,
70
	"disablehelpicon" => false,
71
	"disablecrashreporter" => false,
72
	"crashreporterurl" => "https://crashreporter.pfsense.org/crash_reporter.php",
73
	"debug" => false,
74
	"latest_config" => "19.7",
75
	"minimum_ram_warning" => "101",
76
	"minimum_ram_warning_text" => "128 MB",
77
	"wan_interface_name" => "wan",
78
	"captiveportal_path" => "/usr/local/captiveportal",
79
	"captiveportal_element_path" => "/var/db/cpelements",
80
	"captiveportal_element_sizelimit" => 1048576,
81
	"captiveportal_rules_interval" => 50,
82
	"services_dhcp_server_enable" => true,
83
	"wireless_regex" => "/^(ath|athp|bwi|bwn|ipw|iwi|iwm|iwn|malo|mwl|ral|rsu|rum|run|uath|upgt|ural|urtw|urtwn|wi|wpi|wtap|zyd)[0-9]+/",
84
	"help_base_url" => "/help.php",
85
	"pkg_prefix" => "pfSense-pkg-",
86
	"default_timezone" => "Etc/UTC",
87
	"language" => "en_US",
88
	"default_config_backup_count" => 30,
89
	"default_log_entries" => 500,
90
	"default_log_size" => 512000,
91
	"minimumtableentries_bogonsv6" => 400000,
92
	"alternativemetaports" => array("vmware", "php72", "php73")
93
);
94

    
95
/* IP TOS flags */
96
$iptos = array("lowdelay", "throughput", "reliability");
97

    
98
/* TCP flags */
99
$tcpflags = array("syn", "ack", "fin", "rst", "psh", "urg", "ece", "cwr");
100

    
101
if (file_exists("/etc/version.patch")) {
102
	$g["product_version_patch"] = trim(file_get_contents("/etc/version.patch"), " \n");
103
} else {
104
	$g["product_version_patch"] = "0";
105
}
106

    
107
$g['product_version_string'] = $g['product_version'];
108
if (is_numeric($g["product_version_patch"]) && $g["product_version_patch"] != "0") {
109
	$g['product_version_string'] .= "-p{$g['product_version_patch']}";
110
}
111

    
112
/* XXX: Backward compatible */
113
$g['platform'] = $g['product_name'];
114

    
115
if (file_exists("{$g['etc_path']}/default-config-flavor")) {
116
	$flavor_array = file("{$g['etc_path']}/default-config-flavor");
117
	$g['default-config-flavor'] = chop($flavor_array[0]);
118
} else {
119
	$g['default-config-flavor'] = '';
120
}
121

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

    
170
$machine_type = php_uname('m');
171
if (($machine_type == 'arm') || ($machine_type == 'arm64')) {
172
	$sysctls['kern.shutdown.secure_halt'] = 1;
173
}
174

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

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

    
183
/* Cache file used to store pfSense version */
184
$g["version_cache_file"] = "{$g['varrun_path']}/{$g['product_name']}_version";
185
$g['version_cache_refresh'] = 2 * 60 * 60; /* 2h */
186

    
187
function platform_booting($on_console = false) {
188
	global $g;
189

    
190
	if ($g['booting'] || file_exists("{$g['varrun_path']}/booting")) {
191
		if ($on_console == false || php_sapi_name() != 'fpm-fcgi') {
192
			return true;
193
		}
194
	}
195

    
196
	return false;
197
}
198

    
199
if (file_exists("{$g['cf_conf_path']}/enableserial_force")) {
200
	$g['enableserial_force'] = true;
201
}
202

    
203
$config_parsed = false;
204

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

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

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

    
235
/* VLAN Prio values. */
236
$vlanprio_values = array(
237
	"bk" => 0,
238
	"be" => 1,
239
	"ee" => 2,
240
	"ca" => 3,
241
	"vi" => 4,
242
	"vo" => 5,
243
	"ic" => 6,
244
	"nc" => 7
245
);
246

    
247
$vlanprio = array(
248
	"bk" => "Background (BK, 0)",
249
	"be" => "Best Effort (BE, 1)",
250
	"ee" => "Excellent Effort (EE, 2)",
251
	"ca" => "Critical Applications (CA, 3)",
252
	"vi" => "Video (VI, 4)",
253
	"vo" => "Voice (VO, 5)",
254
	"ic" => "Internetwork Control (IC, 6)",
255
	"nc" => "Network Control (NC, 7)"
256
);
257

    
258
global $system_log_files;
259
$system_log_files = array(
260
	"system", "filter", "dhcpd", "vpn", "poes", "l2tps", "openvpn",
261
	"portalauth", "ipsec", "ppp", "wireless", "nginx", "ntpd", "gateways",
262
	"resolver", "routing", "auth");
263

    
264
global $system_log_compression_types;
265
$system_log_compression_types = array(
266
	'bzip2' => array(
267
			'flag' => 'J',
268
			'cat' => '/usr/bin/bzcat -qf',
269
			'ext' => 'bz2',
270
		),
271
	'gzip' => array(
272
			'flag' => 'Z',
273
			'cat' => '/usr/bin/zcat -qf',
274
			'ext' => 'gz',
275
		),
276
	'xz' => array(
277
			'flag' => 'X',
278
			'cat' => '/usr/bin/xzcat -qf',
279
			'ext' => 'xz',
280
		),
281
	'zstd' => array(
282
			'flag' => 'Y',
283
			'cat' => '/usr/bin/zstdcat -qqf',
284
			'ext' => 'zst',
285
		),
286
	'none' => array(
287
			'flag' => '',
288
			'cat' => '/usr/bin/cat',
289
			'ext' => '',
290
		),
291
);
292

    
293
?>
(19-19/59)