Support using an HTTP proxy

tags/patrix-0.1.9-1
Daniel Berteaud 7 years ago
parent 92b8451f95
commit ea83e268b4
  1. 1
      README.md
  2. 9
      scripts/patrix

@ -21,6 +21,7 @@ Here're the vailable options:
* --user: specify the user you want to login as
* --password: the password to auth against the HS
* --server: the HS you want to connect to. Default is https://matrix.org
* --proxy: use an HTTP proxy to access the HS. If not specified, will try to get system wide proxy (see LWP::UserAgent->env_proxy)
* --access-token: can be used instead of --user and --password. Use --get-access-token to get one first for example.
* --room: the room to which the message must be sent. Can be a room ID or a room alias
* --message: the text message you want to send. If you send something on stdin, it's assumed to be the text to send and this option is ignored

@ -23,6 +23,7 @@ GetOptions(
"password=s" => \$opt->{password},
"access_token|access-token|token=s" => \$opt->{access_token},
"server=s" => \$opt->{server},
"proxy=s" => \$opt->{proxy},
"room=s" => \$opt->{room},
"message|msg=s" => \$opt->{message},
"files=s@" => \$opt->{file},
@ -82,6 +83,14 @@ foreach my $action (@actions){
my $lwp = LWP::UserAgent->new;
# If a proxy is specified then use it. Else, try to get global one
if ($opt->{proxy}){
$lwp->proxy(['https'], $opt->{proxy});
}
else{
$lwp->env_proxy;
}
my $stdin = 0;
if (!-t STDIN){
debug("Reading data from stdin");

Loading…
Cancel
Save