App-ReslirpTunnel
view release on metacpan or search on metacpan
bin/reslirp-tunnel view on Meta::CPAN
=head1 DESCRIPTION
C<reslirp-tunnel> establishes a reSLIRP tunnel to a specified remote
host using SSH. It enables users to configure various networking
options and manages IP routing rules along with DNS resolution
configuration, greatly simplifying the setup process for a reSLIRP
tunnel.
The program is designed to be executed by a non-root user. It
automatically invokes sudo in the background, which typically prompts
the user for a password to perform privileged operations.
=head1 OPTIONS
=over 8
=item B<-C>, B<--reslirp-command> I<command>
Specify command to be use on the remote host to run reSLIRP.
bin/reslirp-tunnel view on Meta::CPAN
=item B<-f>, B<--run-in-foreground>
By default, C<reslirp-tunnel> detaches from the terminal once the
slave sudo process begins and the SSH connection is established. This
option disables that behavior.
=item B<--dont-close-stdio>
Preserve standard input/output.
By default, when C<reslirp-tunnel> forks itself into the background,
it closes its standard input and output channels. This can complicate
matters by preventing error messages from being printed
afterward. Enabling this option ensures that the standard input/output
channels remain open.
=item B<-P>, B<--profile> I<profile_name>
Load a profile from the configuration file.
=back
bin/reslirp-tunnel view on Meta::CPAN
=item 1.
Initiates a slave process using C<sudo> to carry out privileged operations.
=item 2.
Establishes an SSH connection to the designated remote host.
=item 3.
Forks itself into the background and closes its standard input and output channels.
=item 4.
Creates a C<tap> device.
=item 5.
Executes C<reSLIRP> on the remote machine, linking it to the C<tap>
device through an SSH channel.
lib/App/ReslirpTunnel.pm view on Meta::CPAN
eval {
$self->_init_xdg;
$self->_init_time;
$self->_init_logger;
$self->_log(info => "Starting ReslirpTunnel");
$self->_set_signal_handlers;
$self->_init_config;
$self->_init_butler;
$self->_init_ssh;
$self->_send_to_background;
$self->_init_tap_device;
$self->_init_reslirp;
$self->_init_loop;
$self->_config_forward_dns;
$self->_config_net_mappings;
$self->_init_dnsmasq;
$self->_init_resolver_rules;
$self->_init_routes;
$self->_wait_for_something;
$self->_log(info => "Terminating ReslirpTunnel");
lib/App/ReslirpTunnel.pm view on Meta::CPAN
log_level => $self->{log_level},
log_to_stderr => $self->{log_to_stderr},
log_file => $self->{log_file});
$butler->start or $self->_die("Failed to start butler");
$butler->hello
or $self->_die("Failed to say hello to butler");
$self->_log(info => "Elevated slave process started and ready");
}
sub _send_to_background {
my $self = shift;
return if $self->{run_in_foreground};
$self->_log(info => "Moving to background");
POSIX::setsid();
my $pid = fork // $self->_die("Unable to move process into the background", $!);
if ($pid == 0) {
$SIG{INT} = $self->{signal_handler};
$SIG{TERM} = $self->{signal_handler};
unless ($self->{dont_close_stdio}) {
open STDIN, '<', '/dev/null';
open STDOUT, '>', '/dev/null';
open STDERR, '>', '/dev/null' unless $self->{log_to_stderr};
}
$self->{log_prefix} = "ReslirpTunnel::Child";
return 1; # Return in the child!!!
}
else {
eval {
syswrite STDERR, "$0 moved to background, PID: $pid\n";
$self->_log(debug => "First process exiting");
};
POSIX::_exit(0);
}
}
sub _init_ssh {
my $self = shift;
my $host = $self->{ssh_host} // $self->_die("No remote host specified");
( run in 1.877 second using v1.01-cache-2.11-cpan-d8267643d1d )