X-Git-Url: http://www.privoxy.org/gitweb/?p=privoxy.git;a=blobdiff_plain;f=tools%2Fuagen.pl;h=94002fa5333045202b31547d9301f5f984aa0aa3;hp=f26af8813fc99987e69d319ab880e408e7394389;hb=bdf44a6580eb92ca3dbd1c89b651372885471989;hpb=f3e87d9a4e656286a271d5ad822d65301e2ef0f4 diff --git a/tools/uagen.pl b/tools/uagen.pl index f26af881..94002fa5 100755 --- a/tools/uagen.pl +++ b/tools/uagen.pl @@ -3,8 +3,6 @@ ############################################################################################## # uagen (http://www.fabiankeil.de/sourcecode/uagen/) # -# $Id: uagen.pl,v 1.12 2011/06/29 18:35:23 fabiankeil Exp $ -# # Generates a pseudo-random Firefox user agent and writes it into a Privoxy action file # and optionally into a Mozilla prefs file. For documentation see 'perldoc uagen(.pl)'. # @@ -18,7 +16,7 @@ # Mozilla/5.0 (X11; U; OpenBSD sparc64; pl-PL; rv:1.8.0.2) Gecko/20060429 Firefox/1.5.0.2 # Mozilla/5.0 (X11; U; Linux i686; en-CA; rv:1.8.0.2) Gecko/20060413 Firefox/1.5.0.2 # -# Copyright (c) 2006-2009 Fabian Keil +# Copyright (c) 2006-2011 Fabian Keil # # Permission to use, copy, modify, and distribute this software for any # purpose with or without fee is hereby granted, provided that the above @@ -40,7 +38,7 @@ use Getopt::Long; use constant { - UAGEN_VERSION => 'uagen 1.0.10', + UAGEN_VERSION => 'uagen 1.2.1', UAGEN_LOGFILE => '/var/log/uagen.log', ACTION_FILE => '/etc/privoxy/user-agent.action', @@ -60,8 +58,8 @@ use constant { # are too lazy to check, but want to change them anyway, take the values you # see in the "Help/About Mozilla Firefox" menu. - BROWSER_VERSION => "5.0", - BROWSER_REVISION => '5.0', + BROWSER_VERSION => "17.0", + BROWSER_REVISION => '17.0', BROWSER_RELEASE_DATE => '20100101', }; @@ -72,51 +70,48 @@ use constant LANGUAGES => qw( ####################################################################################### sub generate_creation_time($) { - my $release_date = $_ = shift; + my $release_date = shift; my ($rel_year, $rel_mon, $rel_day); my ($c_day, $c_mon, $c_year); my $now = time; - my ( $sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst ) = - localtime $now; + my (undef, undef, undef, $mday, $mon, $year, undef, undef, undef) = localtime($now); $mon += 1; $year += 1900; - unless ( m/\d{6}/ ) { + unless ($release_date =~ m/\d{6}/) { log_error("Invalid release date format: $release_date. Using " . BROWSER_RELEASE_DATE . " instead."); $release_date = BROWSER_RELEASE_DATE; } - $rel_year = substr $release_date, 0, 4; - $rel_mon = substr $release_date, 4, 2; - $rel_day = substr $release_date, 6, 2; + $rel_year = substr($release_date, 0, 4); + $rel_mon = substr($release_date, 4, 2); + $rel_day = substr($release_date, 6, 2); #1, 2, 3, Check. - die "release year in the future" if ( $year < $rel_year ); + die "release year in the future" if ($year < $rel_year); die "release month in the future" - if ( ( $year == $rel_year ) and ( $mon < $rel_mon ) ); + if (($year == $rel_year) and ($mon < $rel_mon)); die "release day in the future" - if ( ( $year == $rel_year ) - and ( $mon == $rel_mon ) - and ( $mday < $rel_day ) ); + if (($year == $rel_year) and ($mon == $rel_mon) and ($mday < $rel_day)); my @c_time = (0, 0, 0, $rel_day, $rel_mon - 1, $rel_year - 1900, 0, 0, 0); - my $c_seconds = &timelocal( @c_time ); + my $c_seconds = timelocal(@c_time); $c_seconds = $now - (int rand ($now - $c_seconds)); - @c_time = localtime $c_seconds; - ($sec, $min, $hour, $c_day, $c_mon, $c_year, $wday, $yday, $isdst) = @c_time; + @c_time = localtime($c_seconds); + (undef, undef, undef, $c_day, $c_mon, $c_year, undef, undef, undef) = @c_time; $c_mon += 1; $c_year += 1900; #3, 2, 1, Test. - die "Compilation year in the future" if ( $year < $c_year ); + die "Compilation year in the future" if ($year < $c_year); die "Compilation month in the future" - if ( ( $year == $c_year ) and ( $mon < $c_mon ) ); + if (($year == $c_year) and ($mon < $c_mon)); die "Compilation day in the future" - if ( ( $year == $c_year ) and ( $mon == $c_mon ) and ( $mday < $c_day ) ); + if (($year == $c_year) and ($mon == $c_mon) and ($mday < $c_day)); - return sprintf "%.2i%.2i%.2i", $c_year, $c_mon, $c_day; + return sprintf("%.2i%.2i%.2i", $c_year, $c_mon, $c_day); } sub generate_language_settings() { @@ -136,7 +131,7 @@ sub generate_platform_and_os() { FreeBSD => { karma => 1, platform => 'X11', - architectures => [ 'i386', 'amd64', 'sparc64', 'alpha' ], + architectures => [ 'i386', 'amd64', 'sparc64' ], order_is_inversed => 0, }, OpenBSD => { @@ -207,7 +202,6 @@ sub generate_firefox_user_agent() { our $randomize_release_date; my $mozillaversion = '5.0'; - my $security = "U"; my $creation_time = $randomize_release_date ? generate_creation_time($browser_release_date) : $browser_release_date; @@ -215,8 +209,8 @@ sub generate_firefox_user_agent() { my ( $platform, $os_or_cpu ) = generate_platform_and_os; my $firefox_user_agent = - sprintf "Mozilla/%s (%s; %s; %s; %s; rv:%s) Gecko/%s Firefox/%s", - $mozillaversion, $platform, $security, $os_or_cpu, $locale, $browser_revision, + sprintf "Mozilla/%s (%s; %s; rv:%s) Gecko/%s Firefox/%s", + $mozillaversion, $platform, $os_or_cpu, $browser_revision, $creation_time, $browser_version; return $accept_language, $firefox_user_agent; @@ -238,7 +232,7 @@ sub log_to_file($) { return if $no_logging; - open(my $log_fd, ">>" . $logfile) || die "Writing " . $logfile . " failed"; + open(my $log_fd, ">>", $logfile) || die "Writing " . $logfile . " failed"; printf $log_fd UAGEN_VERSION . " ($logtime) $message\n"; close($log_fd); } @@ -280,7 +274,7 @@ sub write_action_file() { $action_file_content .= sprintf " +hide-user-agent{%s} \\\n}\n/\n", $user_agent; } - open(my $actionfile_fd, ">" . $action_file) + open(my $actionfile_fd, ">", $action_file) or log_error "Writing action file $action_file failed!"; print $actionfile_fd $action_file_content; close($actionfile_fd); @@ -298,7 +292,7 @@ sub write_prefs_file() { my $prefs_file_content = ''; my $prefsfile_fd; - if (open($prefsfile_fd, $mozilla_prefs_file)) { + if (open($prefsfile_fd, "<", $mozilla_prefs_file)) { while (<$prefsfile_fd>) { s@user_pref\(\"general.useragent.override\",.*\);\n?@@; @@ -315,7 +309,7 @@ sub write_prefs_file() { sprintf("user_pref(\"intl.accept_languages\", \"%s\");\n", $accept_language) unless $clean_prefs; - open($prefsfile_fd, ">" . $mozilla_prefs_file) + open($prefsfile_fd, ">", $mozilla_prefs_file) or log_error "Writing prefs file $mozilla_prefs_file failed!"; print $prefsfile_fd $prefs_file_content; close($prefsfile_fd); @@ -323,7 +317,7 @@ sub write_prefs_file() { } sub VersionMessage() { - printf UAGEN_VERSION . "\n" . 'Copyright (C) 2006-2009 Fabian Keil ' . + printf UAGEN_VERSION . "\n" . 'Copyright (C) 2006-2011 Fabian Keil ' . "\nhttp://www.fabiankeil.de/sourcecode/uagen/\n"; } @@ -443,7 +437,6 @@ sub main() { } main(); -exit(0); =head1 NAME