Created
February 19, 2021 10:05
-
-
Save dex4er/7bd2243688aa4cf6645c21fdfa5f82b2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
## The fake API service for OpenVPN that allows to use client with simple setup mode. | |
use Mojo::File; | |
use Mojo::Util 'xml_escape'; | |
use Mojolicious::Lite; | |
post '/RPC2' => sub { | |
my ($c) = @_; | |
my $methodName = eval { $c->req->dom->at('methodName')->text } // ''; | |
if ($methodName eq 'GetSession') { | |
$c->render(text => q{<?xml version='1.0'?> | |
<methodResponse> | |
<params> | |
<param> | |
<value> | |
<struct> | |
<member> | |
<name>status</name> | |
<value> | |
<int>0</int> | |
</value> | |
</member> | |
<member> | |
<name>session_id</name> | |
<value> | |
<string>AS_AAAAAAAAAAAAAAAAAAAAAA==</string> | |
</value> | |
</member> | |
</struct> | |
</value> | |
</param> | |
</params> | |
</methodResponse>}); | |
} elsif ($methodName eq 'GetUserlogin') { | |
my $client_conf = xml_escape(Mojo::File->new('/etc/openvpn/client.conf')->slurp) =~ s/^/ /gr; | |
$c->render(text => qq{<?xml version='1.0'?> | |
<methodResponse> | |
<params> | |
<param> | |
<value> | |
<string> | |
$client_conf | |
</string> | |
</value> | |
</param> | |
</params> | |
</methodResponse>}); | |
} else { | |
$c->render(text => 'Not supported', status => 500); | |
} | |
}; | |
app->start; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment