Changeset 7687


Ignore:
Timestamp:
2004-07-01T14:55:18+12:00 (20 years ago)
Author:
kjdon
Message:

proxy host, port, user and password are now set in an envornment variable rather than as args to the wget command - hopefully can't be spied on?

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gli/src/org/greenstone/gatherer/collection/DownloadJob.java

    r7677 r7687  
    223223    }
    224224
     225    String proxy_url = "";
    225226    // Determine if we have to use a proxy.
    226227    if(Gatherer.config.get("general.use_proxy", true)) {
     
    240241        }
    241242        if(user_pass.indexOf("@") != -1) {
    242         // Write the use proxy command
    243         command = command + "-e httpproxy=" + proxy_host + ":" + proxy_port + "/ --proxy-user=" + user_pass.substring(0, user_pass.indexOf("@")) + " --proxy-passwd=" + user_pass.substring(user_pass.indexOf("@") + 1) + " -Y on ";
    244 
     243        String user_name = user_pass.substring(0, user_pass.indexOf("@"));
     244        String user_pwd = user_pass.substring(user_pass.indexOf("@") + 1);
     245        proxy_url = user_name+":"+user_pwd+"@"+proxy_host+":"+proxy_port+"/";
     246        // Write the use proxy command - we don't do this anymore, instead we set environment variables - hopefully these can't be spied on like the follwoing can (using ps)
     247        //command = command + "-e httpproxy=" + proxy_host + ":" + proxy_port + "/ --proxy-user=" + user_pass.substring(0, user_pass.indexOf("@")) + " --proxy-passwd=" + user_pass.substring(user_pass.indexOf("@") + 1) + " -Y on ";
     248       
    245249        }
    246250        else {
     
    249253    }
    250254       
    251     // The user can either choose to mirror all of the page requisites...
     255    // The user can choose to mirror all of the page requisites...
    252256    if(page_requisites) {
    253257        command = command + "-p ";
    254258    }
    255259
     260    // Download files from other hosts
    256261    if(other_hosts) {
    257262        command = command + "-H ";
     
    276281        Gatherer.println("Cmd: " + command);
    277282        Runtime rt = Runtime.getRuntime();
    278         Process prcs = rt.exec(command, null, dest_file);
     283        String [] env = null;
     284        if (!proxy_url.equals("")) {
     285        env = new String[2];
     286        env[0] = "http_proxy=http://"+proxy_url;
     287        env[1] = "ftp_proxy=ftp://"+proxy_url;
     288        }
     289        Process prcs = rt.exec(command, env, dest_file);
    279290        InputStreamReader isr = new InputStreamReader(prcs.getErrorStream());
    280291        BufferedReader br = new BufferedReader(isr);
     
    367378    Gatherer.g_man.refreshWorkspaceTree(WorkspaceTree.DOWNLOADED_FILES_CHANGED);
    368379    }
    369 
     380   
     381   
    370382    /** The most important part of the DownloadJob class, this method is
    371383     * responsible for calling the WGet native methods used to
Note: See TracChangeset for help on using the changeset viewer.