A utility class that detects proxies using ProxySelector and detects authentication credentials using Authenticator.
| 46 | * |
| 47 | */ |
| 48 | class ProxyDetectorImpl implements ProxyDetector { |
| 49 | // To validate this code: set up a local squid proxy instance, and |
| 50 | // try to communicate with grpc-test.sandbox.googleapis.com:443. |
| 51 | // The endpoint runs an instance of TestServiceGrpc, see |
| 52 | // AbstractInteropTest for an example how to run a |
| 53 | // TestService.EmptyCall RPC. |
| 54 | // |
| 55 | // The instructions below assume Squid 3.5.23 and a recent |
| 56 | // version of Debian. |
| 57 | // |
| 58 | // Set the contents of /etc/squid/squid.conf to be: |
| 59 | // WARNING: THESE CONFIGS HAVE NOT BEEN REVIEWED FOR SECURITY, DO |
| 60 | // NOT USE OUTSIDE OF TESTING. COMMENT OUT THIS WARNING TO |
| 61 | // UNBREAK THE CONFIG FILE. |
| 62 | // acl SSL_ports port 443 |
| 63 | // acl Safe_ports port 80 |
| 64 | // acl Safe_ports port 21 |
| 65 | // acl Safe_ports port 443 |
| 66 | // acl Safe_ports port 70 |
| 67 | // acl Safe_ports port 210 |
| 68 | // acl Safe_ports port 1025-65535 |
| 69 | // acl Safe_ports port 280 |
| 70 | // acl Safe_ports port 488 |
| 71 | // acl Safe_ports port 591 |
| 72 | // acl Safe_ports port 777 |
| 73 | // acl CONNECT method CONNECT |
| 74 | // http_access deny !Safe_ports |
| 75 | // http_access deny CONNECT !SSL_ports |
| 76 | // http_access allow localhost manager |
| 77 | // http_access deny manager |
| 78 | // http_access allow localhost |
| 79 | // http_access deny all |
| 80 | // http_port 3128 |
| 81 | // coredump_dir /var/spool/squid |
| 82 | // refresh_pattern ^ftp: 1440 20% 10080 |
| 83 | // refresh_pattern ^gopher: 1440 0% 1440 |
| 84 | // refresh_pattern -i (/cgi-bin/|\?) 0 0% 0 |
| 85 | // refresh_pattern . 0 20% 4320 |
| 86 | // |
| 87 | // Restart squid: |
| 88 | // $ sudo /etc/init.d/squid restart |
| 89 | // |
| 90 | // To test with passwords: |
| 91 | // |
| 92 | // Run this command and follow the instructions to set up a user/pass: |
| 93 | // $ sudo htpasswd -c /etc/squid/passwd myuser1 |
| 94 | // |
| 95 | // Make the file readable to squid: |
| 96 | // $ sudo chmod 644 /etc/squid/passwd |
| 97 | // |
| 98 | // Validate the username and password, you should see OK printed: |
| 99 | // $ /usr/lib/squid3/basic_ncsa_auth /etc/squid/passwd |
| 100 | // myuser1 <your password here> |
| 101 | // |
| 102 | // Add these additional lines to the beginning of squid.conf (the ordering matters): |
| 103 | // auth_param basic program /usr/lib/squid3/basic_ncsa_auth /etc/squid/passwd |
| 104 | // auth_param basic children 5 |
| 105 | // auth_param basic realm Squid proxy-caching web server |