summaryrefslogtreecommitdiffstats
path: root/INF/ILO2.pm
diff options
context:
space:
mode:
Diffstat (limited to 'INF/ILO2.pm')
-rw-r--r--INF/ILO2.pm71
1 files changed, 54 insertions, 17 deletions
diff --git a/INF/ILO2.pm b/INF/ILO2.pm
index aeff411..81e4746 100644
--- a/INF/ILO2.pm
+++ b/INF/ILO2.pm
@@ -40,29 +40,42 @@ sub read_file($) {
return $guts;
}
-sub setup_port_proxy($$$) {
- my ( $local_port, $remote_host, $remote_port ) = @_;
+sub setup_port_proxy($$$$) {
+ my ( $self, $local_port, $remote_host, $remote_port ) = @_;
my $child = fork();
- print STDERR "balance ",
- join(
- ' ',
- (
- "balance", "-d", "-f", "127.0.0.1", $local_port,
- $remote_host . ":" . $remote_port
- )
- ),
- "\n";
+ my $cmd = [
+ "balance", "-d", "-f", "-b", "127.0.0.1", $local_port,
+ $remote_host . ":" . $remote_port
+ ];
+
+ print STDERR "PROXY CMD: " . join( ' ', @$cmd ) . "\n";
if ( $child == 0 ) {
- exec( "balance", "-d", "-f", "-b", "127.0.0.1", $local_port,
- $remote_host . ":" . $remote_port );
+ if ( defined $self->{proxy_host} ) {
+ my $tmp = File::Temp->new( UNLINK => 0, SUFFIX => '.cnf' );
+
+ select( ( select($tmp), $| = 1 )[0] );
+
+ print $tmp "server = 127.0.0.1\n";
+ print $tmp "server_port = " . $self->{proxy_port} . "\n";
+ print $tmp "local = 127.0.0.0/255.0.0.0\n";
+
+ $ENV{'LD_PRELOAD'} = 'libtsocks.so';
+ $ENV{'TSOCKS_CONF_FILE'} = $tmp->filename;
+
+ print "Filename is $tmp->filename\n";
+ }
+
+ exec(@$cmd);
print STDERR "failed to start port proxy";
sleep(10000);
}
+ sleep(4);
+
print "Setup proxy $local_port -> $remote_host:$remote_port\n";
return $child;
@@ -106,6 +119,24 @@ sub proxy($$$) {
}
+sub logout($) {
+ my $self = shift;
+
+ return unless defined $self->{stoken};
+
+ my $get = GET( $self->{ilo_url} . '/logout.htm' );
+
+ $get->header( 'cookie' => $self->{stoken} );
+
+ my $res = $self->{ua}->request($get);
+
+ unless ( $res->is_success ) {
+ print STDERR "failed to logout";
+ return -1;
+ }
+
+}
+
sub login($) {
my $self = shift;
@@ -223,7 +254,7 @@ sub view($) {
my $local_port = int( rand(30000) ) + 30000;
push @{ $self->{to_kill} },
- setup_port_proxy( $local_port, $self->{host}, $things->{info6} );
+ $self->setup_port_proxy( $local_port, $self->{host}, $things->{info6} );
$things->{info6} = $local_port;
$things->{consoleWidth} = 1024;
@@ -276,8 +307,6 @@ sub view($) {
$SIG{TERM} = sub { kill 'TERM', ( @{ $self->{to_kill} } ); die; };
system(
- # "strace","-f","-o","t2","-s","8192",
- # "/bin/appletviewer",
"appletviewer",
"-J-Djava.security.manager",
"-J-Djava.security.policy=/usr/local/share/inf/ilo/mypolicy",
@@ -324,7 +353,7 @@ sub media($) {
my $local_port = int( rand(30000) ) + 30000;
push @{ $self->{to_kill} },
- setup_port_proxy( $local_port, $self->{host}, $things->{info1v} );
+ $self->setup_port_proxy( $local_port, $self->{host}, $things->{info1v} );
$things->{info1v} = $local_port;
@@ -556,6 +585,14 @@ sub new ($;$) {
verify_hostname => 0,
);
+ if ( defined $parm->{proxy_host} ) {
+ $self->{ua}->proxy( [qw(http https)] => "socks://"
+ . $parm->{proxy_host} . ":"
+ . $parm->{proxy_port} );
+ $self->{proxy_host} = $parm->{proxy_host};
+ $self->{proxy_port} = $parm->{proxy_port};
+ }
+
my $local_port = int( rand(30000) ) + 30000;
$self->{proxy_url} = 'https://127.0.0.1:' . $local_port;