Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix323 FOR TESTING #335

Merged
merged 11 commits into from Jan 4, 2020
55 changes: 31 additions & 24 deletions lib/PACConfig.pm
Expand Up @@ -64,9 +64,6 @@ my $GLADE_FILE = "$RealBin/res/asbru.glade";
my $CFG_DIR = $ENV{"ASBRU_CFG"};
my $RES_DIR = "$RealBin/res";

# Connect to Gnome's GSettings
my $GSETTINGS = Glib::IO::Settings->new('org.gnome.system.proxy.http');

my $CIPHER = Crypt::CBC->new(-key => 'PAC Manager (David Torrejon Vaquerizas, david.tv@gmail.com)', -cipher => 'Blowfish', -salt => '12345678') or die "ERROR: $!";

# END: Define GLOBAL CLASS variables
Expand Down Expand Up @@ -221,7 +218,6 @@ sub _setupCallbacks {
# Capture 'Show hidden files' checkbox for session log files
$$self{cbShowHidden}->signal_connect('toggled' => sub {_($self, 'btnCfgSaveSessionLogs')->set_show_hidden($$self{cbShowHidden}->get_active);});

_($self, 'cbCfgProxyToggle')->signal_connect('toggled' => sub {_($self, 'aCfgProxy')->set_sensitive(_($self, 'cbCfgProxyToggle')->get_active);});
_($self, 'cbConnShowPass')->signal_connect('toggled' => sub {_($self, 'entryPassword')->set_visibility(_($self, 'cbConnShowPass')->get_active);});
_($self, 'cbCfgPreConnPingPort')->signal_connect('toggled' => sub {_($self, 'spCfgPingTimeout')->set_sensitive(_($self, 'cbCfgPreConnPingPort')->get_active);});
_($self, 'cbCfgSaveSessionLogs')->signal_connect('toggled' => sub {_($self, 'hboxCfgSaveSessionLogs')->set_sensitive(_($self, 'cbCfgSaveSessionLogs')->get_active);});
Expand Down Expand Up @@ -624,19 +620,6 @@ sub _updateGUIPreferences {
my $cfg = shift // $$self{_CFG};
my %layout = ('Traditional',0,'Compact',1);

# Get PROXY from environment
my $proxy_ip = $GSETTINGS->get_string('host');
my $proxy_port = $GSETTINGS->get_int('port');
my $proxy_user = $GSETTINGS->get_string('authentication-user');
my $proxy_pass = $GSETTINGS->get_string('authentication-password');
my $proxy_string = 'no proxy configured';

if ($proxy_ip) {
$proxy_string = "$proxy_ip:$proxy_port";
}
if ($proxy_user) {
$proxy_string .= "; User: $proxy_user, Pass: <password hidden!>";
}
if (!defined $$cfg{'defaults'}{'layout'}) {
$$cfg{'defaults'}{'layout'} = 'Traditional';
}
Expand Down Expand Up @@ -800,17 +783,30 @@ sub _updateGUIPreferences {
_($self, 'entryCfgShellOptions')->set_text($$cfg{'defaults'}{'shell options'});
_($self, 'entryCfgShellDirectory')->set_text($$cfg{'defaults'}{'shell directory'});

if (defined $$cfg{'defaults'}{'proxy'}) {
if ($$cfg{'defaults'}{'proxy'} eq 'Jump') {
_($self, 'cbCfgProxyJump')->set_active(1);
} elsif ($$cfg{'defaults'}{'proxy'} eq 'Proxy') {
_($self, 'cbCfgProxyManual')->set_active(1);
} else {
_($self, 'cbCfgProxyNo')->set_active(1);
}
} else {
$$cfg{'defaults'}{'proxy'} = '';
_($self, 'cbCfgProxyNo')->set_active(1);
}
# Proxy Configuration
_($self, 'cbCfgProxyToggle')->set_active($$cfg{'defaults'}{'use proxy'});
_($self, 'aCfgProxy')->set_sensitive(_($self, 'cbCfgProxyToggle')->get_active);
_($self, 'cbCfgProxySystem')->set_active($$cfg{'defaults'}{'use system proxy'});
_($self, 'cbCfgProxySystem')->set('label', 'Use system proxy settings (' . $proxy_string . ')');
_($self, 'cbCfgProxyManual')->set_active(! $$cfg{'defaults'}{'use system proxy'});
_($self, 'entryCfgProxyIP')->set_text($$cfg{'defaults'}{'proxy ip'});
_($self, 'entryCfgProxyPort')->set_value(($$cfg{'defaults'}{'proxy port'} // 0) || 8080);
_($self, 'entryCfgProxyUser')->set_text($$cfg{'defaults'}{'proxy user'});
_($self, 'entryCfgProxyPassword')->set_text($$cfg{'defaults'}{'proxy pass'});

# Jump Configuration
_($self, 'entryCfgJumpIP')->set_text($$cfg{'defaults'}{'jump ip'} // '');
_($self, 'entryCfgJumpPort')->set_value(($$cfg{'defaults'}{'jump port'} // 22) || 22);
_($self, 'entryCfgJumpUser')->set_text($$cfg{'defaults'}{'jump user'} // '');
_($self, 'entryCfgJumpConfig')->set_text($$cfg{'defaults'}{'jump config'} // '');

# Global TABS
$$self{_SHELL}->update($$self{_CFG}{'environments'}{'__PAC_SHELL__'}{'terminal options'});
$$self{_VARIABLES}->update($$self{_CFG}{'defaults'}{'global variables'});
Expand Down Expand Up @@ -880,12 +876,23 @@ sub _saveConfiguration {
$$self{_CFG}{'defaults'}{'remember main size'} = _($self, 'cbCfgRememberSize')->get_active;
$$self{_CFG}{'defaults'}{'save on exit'} = _($self, 'cbCfgSaveOnExit')->get_active;
$$self{_CFG}{'defaults'}{'auto save'} = _($self, 'cbCfgAutoSave')->get_active;
$$self{_CFG}{'defaults'}{'use proxy'} = _($self, 'cbCfgProxyToggle')->get_active;
$$self{_CFG}{'defaults'}{'use system proxy'} = _($self, 'cbCfgProxySystem')->get_active;
if (_($self, 'cbCfgProxyManual')->get_active) {
$$self{_CFG}{'defaults'}{'proxy'} = 'Proxy';
} elsif (_($self, 'cbCfgProxyJump')->get_active) {
$$self{_CFG}{'defaults'}{'proxy'} = 'Jump';
} else {
$$self{_CFG}{'defaults'}{'proxy'} = 'No';
}
# SOCKS PROXY
$$self{_CFG}{'defaults'}{'proxy ip'} = _($self, 'entryCfgProxyIP')->get_chars(0, -1);
$$self{_CFG}{'defaults'}{'proxy port'} = _($self, 'entryCfgProxyPort')->get_chars(0, -1);
$$self{_CFG}{'defaults'}{'proxy user'} = _($self, 'entryCfgProxyUser')->get_chars(0, -1);
$$self{_CFG}{'defaults'}{'proxy pass'} = _($self, 'entryCfgProxyPassword')->get_chars(0, -1);
# JUMP SERVER
$$self{_CFG}{'defaults'}{'jump ip'} = _($self, 'entryCfgJumpIP')->get_chars(0, -1);
$$self{_CFG}{'defaults'}{'jump port'} = _($self, 'entryCfgJumpPort')->get_chars(0, -1);
$$self{_CFG}{'defaults'}{'jump user'} = _($self, 'entryCfgJumpUser')->get_chars(0, -1);
$$self{_CFG}{'defaults'}{'jump config'} = _($self, 'entryCfgJumpConfig')->get_chars(0, -1);
$$self{_CFG}{'defaults'}{'shell binary'} = _($self, 'entryCfgShellBinary')->get_chars(0, -1);
$$self{_CFG}{'defaults'}{'shell options'} = _($self, 'entryCfgShellOptions')->get_chars(0, -1);
$$self{_CFG}{'defaults'}{'shell directory'} = _($self, 'entryCfgShellDirectory')->get_chars(0, -1);
Expand Down
47 changes: 35 additions & 12 deletions lib/PACEdit.pm
Expand Up @@ -71,8 +71,6 @@ my $INIT_CFG_FILE = $RES_DIR . '/pac.yml';
my $CFG_DIR = $ENV{"ASBRU_CFG"};
my $CFG_FILE = $CFG_DIR . '/pac.yml';

my $GSETTINGS = Glib::IO::Settings->new('org.gnome.system.proxy.http');

# END: Define GLOBAL CLASS variables
###################################################################

Expand Down Expand Up @@ -641,15 +639,24 @@ sub _updateGUIPreferences {
# General options
####################################

if (!defined $$self{_CFG}{'environments'}{$uuid}{'use proxy'}) {
$$self{_CFG}{'environments'}{$uuid}{'use proxy'} = 0;
}
_($self, 'rbUseProxyIfCFG')->set_active($$self{_CFG}{'environments'}{$uuid}{'use proxy'} == 0);
_($self, 'rbUseProxyAlways')->set_active($$self{_CFG}{'environments'}{$uuid}{'use proxy'} == 1);
_($self, 'rbUseProxyNever')->set_active($$self{_CFG}{'environments'}{$uuid}{'use proxy'} == 2);
_($self, 'rbUseProxyJump')->set_active($$self{_CFG}{'environments'}{$uuid}{'use proxy'} == 3);
_($self, 'vboxCfgManualProxyConn')->set_sensitive(_($self, 'rbUseProxyAlways')->get_active);
_($self, 'bCfgProxy')->set_sensitive(1);
# SOCKS Proxy
_($self, 'entryCfgProxyConnIP')->set_text($$self{_CFG}{'environments'}{$uuid}{'proxy ip'});
_($self, 'entryCfgProxyConnPort')->set_value($$self{_CFG}{'environments'}{$uuid}{'proxy port'} // 8080);
_($self, 'entryCfgProxyConnUser')->set_text($$self{_CFG}{'environments'}{$uuid}{'proxy user'});
_($self, 'entryCfgProxyConnPassword')->set_text($$self{_CFG}{'environments'}{$uuid}{'proxy pass'});
_($self, 'vboxCfgManualProxyConn')->set_sensitive(_($self, 'rbUseProxyAlways')->get_active);
# Jump Server
_($self, 'entryCfgJumpConnIP')->set_text($$self{_CFG}{'environments'}{$uuid}{'jump ip'} // '');
_($self, 'entryCfgJumpConnPort')->set_value($$self{_CFG}{'environments'}{$uuid}{'jump port'} // 22);
_($self, 'entryCfgJumpConnUser')->set_text($$self{_CFG}{'environments'}{$uuid}{'jump user'} // '');
_($self, 'entryCfgJumpConnConfig')->set_text($$self{_CFG}{'environments'}{$uuid}{'jump config'} // '');
_($self, 'cbEditUseSudo')->set_active($$self{_CFG}{'environments'}{$uuid}{'use sudo'});
_($self, 'cbEditSaveSessionLogs')->set_active($$self{_CFG}{'environments'}{$uuid}{'save session logs'});
_($self, 'cbEditPrependCommand')->set_active($$self{_CFG}{'environments'}{$uuid}{'use prepend command'} // 0);
Expand Down Expand Up @@ -763,25 +770,41 @@ sub _saveConfiguration {
}

# Check if proxy ip and port are defined in case "force use proxy" is checked
if ((_($self, 'rbUseProxyAlways')->get_active == 1) && (! _($self, 'entryCfgProxyConnIP')->get_chars(0, -1) || ! _($self, 'entryCfgProxyConnPort')->get_chars(0, -1) )) {
_wMessage($$self{_WINDOWEDIT}, "<b>Please, check:</b>\n\nPROXY IP / PORT can't be empty if 'always use proxy' is active\n\n<b>before saving this connection data!!</b>");
if ((_($self, 'rbUseProxyAlways')->get_active == 1) && (!_($self,'entryCfgProxyConnIP')->get_chars(0,-1) || ! _($self, 'entryCfgProxyConnPort')->get_chars(0,-1))) {
_wMessage($$self{_WINDOWEDIT}, "<b>Please, check:</b>\n\nSOCKS IP / PORT can't be empty\n\n<b>before saving this connection data!!</b>");
return 0;
}

##############################
# IP, Port, User, Pass, ...
##############################

$$self{_CFG}{'environments'}{$uuid}{'use proxy'} = 0 if _($self, 'rbUseProxyIfCFG')->get_active;
$$self{_CFG}{'environments'}{$uuid}{'use proxy'} = 1 if _($self, 'rbUseProxyAlways')->get_active;
$$self{_CFG}{'environments'}{$uuid}{'use proxy'} = 2 if _($self, 'rbUseProxyNever')->get_active;
if (_($self, 'rbUseProxyIfCFG')->get_active) {
$$self{_CFG}{'environments'}{$uuid}{'use proxy'} = 0;
} elsif (_($self, 'rbUseProxyAlways')->get_active) {
$$self{_CFG}{'environments'}{$uuid}{'use proxy'} = 1;
} elsif (_($self, 'rbUseProxyJump')->get_active) {
$$self{_CFG}{'environments'}{$uuid}{'use proxy'} = 3;
} else {
$$self{_CFG}{'environments'}{$uuid}{'use proxy'} = 2;
}
# SOCKS Proxy
$$self{_CFG}{'environments'}{$uuid}{'proxy ip'} = _($self, 'entryCfgProxyConnIP')->get_chars(0, -1);
$$self{_CFG}{'environments'}{$uuid}{'proxy port'} = _($self, 'entryCfgProxyConnPort')->get_chars(0, -1);
$$self{_CFG}{'environments'}{$uuid}{'proxy user'} = _($self, 'entryCfgProxyConnUser')->get_chars(0, -1);
$$self{_CFG}{'environments'}{$uuid}{'proxy pass'} = _($self, 'entryCfgProxyConnPassword')->get_chars(0, -1);
if (_($self, 'rbCfgAuthUserPass')->get_active) {$$self{_CFG}{'environments'}{$uuid}{'auth type'} = 'userpass';}
elsif (_($self, 'rbCfgAuthPublicKey')->get_active) {$$self{_CFG}{'environments'}{$uuid}{'auth type'} = 'publickey';}
elsif (_($self, 'rbCfgAuthManual')->get_active) {$$self{_CFG}{'environments'}{$uuid}{'auth type'} = 'manual';}
# Jump server
$$self{_CFG}{'environments'}{$uuid}{'jump ip'} = _($self, 'entryCfgJumpConnIP')->get_chars(0, -1);
$$self{_CFG}{'environments'}{$uuid}{'jump port'} = _($self, 'entryCfgJumpConnPort')->get_chars(0, -1);
$$self{_CFG}{'environments'}{$uuid}{'jump user'} = _($self, 'entryCfgJumpConnUser')->get_chars(0, -1);
$$self{_CFG}{'environments'}{$uuid}{'jump config'} = _($self, 'entryCfgJumpConnConfig')->get_chars(0, -1);
if (_($self, 'rbCfgAuthUserPass')->get_active) {
$$self{_CFG}{'environments'}{$uuid}{'auth type'} = 'userpass';
} elsif (_($self, 'rbCfgAuthPublicKey')->get_active) {
$$self{_CFG}{'environments'}{$uuid}{'auth type'} = 'publickey';
} elsif (_($self, 'rbCfgAuthManual')->get_active) {
$$self{_CFG}{'environments'}{$uuid}{'auth type'} = 'manual';
}
$$self{_CFG}{'environments'}{$uuid}{'passphrase user'} = _($self, 'entryUserPassphrase')->get_chars(0, -1);
$$self{_CFG}{'environments'}{$uuid}{'passphrase'} = _($self, 'entryPassphrase')->get_chars(0, -1);
$$self{_CFG}{'environments'}{$uuid}{'public key'} = _($self, 'fileCfgPublicKey')->get_filename // '';
Expand Down
2 changes: 1 addition & 1 deletion lib/PACTerminal.pm
Expand Up @@ -829,7 +829,7 @@ sub _initGUI {
_setupTabDND($self);

$tabs->append_page($$self{_GUI}{_VBOX}, $$self{_GUI}{_TABLBL});
$tabs->show_all();
$tabs->show();
$$self{_GUI}{_VBOX}->show_all();
$tabs->set_tab_reorderable($$self{_GUI}{_VBOX}, 1);
$tabs->set_current_page(-1);
Expand Down