Changeset 31880
- Timestamp:
- 2017-08-14T22:23:04+12:00 (6 years ago)
- Location:
- main/trunk
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/gli/classes/dictionary.properties
r31875 r31880 1004 1004 Preferences.Connection.No_Check_Certificate: No certificate checking (effective on 'https' URLs) 1005 1005 Preferences.Connection.No_Check_Certificate_Tooltip:Tick to download even from 'https' URLs that don't have a (valid) security certificate. 1006 Preferences.Connection.Proxy_Host:Proxy Host: 1007 Preferences.Connection.Proxy_Host_Tooltip:The address of your proxy server 1008 Preferences.Connection.Proxy_Port:Proxy Port: 1009 Preferences.Connection.Proxy_Port_Tooltip:The port number of your proxy server 1010 Preferences.Connection.Proxy_Host_Missing:Enter a value for the proxy host or turn off Use Proxy Connection in the Connection tab. 1006 Preferences.Connection.HTTP_Proxy_Host:HTTP Proxy Host: 1007 Preferences.Connection.HTTP_Proxy_Host_Tooltip:The address of your HTTP proxy server 1008 Preferences.Connection.HTTP_Proxy_Port_Tooltip:The port number of your HTTP proxy server 1009 Preferences.Connection.HTTPS_Proxy_Host:HTTPS Proxy Host: 1010 Preferences.Connection.HTTPS_Proxy_Host_Tooltip:The address of your HTTPS proxy server 1011 Preferences.Connection.HTTPS_Proxy_Port_Tooltip:The port number of your HTTPS proxy server 1012 Preferences.Connection.FTP_Proxy_Host:FTP Proxy Host: 1013 Preferences.Connection.FTP_Proxy_Host_Tooltip:The address of your FTP proxy server 1014 Preferences.Connection.FTP_Proxy_Port_Tooltip:The port number of your FTP proxy server 1015 Preferences.Connection.Proxy_Host_Missing:Enter a value for at least one proxy host or turn off Use Proxy Connection in the Connection tab. 1016 Preferences.Connection.Proxy_Port:Port: 1011 1017 Preferences.Connection.Servlet:Servlet: 1012 1018 Preferences.Connection.Servlet_Tooltip:The servlet to use to view your site -
main/trunk/gli/src/org/greenstone/gatherer/Gatherer.java
r31814 r31880 1453 1453 try {// Can throw several exceptions 1454 1454 if(Configuration.get("general.use_proxy", true)) { 1455 // These are Java properties, therefore see 1456 // https://docs.oracle.com/javase/7/docs/api/java/net/doc-files/net-properties.html 1457 // https://docs.oracle.com/javase/8/docs/technotes/guides/net/proxies.html 1458 // https://stackoverflow.com/questions/14243590/proxy-settings-in-java 1459 1460 // Not sure what proxyType is. And proxySet ceased to exist since JDK 6 or before 1455 1461 System.setProperty("http.proxyType", "4"); 1456 System.setProperty("http.proxyHost", Configuration.getString("general.proxy_host", true)); 1457 System.setProperty("http.proxyPort", Configuration.getString("general.proxy_port", true)); 1458 System.setProperty("http.proxySet", "true"); 1462 System.setProperty("http.proxyHost", Configuration.getString("general.HTTP_proxy_host", true)); 1463 System.setProperty("http.proxyPort", Configuration.getString("general.HTTP_proxy_port", true)); 1464 //System.setProperty("http.proxySet", "true"); 1465 1466 System.setProperty("https.proxyHost", Configuration.getString("general.HTTPS_proxy_host", true)); 1467 System.setProperty("https.proxyPort", Configuration.getString("general.HTTPS_proxy_port", true)); 1468 1469 System.setProperty("ftp.proxyHost", Configuration.getString("general.FTP_proxy_host", true)); 1470 System.setProperty("ftp.proxyPort", Configuration.getString("general.FTP_proxy_port", true)); 1471 1459 1472 } else { 1460 1473 System.setProperty("http.proxyHost", ""); 1461 1474 System.setProperty("http.proxyPort", ""); 1462 System.setProperty("http.proxySet", "false"); 1475 //System.setProperty("http.proxySet", "false"); 1476 System.setProperty("https.proxyHost", ""); 1477 System.setProperty("https.proxyPort", ""); 1478 System.setProperty("ftp.proxyHost", ""); 1479 System.setProperty("ftp.proxyPort", ""); 1463 1480 } 1464 1481 } catch (Exception error) { -
main/trunk/gli/src/org/greenstone/gatherer/download/DownloadJob.java
r31878 r31880 107 107 private final String mode; 108 108 109 private String proxy_url; // only the main thread (where DownloadJob runs) modifies this, so no synching needed109 private Properties proxy_urls; // only the main thread (where DownloadJob runs) modifies this, so no synching needed 110 110 111 111 /** 112 112 */ 113 public DownloadJob(Download download, String proxy_pass, String proxy_user, DownloadScrollPane mummy, String mode, String proxy_url) {113 public DownloadJob(Download download, String proxy_pass, String proxy_user, DownloadScrollPane mummy, String mode, Properties proxy_urls) { 114 114 URL url = null; 115 115 int folder_hash; 116 116 117 this.proxy_url = proxy_url;117 this.proxy_urls = proxy_urls; 118 118 119 119 download_option = downloadToHashMap(download); … … 310 310 Process prcs = null; 311 311 312 if (proxy_url != null && !proxy_url.equals("")) {312 if (proxy_urls.size() != 0) { 313 313 // Specify proxies as environment variables 314 314 // Need to manually specify GSDLHOME and GSDLOS also 315 env = new String[4+proxy_urls.size()]; 315 316 316 proxy_url = proxy_url.replaceAll("http://",""); 317 318 env = new String[7]; 319 320 env[0] = "http_proxy=http://"+proxy_url; 321 env[1] = "https_proxy=http://"+proxy_url; // yes, HTTP protocol for https:// too 322 // see also https://wiki.archlinux.org/index.php/proxy_settings 323 env[2] = "ftp_proxy=ftp://"+proxy_url; 324 env[3] = "GSDLHOME=" + Configuration.gsdl_path; 325 env[4] = "GSDLOS=" + Gatherer.client_operating_system; 317 env[0] = "GSDLHOME=" + Configuration.gsdl_path; 318 env[1] = "GSDLOS=" + Gatherer.client_operating_system; 326 319 // teach it where the wgetrc file lives, in gs2build/bin/<os>: 327 env[ 5] = "WGETRC=" + LocalGreenstone.getBinOSDirectoryPath(Gatherer.client_operating_system)+"wgetrc";320 env[2] = "WGETRC=" + LocalGreenstone.getBinOSDirectoryPath(Gatherer.client_operating_system)+"wgetrc"; 328 321 // Issue discovered on Windows: If PATH is not made available to perl, so that wget or something else needed by 329 322 // WgetDownload.pm's open3() call is not on the PATH, then the perl open() call to run wget fails. 330 323 // So make PATH available to get open3() working: 331 env[6] = "PATH="+System.getenv("PATH"); 324 env[3] = "PATH="+System.getenv("PATH"); 325 326 int next_index = 4; 327 String proxy_url = proxy_urls.getProperty("HTTP"); 328 if(proxy_url != null) { 329 env[next_index] = "http_proxy="+proxy_url; 330 next_index++; 331 } 332 proxy_url = proxy_urls.getProperty("HTTPS"); 333 if(proxy_url != null) { 334 env[next_index] = "https_proxy="+proxy_url; 335 next_index++; 336 } 337 proxy_url = proxy_urls.getProperty("FTP"); 338 if(proxy_url != null) { 339 env[next_index] = "ftp_proxy="+proxy_url; 340 next_index++; 341 } 332 342 333 343 prcs = rt.exec(cmd, env); … … 623 633 String [] env = null; 624 634 625 if (proxy_url != null && !proxy_url.equals("")) {635 if (proxy_urls.size() != 0) { 626 636 // Specify proxies as environment variables 627 637 // Need to manually specify GSDLHOME and GSDLOS also 638 env = new String[4+proxy_urls.size()]; 628 639 629 proxy_url = proxy_url.replaceAll("http://",""); 630 631 env = new String[7]; 632 633 env[0] = "http_proxy=http://"+proxy_url; 634 env[1] = "https_proxy=http://"+proxy_url; // yes, HTTP protocol for https:// too 635 // see also https://wiki.archlinux.org/index.php/proxy_settings 636 env[2] = "ftp_proxy=ftp://"+proxy_url; 637 env[3] = "GSDLHOME=" + Configuration.gsdl_path; 638 env[4] = "GSDLOS=" + Gatherer.client_operating_system; 640 env[0] = "GSDLHOME=" + Configuration.gsdl_path; 641 env[1] = "GSDLOS=" + Gatherer.client_operating_system; 639 642 // teach it where the wgetrc file lives, in gs2build/bin/<os>: 640 env[ 5] = "WGETRC=" + LocalGreenstone.getBinOSDirectoryPath(Gatherer.client_operating_system)+"wgetrc";643 env[2] = "WGETRC=" + LocalGreenstone.getBinOSDirectoryPath(Gatherer.client_operating_system)+"wgetrc"; 641 644 // Issue discovered on Windows: If PATH is not made available to perl, so that wget or something else needed by 642 645 // WgetDownload.pm's open3() call is not on the PATH, then the perl open() call to run wget fails. 643 646 // So make PATH available to get open3() working: 644 env[6] = "PATH="+System.getenv("PATH"); 647 env[3] = "PATH="+System.getenv("PATH"); 648 649 int next_index = 4; 650 String proxy_url = proxy_urls.getProperty("HTTP"); 651 if(proxy_url != null) { 652 env[next_index] = "http_proxy="+proxy_url; 653 next_index++; 654 } 655 proxy_url = proxy_urls.getProperty("HTTPS"); 656 if(proxy_url != null) { 657 env[next_index] = "https_proxy="+proxy_url; 658 next_index++; 659 } 660 proxy_url = proxy_urls.getProperty("FTP"); 661 if(proxy_url != null) { 662 env[next_index] = "ftp_proxy="+proxy_url; 663 next_index++; 664 } 645 665 646 666 prcs = new SafeProcess(cmd, env, null); 647 } 667 } 648 668 else if(Gatherer.isGsdlRemote && Gatherer.isDownloadEnabled && !Utility.isWindows()) { 649 669 // Not Windows, but running client with download panel -
main/trunk/gli/src/org/greenstone/gatherer/download/DownloadScrollPane.java
r31822 r31880 183 183 } 184 184 185 public void newDownloadJob(Download download, String mode, String proxy_url) {185 public void newDownloadJob(Download download, String mode, Properties proxy_urls) { 186 186 // Create the job and fill in the details from gatherer.config. 187 187 188 188 DebugStream.println("About to create a new job"); 189 189 190 DownloadJob new_job = new DownloadJob(download, Configuration.proxy_pass, Configuration.proxy_user, this, mode, proxy_url );190 DownloadJob new_job = new DownloadJob(download, Configuration.proxy_pass, Configuration.proxy_user, this, mode, proxy_urls); 191 191 // Tell it to run as soon as possible 192 192 -
main/trunk/gli/src/org/greenstone/gatherer/download/ServerInfoDialog.java
r31878 r31880 8 8 import java.io.*; 9 9 import java.util.ArrayList; 10 import java.util.Properties; 10 11 import org.greenstone.gatherer.cdm.Argument; 11 12 import org.greenstone.gatherer.Configuration; … … 27 28 private JDialog info_dialog; 28 29 private Download download; 29 private String proxy_url;30 private Properties proxy_urls; 30 31 31 public ServerInfoDialog(String url, String proxy_url, String mode, Download download) {32 public ServerInfoDialog(String url, Properties proxy_urls, String mode, Download download) { 32 33 super(); 33 34 this.url = url; 34 35 this.mode = mode; 35 36 this.download = download; 36 this.proxy_url = proxy_url;37 this.proxy_urls = proxy_urls; 37 38 this.info_dialog = this; 38 39 … … 106 107 try { 107 108 SafeProcess prcs = null; 108 109 if (proxy_url != null && !proxy_url.equals("")) { 110 // Specify proxies as environment variables 111 // Need to manually specify GSDLHOME and GSDLOS also 112 113 proxy_url = proxy_url.replaceAll("http://",""); 114 115 String [] env = new String[7]; 116 117 env[0] = "http_proxy=http://"+proxy_url; 118 env[1] = "https_proxy=http://"+proxy_url; // yes, HTTP protocol for https:// too 119 // see also https://wiki.archlinux.org/index.php/proxy_settings 120 env[2] = "ftp_proxy=ftp://"+proxy_url; 121 env[3] = "GSDLHOME=" + Configuration.gsdl_path; 122 env[4] = "GSDLOS=" + Gatherer.client_operating_system; 123 // teach it where the wgetrc file lives, in gs2build/bin/<os>: 124 env[5] = "WGETRC=" + LocalGreenstone.getBinOSDirectoryPath(Gatherer.client_operating_system)+"wgetrc"; 125 // Issue discovered on Windows: If PATH is not made available to perl, so that wget or something else needed by 126 // WgetDownload.pm's open3() call is not on the PATH, then the perl open() call to run wget fails. 127 // So make PATH available to get open3() working: 128 env[6] = "PATH="+System.getenv("PATH"); 129 130 prcs = new SafeProcess(command, env, null); 131 } 132 else { 133 // Will inherit the GLI's environment, with GSDLHOME and GSDLOS set 134 prcs = new SafeProcess(command); 109 110 if (proxy_urls.size() != 0) { 111 // Specify proxies as environment variables 112 // Need to manually specify GSDLHOME and GSDLOS also 113 String[] env = new String[4+proxy_urls.size()]; 114 115 env[0] = "GSDLHOME=" + Configuration.gsdl_path; 116 env[1] = "GSDLOS=" + Gatherer.client_operating_system; 117 // teach it where the wgetrc file lives, in gs2build/bin/<os>: 118 env[2] = "WGETRC=" + LocalGreenstone.getBinOSDirectoryPath(Gatherer.client_operating_system)+"wgetrc"; 119 // Issue discovered on Windows: If PATH is not made available to perl, so that wget or something else needed by 120 // WgetDownload.pm's open3() call is not on the PATH, then the perl open() call to run wget fails. 121 // So make PATH available to get open3() working: 122 env[3] = "PATH="+System.getenv("PATH"); 123 124 int next_index = 4; 125 String proxy_url = proxy_urls.getProperty("HTTP"); 126 if(proxy_url != null) { 127 env[next_index] = "http_proxy="+proxy_url; 128 next_index++; 135 129 } 130 proxy_url = proxy_urls.getProperty("HTTPS"); 131 if(proxy_url != null) { 132 env[next_index] = "https_proxy="+proxy_url; 133 next_index++; 134 } 135 proxy_url = proxy_urls.getProperty("FTP"); 136 if(proxy_url != null) { 137 env[next_index] = "ftp_proxy="+proxy_url; 138 next_index++; 139 } 140 141 prcs = new SafeProcess(command, env, null); 142 } else { 143 // Will inherit the GLI's environment, with GSDLHOME and GSDLOS set 144 prcs = new SafeProcess(command); 145 } 136 146 137 147 // special processing of Process' stderr stream: -
main/trunk/gli/src/org/greenstone/gatherer/gui/DownloadPane.java
r31877 r31880 91 91 private String mode = null; 92 92 private TreePath previous_path; 93 private String proxy_url = "";93 private Properties proxy_urls = new Properties(); // proxy_urls for each of HTTP, HTTPS, FTP 94 94 private Proxy proxyObject = null; 95 95 … … 601 601 } 602 602 603 getter.newDownloadJob((Download)download_map.get(mode) ,mode,proxy_url );603 getter.newDownloadJob((Download)download_map.get(mode) ,mode,proxy_urls); 604 604 } 605 605 } … … 723 723 } 724 724 725 // TODO: Still need to read up on and test how to set wget proxy on windows 726 // Need to be on a windows machine that requires proxy, and get wget to work on cmdline 727 // If that works, then need to check https URLS also work. 728 // See https://superuser.com/questions/526710/how-to-set-http-proxy-address-for-wget-under-windows 729 private boolean checkProxy(){ 725 726 // SOME READING: 727 // https://superuser.com/questions/526710/how-to-set-http-proxy-address-for-wget-under-windows 728 // https://arstechnica.com/civis/viewtopic.php?f=10&t=1281165 729 // "http or https to an https proxy?" 730 // About "CONNECT": https://daniel.haxx.se/docs/sshproxy.html 731 // "You need an SSH client that can issue CONNECT requests through the company HTTP proxy." Seems to imply http? Also uses it for ftp. 732 // https://forum.ivorde.com/set-up-ftp-proxy-via-command-line-in-linux-freebsd-t19733.html sets ftp_proxy to a http url. 733 // So it's seems to be just whatever protocol the proxy server has. When the proxy supports all three protocols 734 // (apparently the common case as per page below describing firefox prefs), then wiki.archlinux sets all three ftp_proxy/http_proxy/https_proxy to the same. 735 // See https://forums.freebsd.org/threads/57378/ 736 // "I believe that ftp(1) only uses HTTP-type proxies for fetching URLs. I.e. you can't do traditional open->cd->get interactive style of FTP with it via a HTTP proxy. If you do something like ftp ftp://ftp.example.com/path/file, it should work with your proxy setup. For traditional interactive FTP, you need to be directly talking to the remote server or using the less common FTP proxy/gate functionality." 737 // https://wiki.archlinux.org/index.php/Proxy_settings 738 // This does https_proxy = http_proxy, and explicitly prefixes "https://" to http_proxy. 739 // https://www.howtogeek.com/293213/how-to-configure-a-proxy-server-in-firefox/ 740 /* Youâll usually want to click the âUse the proxy server for all protocolsâ option. Firefox will also use your HTTP proxy server for SSL-encrypted HTTPS connections and File Transfer Protocol (FTP) connections. 741 Uncheck this box if you want to enter separate proxy servers for HTTP, HTTPS, and FTP connections. This isnât common. 742 If youâre configuring a SOCKS proxy, leave the HTTP Proxy, SSL Proxy, and FTP Proxy boxes empty. Enter the address of the SOCKS proxy into the âSOCKS Hostâ and its port into the âPortâ box. 743 */ 744 private boolean checkProxy(){ 745 746 proxy_urls.clear(); 747 748 Download current_download = (Download)download_map.get(mode); 749 750 Argument arg = current_download.getArgument("proxy_on"); 751 752 if (arg == null) return true; 753 754 // Determine if we have to use a proxy. 755 if(Configuration.get("general.use_proxy", true)) { 756 757 boolean http_proxy_set = setProxyURLFor("HTTP"); 758 boolean https_proxy_set = setProxyURLFor("HTTPS"); 759 boolean ftp_proxy_set = setProxyURLFor("FTP"); 760 761 if(proxy_urls.size() == 0 || 762 (!http_proxy_set && !https_proxy_set && !ftp_proxy_set)) { 763 764 // if checkProxy() failed for all protocols 765 // OR if none of the proxies were setup by user, then turn off proxying 766 arg = current_download.getArgument("proxy_on"); 767 arg.setValue("false"); 768 arg.setAssigned(false); 769 proxy_urls.clear(); 770 return false; 771 } else { // proxy details have been successfully set for at least one proxy protocol 772 return true; 773 } 774 775 } else { // if proxy_on was off 776 // unset proxy_on argument too 777 arg = current_download.getArgument("proxy_on"); 778 arg.setValue("false"); 779 arg.setAssigned(false); 780 } 781 782 return true; 783 } 784 785 private boolean setProxyURLFor(String protocol) { 786 String proxy_host = Configuration.getString("general."+protocol+"_proxy_host", true); 787 if(proxy_host.equals("")) { // no proxy details for this protocol 788 ///System.err.println("### general."+protocol+"proxy_host was empty"); 789 return true; 790 } 791 792 String proxy_port = Configuration.getString("general."+protocol+"_proxy_port", true); 793 // Find out whether the user has already authenticated themselves 794 795 // remove the protocol prefix from proxy_host, and store it 796 String proxy_protocol = ""; 797 int proxy_protocol_index = proxy_host.indexOf("://"); 798 if(proxy_protocol_index != -1) { 799 proxy_protocol_index += "://".length(); 800 proxy_protocol = proxy_host.substring(0, proxy_protocol_index); 801 proxy_host = proxy_host.substring(proxy_protocol_index); 802 } else { // no explicit protocol for proxy host specified, 803 // then set explicit protocol to be the same as the protocol param: http|https|ftp 804 proxy_protocol = protocol.toLowerCase()+"://"; 805 } 806 807 String user_pass = ""; 808 String address = proxy_host + ":" + proxy_port; 809 810 int count = 0; 811 // Only for wget, need to avoid a second automatic authentication popup (first asks 812 // the proxy authentication for wget, and the second will ask the same for the realm) 813 // Once the authentication has been reused, it will set the GAuthenticator state back to REGULAR 814 GAuthenticator.setMode(GAuthenticator.DOWNLOAD); 815 while(count < 3 && (user_pass = (String) GAuthenticator.authentications.get(address)) == null) { 816 Authenticator.requestPasswordAuthentication(proxy_host, null, Integer.parseInt(proxy_port), "http://", Dictionary.get("WGet.Prompt"), "HTTP"); 817 count++; 818 } 819 if(count >= 3) { 820 return false; 821 } 822 823 // https://askubuntu.com/questions/664777/systemwide-proxy-settings-in-ubuntu 824 // http://www.rgagnon.com/javadetails/java-0085.html 825 // how-do-i-make-httpurlconnection-use-a-proxy 826 // https://stackoverflow.com/questions/8030908/how-to-check-if-proxy-is-working-in-java 827 828 //proxyObject = new Proxy(Proxy.Type.HTTP, new InetSocketAddress(proxy_host, Integer.parseInt(proxy_port))); // proxyObject only used by getRedirectURL(), which we're no longer calling 829 830 Download current_download = (Download)download_map.get(mode); 831 Argument arg = current_download.getArgument("proxy_on"); 832 833 if(user_pass.indexOf("@") != -1) { 834 835 arg.setValue("true"); // proxy_on argument 836 arg.setAssigned(true); 837 838 arg = current_download.getArgument(protocol.toLowerCase()+"_proxy_host"); 839 arg.setValue(proxy_host); 840 arg.setAssigned(true); 841 842 arg = current_download.getArgument(protocol.toLowerCase()+"_proxy_port"); 843 arg.setValue(proxy_port); 844 arg.setAssigned(true); 845 846 // Write the use proxy command - we don't do this anymore, instead we set environment 847 // variables as these do work for windows after all (Aug 2017). Hopefully these can't 848 // be spied on like the following can (using ps/task manager. If going back to the 849 // following, be aware: can't add protocol+user_name and protocol+user_password as 850 // accepted parameters in WgetDownload.pm for HTTP, HTTPS and FTP protocols. Only 851 // one set of username and password can be set for wget's --proxy-user and 852 // --proxy-password flags. No separate flags for each protocol. 853 /*if (Utility.isWindows()) { 854 855 arg = current_download.getArgument("user_name"); 856 arg.setValue(user_pass.substring(0, user_pass.indexOf("@"))); 857 arg.setAssigned(true); 858 859 arg = current_download.getArgument("user_password"); 860 arg.setValue(user_pass.substring(user_pass.indexOf("@") + 1)); 861 arg.setAssigned(true); 862 } 863 864 else{*/ 865 String user_name = user_pass.substring(0, user_pass.indexOf("@")); 866 String user_pwd = user_pass.substring(user_pass.indexOf("@") + 1); 867 /*}*/ 868 869 // construct proxy_url and prefix the stored proxy protocol to it 870 String proxy_url = proxy_protocol+user_name+":"+user_pwd+"@"+proxy_host+":"+proxy_port+"/"; 871 proxy_urls.setProperty(protocol, proxy_url); 872 return true; 873 } 874 else{ 875 return false; 876 } 877 } 878 879 880 private boolean old_checkProxy(){ 730 881 731 proxy_url = null;732 882 String proxy_url = null; // ORIGINALLY A MEMBER VAR 883 733 884 Download current_download = (Download)download_map.get(mode); 734 885 … … 860 1011 } 861 1012 862 server_info = new ServerInfoDialog(str_url ,proxy_url , mode,(Download)download_map.get(mode));1013 server_info = new ServerInfoDialog(str_url ,proxy_urls, mode,(Download)download_map.get(mode)); 863 1014 864 1015 } -
main/trunk/gli/src/org/greenstone/gatherer/gui/Preferences.java
r31861 r31880 56 56 extends ModalDialog 57 57 { 58 static final public String HTTP = "HTTP"; 59 static final public String HTTPS = "HTTPS"; 60 static final public String FTP = "FTP"; 61 58 62 static final public String CONNECTION_PREFS = "connection"; 59 63 static final public String GENERAL_PREFS = "general"; … … 86 90 private JRadioButton expert_mode_radio_button; 87 91 private JRadioButton librarian_mode_radio_button; 88 private JSpinner proxy_port_field; 92 private JSpinner http_proxy_port_field; 93 private JSpinner https_proxy_port_field; 94 private JSpinner ftp_proxy_port_field; 89 95 private JTabbedPane tab_pane; 90 96 private JTextArea mode_description_textarea; … … 93 99 private JTextField library_path_field; 94 100 private JTextField program_field; 95 private JTextField proxy_host_field; 101 private JTextField http_proxy_host_field; 102 private JTextField https_proxy_host_field; 103 private JTextField ftp_proxy_host_field; 96 104 private JTextField collect_dir_field; 97 105 … … 337 345 use_proxy_checkbox.setPreferredSize(ROW_SIZE); 338 346 339 JPanel proxy_host_pane = new JPanel();340 proxy_host_pane.setComponentOrientation(Dictionary.getOrientation());341 proxy_host_pane.setPreferredSize(ROW_SIZE);342 343 JLabel proxy_host_label = new JLabel(Dictionary.get("Preferences.Connection.Proxy_Host"));344 proxy_host_label.setComponentOrientation(Dictionary.getOrientation());345 proxy_host_label.setPreferredSize(LABEL_SIZE);346 347 proxy_host_field = new JTextField(Configuration.getString("general.proxy_host", true));348 proxy_host_field.setEnabled(currently_enabled);349 proxy_host_field.setToolTipText(Dictionary.get("Preferences.Connection.Proxy_Host_Tooltip"));350 proxy_host_field.setComponentOrientation(Dictionary.getOrientation());351 352 JPanel proxy_port_pane = new JPanel();353 proxy_port_pane.setComponentOrientation(Dictionary.getOrientation());354 proxy_port_pane.setPreferredSize(ROW_SIZE);355 356 JLabel proxy_port_label = new JLabel(Dictionary.get("Preferences.Connection.Proxy_Port"));357 proxy_port_label.setPreferredSize(LABEL_SIZE);358 proxy_port_label.setComponentOrientation(Dictionary.getOrientation());359 360 String port_value = Configuration.getString("general.proxy_port", true);361 if(port_value.length() > 0) {362 proxy_port_field = new JSpinner(new SpinnerNumberModel((new Integer(port_value)).intValue(), 0, 65535, 1));363 }364 else {365 proxy_port_field = new JSpinner(new SpinnerNumberModel(0, 0, 65535, 1));366 }367 proxy_port_field.setEnabled(currently_enabled);368 proxy_port_field.setToolTipText(Dictionary.get("Preferences.Connection.Proxy_Port_Tooltip"));369 347 370 348 // Connection … … 405 383 collect_dir_pane.add(chdir_button, BorderLayout.LINE_END); 406 384 407 proxy_host_pane.setLayout(new BorderLayout());408 proxy_host_pane.add(proxy_host_label, BorderLayout.LINE_START);409 proxy_host_pane.add(proxy_host_field, BorderLayout.CENTER);410 411 proxy_port_pane.setLayout(new BorderLayout());412 proxy_port_pane.add(proxy_port_label, BorderLayout.LINE_START);413 proxy_port_pane.add(proxy_port_field, BorderLayout.CENTER);414 385 415 386 connection_pane.setBorder(BorderFactory.createEmptyBorder(5,5,5,5)); 416 connection_pane.setLayout(new GridLayout( 9,1,0,2));387 connection_pane.setLayout(new GridLayout(10,1,0,2)); 417 388 connection_pane.add(program_pane); 418 389 connection_pane.add(library_path_pane); … … 428 399 connection_pane.add(no_check_certificate_checkbox); 429 400 connection_pane.add(use_proxy_checkbox); 430 connection_pane.add(proxy_host_pane); 431 connection_pane.add(proxy_port_pane); 401 402 // set up the proxy host and port fields for each of http, https and ftp 403 setupProxyHostPane(HTTP, connection_pane, currently_enabled, http_proxy_host_field, http_proxy_port_field); 404 setupProxyHostPane(HTTPS, connection_pane, currently_enabled, https_proxy_host_field, https_proxy_port_field); 405 setupProxyHostPane(FTP, connection_pane, currently_enabled, ftp_proxy_host_field, ftp_proxy_port_field); 432 406 433 407 return connection_pane; … … 570 544 return general_pane; 571 545 } 546 547 private void setupProxyHostPane(String protocol, JPanel connection_pane, boolean isEnabled, 548 JTextField proxy_host_field, JSpinner proxy_port_field) 549 { 550 final Dimension WIDER_LABEL_SIZE = new Dimension(180, 25); 551 final Dimension NARROWER_LABEL_SIZE = new Dimension(60, 25); 552 final Dimension WIDER_ROW_SIZE = new Dimension(480, 25); 553 final Dimension NARROWER_ROW_SIZE = new Dimension(120, 25); 554 555 JPanel proxy_host_pane = new JPanel(); 556 proxy_host_pane.setComponentOrientation(Dictionary.getOrientation()); 557 proxy_host_pane.setPreferredSize(WIDER_ROW_SIZE); 558 559 JLabel proxy_host_label = new JLabel(Dictionary.get("Preferences.Connection."+protocol+"_Proxy_Host")); 560 proxy_host_label.setComponentOrientation(Dictionary.getOrientation()); 561 proxy_host_label.setPreferredSize(WIDER_LABEL_SIZE); 562 563 proxy_host_field = new JTextField(Configuration.getString("general."+protocol+"_proxy_host", true)); 564 proxy_host_field.setEnabled(isEnabled); 565 proxy_host_field.setToolTipText(Dictionary.get("Preferences.Connection."+protocol+"_Proxy_Host_Tooltip")); 566 proxy_host_field.setComponentOrientation(Dictionary.getOrientation()); 567 568 JPanel proxy_port_pane = new JPanel(); 569 proxy_port_pane.setComponentOrientation(Dictionary.getOrientation()); 570 proxy_port_pane.setPreferredSize(NARROWER_ROW_SIZE); 571 572 JLabel proxy_port_label = new JLabel(Dictionary.get("Preferences.Connection.Proxy_Port")); 573 proxy_port_label.setPreferredSize(NARROWER_LABEL_SIZE); 574 proxy_port_label.setComponentOrientation(Dictionary.getOrientation()); 575 576 String port_value = Configuration.getString("general."+protocol+"_proxy_port", true); 577 if(port_value.length() > 0) { 578 proxy_port_field = new JSpinner(new SpinnerNumberModel((new Integer(port_value)).intValue(), 0, 65535, 1)); 579 } 580 else { 581 proxy_port_field = new JSpinner(new SpinnerNumberModel(0, 0, 65535, 1)); 582 } 583 proxy_port_field.setEnabled(isEnabled); 584 proxy_port_field.setToolTipText(Dictionary.get("Preferences.Connection."+protocol+"_Proxy_Port_Tooltip")); 585 586 587 // Since the actual object member vars were null when this method is called 588 // need to ensure they are assigned the correct value now, else those refs will remain null 589 if(protocol.equals(HTTP)) { 590 http_proxy_host_field = proxy_host_field; 591 http_proxy_port_field = proxy_port_field; 592 } else if (protocol.equals(HTTPS)) { 593 https_proxy_host_field = proxy_host_field; 594 https_proxy_port_field = proxy_port_field; 595 } else if(protocol.equals(FTP)) { 596 ftp_proxy_host_field = proxy_host_field; 597 ftp_proxy_port_field = proxy_port_field; 598 } 599 600 proxy_host_pane.setLayout(new BorderLayout()); 601 proxy_host_pane.add(proxy_host_label, BorderLayout.LINE_START); 602 proxy_host_pane.add(proxy_host_field, BorderLayout.CENTER); 603 604 proxy_port_pane.setLayout(new BorderLayout()); 605 proxy_port_pane.add(proxy_port_label, BorderLayout.LINE_START); 606 proxy_port_pane.add(proxy_port_field, BorderLayout.CENTER); 607 608 //connection_pane.add(proxy_host_pane); 609 //connection_pane.add(proxy_port_pane); 610 611 JPanel proxy_panel = new JPanel(); 612 proxy_panel.setLayout(new BorderLayout()); 613 proxy_panel.add(proxy_host_pane, BorderLayout.WEST); 614 proxy_panel.add(proxy_port_pane, BorderLayout.CENTER); 615 616 connection_pane.add(proxy_panel); 617 } 618 572 619 573 620 /** Generate the controls for altering the detail mode. … … 786 833 this.close = close; 787 834 } 835 836 private void setProxyHostForProtocol(String protocol, 837 JTextField proxy_host_field, 838 JSpinner proxy_port_field) 839 { 840 Configuration.setString("general."+protocol+"_proxy_host", true, proxy_host_field.getText()); 841 Configuration.setString("general."+protocol+"_proxy_port", true, proxy_port_field.getValue() + ""); 842 } 843 788 844 public void actionPerformed(ActionEvent event) 789 845 { … … 876 932 877 933 Configuration.set("general.use_proxy", true, use_proxy_checkbox.isSelected()); 878 Configuration.setString("general.proxy_host", true, proxy_host_field.getText()); 879 Configuration.setString("general.proxy_port", true, proxy_port_field.getValue() + ""); 934 setProxyHostForProtocol(HTTP, http_proxy_host_field, http_proxy_port_field); 935 setProxyHostForProtocol(HTTPS, https_proxy_host_field, https_proxy_port_field); 936 setProxyHostForProtocol(FTP, ftp_proxy_host_field, ftp_proxy_port_field); 880 937 Gatherer.setProxy(); 881 938 … … 975 1032 976 1033 // If proxy is on but proxy details are incomplete, then can't continue 977 if (use_proxy_checkbox.isSelected() && proxy_host_field.getText().equals("")) { 1034 if (use_proxy_checkbox.isSelected() 1035 && http_proxy_host_field.getText().equals("") 1036 && https_proxy_host_field.getText().equals("") 1037 && ftp_proxy_host_field.getText().equals("")) { 978 1038 JOptionPane.showMessageDialog(Gatherer.g_man, Dictionary.get("Preferences.Connection.Proxy_Host_Missing"), 979 1039 Dictionary.get("General.Error"), JOptionPane.ERROR_MESSAGE); … … 1144 1204 Configuration.set("general.use_proxy", true, enabled); 1145 1205 // Fortunately this is already driven by the event thread. 1146 proxy_host_field.setEnabled(enabled); 1147 proxy_port_field.setEnabled(enabled); 1206 http_proxy_host_field.setEnabled(enabled); 1207 http_proxy_port_field.setEnabled(enabled); 1208 https_proxy_host_field.setEnabled(enabled); 1209 https_proxy_port_field.setEnabled(enabled); 1210 ftp_proxy_host_field.setEnabled(enabled); 1211 ftp_proxy_port_field.setEnabled(enabled); 1148 1212 } 1149 1213 } -
main/trunk/greenstone2/perllib/downloaders/WebDownload.pm
r31878 r31880 193 193 my $strBaseCMD = $strOptions." --tries=2 -q -O - \"$self->{'url'}\""; 194 194 195 #&util::print_env(STDERR, "https_proxy", "http_proxy", " HTTPS_PROXY", "HTTP_PROXY", "ftp_proxy", "FTP_PROXY");195 #&util::print_env(STDERR, "https_proxy", "http_proxy", "ftp_proxy"); 196 196 #&util::print_env(STDERR); 197 197 … … 201 201 202 202 print STDERR "Server information is unavailable.\n"; 203 204 #&util::print_env(STDERR, "https_proxy", "http_proxy"); 205 206 if ($self->{'proxy_on'} && $self->{'proxy_host'} && $self->{'proxy_port'}) { # if proxying set, the settings may be wrong 207 &gsprintf::gsprintf_multiline(STDERR, "{WebDownload.proxied_connect_failed_info}\n", $self->{'proxy_host'}, $self->{'proxy_port'}); 203 204 if ($self->{'proxy_on'}) { # if proxying set, the settings may be wrong 205 &gsprintf::gsprintf_multiline(STDERR, "{WebDownload.proxied_connect_failed_info}\n"); 206 207 if($self->{'http_proxy_host'} && defined $self->{'http_proxy_port'}) { 208 &gsprintf::gsprintf_multiline(STDERR, "{WebDownload.http_proxy_settings}\n", $self->{'http_proxy_host'}, $self->{'http_proxy_port'}); 209 } 210 if($self->{'https_proxy_host'} && defined $self->{'https_proxy_port'}) { 211 &gsprintf::gsprintf_multiline(STDERR, "{WebDownload.https_proxy_settings}\n", $self->{'https_proxy_host'}, $self->{'https_proxy_port'}); 212 } 213 if($self->{'ftp_proxy_host'} && defined $self->{'ftp_proxy_port'}) { 214 &gsprintf::gsprintf_multiline(STDERR, "{WebDownload.ftp_proxy_settings}\n", $self->{'ftp_proxy_host'}, $self->{'ftp_proxy_port'}); 215 } 208 216 } else { # else no proxy set, the user may need proxy settings 209 217 &gsprintf::gsprintf_multiline(STDERR, "{WebDownload.proxyless_connect_failed_info}\n"); -
main/trunk/greenstone2/perllib/downloaders/WgetDownload.pm
r31878 r31880 51 51 'reqd' => "no", 52 52 'hiddengli' => "yes"}, 53 { 'name' => "proxy_host", 54 'desc' => "{WgetDownload.proxy_host}", 55 'type' => "string", 56 'reqd' => "no", 57 'hiddengli' => "yes"}, 58 { 'name' => "proxy_port", 59 'desc' => "{WgetDownload.proxy_port}", 53 { 'name' => "http_proxy_host", 54 'desc' => "{WgetDownload.http_proxy_host}", 55 'type' => "string", 56 'reqd' => "no", 57 'hiddengli' => "yes"}, 58 { 'name' => "http_proxy_port", 59 'desc' => "{WgetDownload.http_proxy_port}", 60 'type' => "string", 61 'reqd' => "no", 62 'hiddengli' => "yes"}, 63 { 'name' => "https_proxy_host", 64 'desc' => "{WgetDownload.https_proxy_host}", 65 'type' => "string", 66 'reqd' => "no", 67 'hiddengli' => "yes"}, 68 { 'name' => "https_proxy_port", 69 'desc' => "{WgetDownload.https_proxy_port}", 70 'type' => "string", 71 'reqd' => "no", 72 'hiddengli' => "yes"}, 73 { 'name' => "ftp_proxy_host", 74 'desc' => "{WgetDownload.ftp_proxy_host}", 75 'type' => "string", 76 'reqd' => "no", 77 'hiddengli' => "yes"}, 78 { 'name' => "ftp_proxy_port", 79 'desc' => "{WgetDownload.ftp_proxy_port}", 60 80 'type' => "string", 61 81 'reqd' => "no", 62 82 'hiddengli' => "yes"}, 63 83 { 'name' => "user_name", 64 'desc' => "{WgetDownload.user_name}", 84 'desc' => "{WgetDownload.user_name}", 65 85 'type' => "string", 66 86 'reqd' => "no", 67 87 'hiddengli' => "yes"}, 68 88 { 'name' => "user_password", 69 'desc' => "{WgetDownload.user_password}", 89 'desc' => "{WgetDownload.user_password}", 70 90 'type' => "string", 71 91 'reqd' => "no", … … 171 191 my ($self) = @_; 172 192 my $strOptions = ""; 173 174 if ($self->{'proxy_on'} && $self->{'proxy_host'} && $self->{'proxy_port'}) 193 194 if($self->{'http_proxy_host'} && $self->{'http_proxy_port'}) { 195 $strOptions .= " -e http_proxy=$self->{'http_proxy_host'}:$self->{'http_proxy_port'} "; 196 } 197 if($self->{'https_proxy_host'} && $self->{'https_proxy_port'}) { 198 $strOptions .= " -e https_proxy=$self->{'https_proxy_host'}:$self->{'https_proxy_port'} "; 199 } 200 if($self->{'ftp_proxy_host'} && $self->{'ftp_proxy_port'}) { 201 $strOptions .= " -e ftp_proxy=$self->{'ftp_proxy_host'}:$self->{'ftp_proxy_port'} "; 202 } 203 204 # For wget, there is only one set pair of proxy-user and proxy-passwd, so wget seems to assume 205 # that all 3 proxy protocols (http|https|ftp) will use the same username and pwd combination? 206 # Note that this only matters when passing the proxying details as flags to wget, not when 207 # the proxies are setup as environment variables. 208 if ($self->{'user_name'} && $self->{'user_password'}) 175 209 { 176 $strOptions .= " -e https_proxy=$self->{'proxy_host'}:$self->{'proxy_port'} "; 177 $strOptions .= " -e http_proxy=$self->{'proxy_host'}:$self->{'proxy_port'} "; 178 179 if ($self->{'user_name'} && $self->{'user_password'}) 180 { 181 $strOptions .= "--proxy-user=$self->{'user_name'}"." --proxy-passwd=$self->{'user_password'}"; 182 } 183 } 184 185 if ($self->{'proxy_on'}) { 186 $strOptions .= " --proxy "; 187 } 210 $strOptions .= "--proxy-user=$self->{'user_name'}"." --proxy-passwd=$self->{'user_password'}"; 211 # how is "--proxy-passwd" instead of "--proxy-password" even working???? 212 # see https://www.gnu.org/software/wget/manual/html_node/Proxies.html 213 # and https://www.gnu.org/software/wget/manual/wget.html 214 # Not touching this, in case the manual is simply wrong. Since our code works in 215 # practice (when we were still using wget proxy username/pwd flags for windows). 216 } 188 217 189 218 return $strOptions; … … 202 231 # http://www.perlmonks.org/?node=what%20is%20true%20and%20false%20in%20Perl%3F 203 232 204 if (!$ENV{'http_proxy'} && !$ENV{'https_proxy'}) { 205 $strOptions .= $self->addProxySettingsAsWgetFlags(); 206 } # else wget will use proxy settings in environment, assume enough settings have been provided 233 if ($self->{'proxy_on'}) { 234 if(!$ENV{'http_proxy'} && !$ENV{'https_proxy'} && !$ENV{'ftp_proxy'}) { 235 $strOptions .= $self->addProxySettingsAsWgetFlags(); 236 } # else wget will use proxy settings in environment, assume enough settings have been provided 237 # either way, we're using the proxy 238 $strOptions .= " --proxy "; 239 } 207 240 208 241 if($self->{'no_check_certificate'}) { # URL may be http that gets redirected to https, so if no_check_certificate is on, turn it on even if URL is http -
main/trunk/greenstone2/perllib/strings.properties
r31875 r31880 1336 1336 WebDownload.html_only:Download only HTML files, and ignore associated files e.g images and stylesheets 1337 1337 WebDownload.html_only_disp:Only HTML files 1338 WebDownload.proxied_connect_failed_info:Current proxy settings are:\n- host=%s\n- port=%s 1338 WebDownload.proxied_connect_failed_info:Current proxy settings are: 1339 WebDownload.http_proxy_settings:- HTTP host=%s : port=%s 1340 WebDownload.https_proxy_settings:- HTTPS host=%s : port=%s 1341 WebDownload.ftp_proxy_settings:- FTP host=%s : port=%s 1339 1342 WebDownload.proxyless_connect_failed_info:- The external server might not be responding\n- or you might need to switch on proxy settings 1340 1343 WebDownload.connect_failed_info:- or try ticking No Certificate Checking (affects 'https' URLs)\nin File > Preferences > Connection … … 1342 1345 WgetDownload.desc: Base class that handles calls to wget 1343 1346 WgetDownload.proxy_on:Proxy on 1344 WgetDownload.proxy_host:Proxy host 1345 WgetDownload.proxy_port:Proxy port 1347 WgetDownload.http_proxy_host:HTTP proxy host 1348 WgetDownload.http_proxy_port:HTTP proxy port 1349 WgetDownload.https_proxy_host:HTTPS proxy host 1350 WgetDownload.https_proxy_port:HTTPS proxy port 1351 WgetDownload.ftp_proxy_host:FTP proxy host 1352 WgetDownload.ftp_proxy_port:FTP proxy port 1346 1353 WgetDownload.user_name:User name 1347 1354 WgetDownload.user_password:User password
Note:
See TracChangeset
for help on using the changeset viewer.