diff --git a/README.md b/README.md index ef5f9d4..5de8e94 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/scripts/patrix b/scripts/patrix index 5ce6407..b5c102c 100644 --- a/scripts/patrix +++ b/scripts/patrix @@ -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");