stunnel
4.05_1
Services: Secure Tunnel
['installedpackages']['package']['$packagename']['configuration']
Description
description
Listen on IP
localip
Listen on Port
localport
Redirects to IP
redirectip
Redirects to Port
redirectport
Description
description
Enter a description for this redirection.
input
Listen on IP
localip
Enter the local IP address to bind this redirection to.
input
Listen on port
localport
Enter the local port to bind this redirection to.
input
Redirects to IP
redirectip
Enter the IP address to redirect this to.
input
Redirects to Port
redirectport
Enter the port to redirect to.
input
safe_mkdir("/usr/local/etc/stunnel");
system("/usr/bin/openssl req -new -x509 -days 365 -nodes -out /usr/local/etc/stunnel/stunnel.pem -keyout /usr/local/etc/stunnel/stunnel.pem 2>/dev/null");
chmod("/usr/local/etc/stunnel/stunnel.pem", 600);
system("mkdir /var/tmp/stunnel; mkdir /var/tmp/stunnel/var; mkdir /var/tmp/stunnel/var/tmp; chown -R stunnel:stunnel /var/tmp/stunnel");
chmod("/var/tmp/stunnel/var/tmp/", 1777);
$fout = fopen("/usr/local/etc/rc.d/stunnel.sh","w");
fwrite($fout, "#!/bin/sh\n");
fwrite($fout, "# PACKAGE: STunnel\n");
fwrite($fout, "# EXECUTABLE: stunnel\n");
fwrite($fout, "/usr/local/sbin/stunnel /usr/local/etc/stunnel/stunnel.conf\n\n");
fclose($fout);
chmod("/usr/local/etc/rc.d/stunnel.sh", 0555);
rmdir_recursive("/var/tmp/stunnel");
rmdir_recursive("/usr/local/etc/stunnel*");
conf_mount_rw();
config_lock();
$fout = fopen("/usr/local/etc/stunnel/stunnel.conf","w");
fwrite($fout, "cert = /usr/local/etc/stunnel/stunnel.pem \n");
fwrite($fout, "chroot = /var/tmp/stunnel \n");
fwrite($fout, "setuid = stunnel \n");
fwrite($fout, "setgid = stunnel \n");
foreach($config['installedpackages']['stunnel']['config'] as $pkgconfig) {
fwrite($fout, "\n[" . $pkgconfig['description'] . "]\n");
fwrite($fout, "accept = " . $pkgconfig['localip'] . ":" . $pkgconfig['localport'] . "\n");
fwrite($fout, "connect = " . $pkgconfig['redirectip'] . ":" . $pkgconfig['redirectport'] . "\n");
fwrite($fout, "TIMEOUTclose = 0\n\n");
}
fclose($fout);
conf_mount_ro();
config_unlock();
system("/usr/bin/killall stunnel 2>/dev/null");
system("/usr/local/etc/rc.d/stunnel.sh start 2>/dev/null");