From 2a5f8639fcc21add3f9161d4986542005d4b1833 Mon Sep 17 00:00:00 2001 From: Florian Pritz Date: Sun, 22 Apr 2018 22:24:24 +0200 Subject: misc Signed-off-by: Florian Pritz --- inwx-add-record.pl | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'inwx-add-record.pl') diff --git a/inwx-add-record.pl b/inwx-add-record.pl index 135c0b7..c4bcf2d 100755 --- a/inwx-add-record.pl +++ b/inwx-add-record.pl @@ -9,6 +9,7 @@ use File::Basename; use HTTP::Cookies; use Try::Tiny; use XMLRPC::Lite; # +trace => 'all'; +use JSON; # FIXME: put this in a config file @@ -27,10 +28,16 @@ my $name = shift @ARGV; my $type = shift @ARGV; my $content = shift @ARGV; -my $client = DomRobot->proxy($addr, cookie_jar => HTTP::Cookies->new(ignore_discard => 1)); -$client->call('account.login', { user => $usr, pass => $pwd }); -my $TFAToken = getInput("Enter 2FA token (press enter if 2FA is not used)"); -$client->call('account.unlock', { tan => $TFAToken }) if $TFAToken ne ''; +my $client = DomRobot->proxy($addr, cookie_jar => HTTP::Cookies->new(file => "$ENV{HOME}/.inwx-add-record.cookies", autosave => 1, ignore_discard => 1)); + +sub login { + $client->call('account.login', { user => $usr, pass => $pwd }); + my $TFAToken = getInput("Enter 2FA token (press enter if 2FA is not used)"); + $TFAToken =~ s/ //g; + $client->call('account.unlock', { tan => $TFAToken }) if $TFAToken ne ''; +} + +#login(); #open(my $fh, '<', 'domains') or die "Failed to open: $!"; @@ -46,7 +53,7 @@ $client->call('account.unlock', { tan => $TFAToken }) if $TFAToken ne ''; #} #close $fh; -$client->logout; +#$client->logout; exit 0; sub getInput { -- cgit v1.2.3-24-g4f1b