From: <no...@so...> - 2001-08-24 17:57:01
|
Patches item #420060, was opened at 2001-04-29 21:13 You can respond by visiting: http://sourceforge.net/tracker/?func=detail&atid=310894&aid=420060&group_id=10894 Category: 28. http Package Group: None Status: Open Resolution: None Priority: 5 Submitted By: Bud Beacham (bbeacham) >Assigned to: Jeffrey Hobbs (hobbs) Summary: Add -address option to http::geturl Initial Comment: Issue: Linux allows multiple IP addresses to be bound to a single NIC card. This gives someone the ability to write applications that appear to generate traffic from multiple clients from a single PC. Problem: The TCL library function HTTP::GETURL only uses the first IP bound to the computer. Solution: HTTP::GETURL uses the TCL socket command to setup the connection. Socket has an option, -myaddr, that allows an IP address to be passed to the socket. This will be the IP addresses used for the conection. I modified HTTP::GETURL to allow an IP address to be passed to it. It then gets passed to socket. Now I can generate HTTPS GETs from a number of unique clients while using a single PC. Note: After I posted this on USENET someone showed how to use http::register to set the system IP to a differant IP and then that would be the IP used by http::geturl. However, that is not as clean and simple as having an address option. Also it creates a lot of CPU overhead having to call it each time you loop through a range of IP addresses. Modified TCL 8.3 ...../lib/tcl8.3/http2.3/http.tcl proc http::geturl { url args } { ...deleted stuff.... # Process command options. array set state { -blocksize 8192 -queryblocksize 8192 -validate 0 -headers {} -timeout 0 -type application/x-www-form-urlencoded -queryprogress {} -address {} ;# added to allow addresses state header meta {} currentsize 0 totalsize 0 querylength 0 queryoffset 0 type text/html body {} status "" http "" } set options {-blocksize -channel -command -handler - headers \ -progress -query -queryblocksize - querychannel -queryprogress\ -validate -timeout -type -address} ...deleted stuff...... # this is where the enhancement patch executes # I am unsure if the first "if" needs to be modified or not if {[info exists phost] && [string length $phost]} { set srvurl $url set conStat [catch {eval $defcmd $async {$phost $pport}} s] } elseif {$state(-address) == ""} { ;# changed else to elseif - system default address, option not used set conStat [catch {eval $defcmd $async {$host $port}} s] } else { ;# added else, set statement, and - myaddr $state(-address) set conStat [catch {eval $defcmd $async {- myaddr $state(-address) $host $port}} s] } Example: set result [catch {http::geturl $url -timeout $TIMEOUT \ -headers "Cookie $cookie($localIp,$url)" \ -address $localIp} token] Documentation: ::http::geturl url ?options? The ::http::geturl command is the main procedure in the package. The -query option causes a POST operation and the -validate option causes a HEAD operation; otherwise, a GET operation is performed. The ::http::geturl command returns a token value that can be used to get information about the transaction. See the STATE ARRAY and ERRORS section for details. The ::http::geturl command blocks until the operation completes, unless the -command option specifies a callback that is invoked when the HTTP transaction completes. ::http::geturl takes several options: -address addr (borrowed from the -myaddr description in the socket documentation and added this part: "or multiple addresses bound to a network interface") Addr gives the domain-style name or numerical IP address of the client-side network interface to use for the connection. This option may be useful if the client machine has multiple network interfaces, or multiple addresses bound to a network interface. If the option is omitted then the client-side interface will be chosen by the system software. ---------------------------------------------------------------------- >Comment By: Andreas Kupries (andreas_kupries) Date: 2001-08-24 10:56 Message: Logged In: YES user_id=75003 Seems not, given the quietness. ---------------------------------------------------------------------- Comment By: Jeffrey Hobbs (hobbs) Date: 2001-05-21 16:32 Message: Logged In: YES user_id=72656 This is a good idea, but can we get it reduced to a simple patch against the current sources for easier analysis and inclusion? ---------------------------------------------------------------------- You can respond by visiting: http://sourceforge.net/tracker/?func=detail&atid=310894&aid=420060&group_id=10894 |