sympa-community / sympa

Sympa, Mailing List Management Software
https://www.sympa.community/sympa
GNU General Public License v2.0
244 stars 96 forks source link

Add proxying support to include_remote_file #756

Open ikedas opened 5 years ago

ikedas commented 5 years ago

Expected Behavior

include_remote_file (and maybe include_remote_sympa_list) would support access through proxy server.

Current Behavior

There are no such features.

Possible Solution

Theoretically, the change like a patch below may support some sort of proxying.

diff --git a/src/lib/Sympa/DataSource/RemoteFile.pm b/src/lib/Sympa/DataSource/RemoteFile.pm
index f97cce0..2160372 100644
--- a/src/lib/Sympa/DataSource/RemoteFile.pm
+++ b/src/lib/Sympa/DataSource/RemoteFile.pm
@@ -48,6 +48,11 @@ sub _open {
     my $ua =
         LWP::UserAgent->new(agent => 'Sympa/' . Sympa::Constants::VERSION);
     $ua->protocols_allowed(['http', 'https', 'ftp']);
+
+    if ($self->{url} =~ /pattern[.]for[.]some[.]site/) {
+        $ua->proxy('http', 'http://proxy.host:port');
+    }
+
     if ($self->{url} =~ /\Ahttps:/i) {
         my $cert_file = Sympa::search_fullpath($list, 'cert.pem');
         my $key_file  = Sympa::search_fullpath($list, 'private_key');

Context

See also a post on sympa-users.

jth56000 commented 4 years ago

Hello Soji,

I contact you again about this issue, we just migrate our production server from 6.2.22 to 6.2.52+security patch and we have again this issue. In my log I have : Apr 21 14:17:07 tcgpsympa2 wwsympa[31276]: err main::#1539 > main::do_sync_include#16506 > Sympa::List::sync_include#4826 > Sympa::Spindle::spin#95 > Sympa::Request::Handler::include::_twist#181 > Sympa::Request::Handler::include::_update_users#289 > Sympa::DataSource::open#134 > Sympa::DataSource::RemoteFile::_open#110 Unable to fetch data source Sympa::DataSource::RemoteFile context=postdocs.neuro-psi@services.cnrs.fr;id=f3919ba3;role=member;name=postdocs-npsi: Can't connect to neuro-psi.cnrs.fr:80 (Connection refused)

In RemoteFile.pm I set as requested 👍

48 my $ua = 49 LWP::UserAgent->new(agent => 'Sympa/' . Sympa::Constants::VERSION); 50 $ua->protocols_allowed(['http', 'https', 'ftp']); 51 52 53 if ($self->{url} =~ /somlit-db.epoc.u-bordeaux1.fr/) { 54 $ua->proxy('http', 'http://t3hpsquid.users.interne:3128'); 55 } 56 if ($self->{url} =~ /www.inaf.cnrs-gif.fr/) { 57 $ua->proxy('http', 'http://t3hpsquid.users.interne:3128'); 58 } 59 if ($self->{url} =~ /neuro-psi.cnrs.fr/) { 60 $ua->proxy('http', 'http://t3hpsquid.users.interne:3128'); 61 } 62 63 if ($self->{url} =~ /\Ahttps:/i) {

But the issue is still present. The list does not synchronize.

Any help would be apreciated.

Regards, Jean THOMAS