mirror of
https://github.com/lucaspalomodevelop/core.git
synced 2026-03-14 16:44:39 +00:00
Firewall: Aliases - support Maxmind's unclassified EU (region, country unknown) as country selector EU
6255148,en,EU,Europe,,,0 Although the same applies for Asia, we can't use AS as country code here, so we do have to skip this for now until we find a better alternative. 6255147,en,AS,Asia,,,0 closes https://github.com/opnsense/core/issues/6063
This commit is contained in:
parent
6a2190695d
commit
385d182798
@ -182,7 +182,12 @@ class AliasController extends ApiMutableModelControllerBase
|
||||
*/
|
||||
public function listCountriesAction()
|
||||
{
|
||||
$result = array();
|
||||
$result = [
|
||||
'EU' => [
|
||||
'name' => gettext('Unclassified'),
|
||||
'region' => 'Europe'
|
||||
]
|
||||
];
|
||||
|
||||
foreach (explode("\n", file_get_contents('/usr/local/opnsense/contrib/tzdata/iso3166.tab')) as $line) {
|
||||
$line = trim($line);
|
||||
|
||||
@ -105,6 +105,8 @@ class AliasContentField extends BaseField
|
||||
private function getCountryCodes()
|
||||
{
|
||||
if (empty(self::$internalCountryCodes)) {
|
||||
// Maxmind's country code 6255148 (EU Unclassified)
|
||||
self::$internalCountryCodes[] = 'EU';
|
||||
foreach (explode("\n", file_get_contents('/usr/local/opnsense/contrib/tzdata/iso3166.tab')) as $line) {
|
||||
$line = trim($line);
|
||||
if (strlen($line) > 3 && substr($line, 0, 1) != '#') {
|
||||
|
||||
@ -90,8 +90,11 @@ def download_geolite():
|
||||
locations = zf.open(file_handles[result['locations_filename']]).read()
|
||||
for line in locations.decode().split('\n'):
|
||||
parts = line.split(',')
|
||||
if len(parts) > 4 and len(parts[4]) >= 1 and len(parts[4]) <= 3:
|
||||
country_codes[parts[0]] = parts[4]
|
||||
if len(parts) > 4 and parts[0].isdigit():
|
||||
if len(parts[4]) >= 1:
|
||||
country_codes[parts[0]] = parts[4]
|
||||
elif parts[2] == 'EU':
|
||||
country_codes[parts[0]] = parts[2]
|
||||
# process all details into files per country / protocol
|
||||
for proto in ['IPv4', 'IPv6']:
|
||||
if result['address_sources'][proto] is not None:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user