mirror of
https://github.com/vincentmli/bpfire.git
synced 2026-04-25 02:12:58 +02:00
ids-functions.pl: Add get_subscription_code() function.
This function can be used to obtain the subscription code of a given configured provider. Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
This commit is contained in:
@@ -1607,6 +1607,34 @@ END
|
||||
close(FILE);
|
||||
}
|
||||
|
||||
#
|
||||
## Function to get the subscription code of a configured provider.
|
||||
#
|
||||
sub get_subscription_code($) {
|
||||
my ($provider) = @_;
|
||||
|
||||
my %configured_providers = ();
|
||||
|
||||
# Read-in providers settings file.
|
||||
&General::readhasharray($providers_settings_file, \%configured_providers);
|
||||
|
||||
# Loop through the hash of configured providers.
|
||||
foreach my $id (keys %configured_providers) {
|
||||
# Assign nice human-readable values to the data fields.
|
||||
my $provider_handle = $configured_providers{$id}[0];
|
||||
my $subscription_code = $configured_providers{$id}[1];
|
||||
|
||||
# Check if the current processed provider is the requested one.
|
||||
if ($provider_handle eq $provider) {
|
||||
# Return the obtained subscription code.
|
||||
return $subscription_code;
|
||||
}
|
||||
}
|
||||
|
||||
# No subscription code found - return nothing.
|
||||
return;
|
||||
}
|
||||
|
||||
#
|
||||
## Function to get the ruleset date for a given provider.
|
||||
##
|
||||
|
||||
Reference in New Issue
Block a user