Skip to content

Instantly share code, notes, and snippets.

@tacitochaves
Created July 3, 2014 20:49
Show Gist options
  • Save tacitochaves/3f1a77f438cf644e7a1b to your computer and use it in GitHub Desktop.
Save tacitochaves/3f1a77f438cf644e7a1b to your computer and use it in GitHub Desktop.
Comentário no squid.conf
#!/usr/bin/env perl
use strict;
use warnings;
my $oi = comment_squid_oi();
#my $emb_34 = comment_squid_emb_34();
#my $emb_147 = comment_squid_emb_147();
sub comment_squid_oi {
#Specify the file
my $file = "squid.conf";
#Open the file and read data
#Die with grace if it fails
open( FILE, "<", "$file" ) or die "Can't open $file: $!\n";
my @lines = <FILE>;
close(FILE);
open( SQUID_OI, ">", "$file" ) or die "Can't open $file: $!\n";
foreach ( @lines ) {
s/tcp_outgoing/#tcp_outgoing/ if m/201.18.32.26/;
s/always_direct/#always_direct/ if m/liberado_2m/;
s/always_direct/#always_direct/ if m/link_2m/;
print SQUID_OI;
}
close(SQUID_OI);
}
sub comment_squid_emb_34 {
#Specify the file
my $file = "squid.conf";
#Open the file and read data
#Die with grace if it fails
open( FILE, "<", "$file" ) or die "Can't open $file: $!\n";
my @lines = <FILE>;
close(FILE);
open( SQUID_EMB_34, ">", "$file" ) or die "Can't open $file: $!\n";
foreach ( @lines ) {
s/tcp_outgoing/#tcp_outgoing/ if m/201.73.62.34/;
s/always_direct/#always_direct/ if m/liberado_10m[^2]/;
s/always_direct/#always_direct/ if m/link_10m[^2]/;
print SQUID_EMB_34;
}
close(SQUID_EMB_34);
}
sub comment_squid_emb_147 {
#Specify the file
my $file = "squid.conf";
#Open the file and read data
#Die with grace if it fails
open( FILE, "<", "$file" ) or die "Can't open $file: $!\n";
my @lines = <FILE>;
close(FILE);
open( SQUID_EMB_147, ">", "$file" ) or die "Can't open $file: $!\n";
foreach ( @lines ) {
s/tcp_outgoing/#tcp_outgoing/ if m/201.73.254.147/;
s/always_direct/#always_direct/ if m/liberado_10m2/;
s/always_direct/#always_direct/ if m/link_10m2/;
print SQUID_EMB_147;
}
close(SQUID_EMB_147);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment