Implemented proxy spec and useragent spoofing
This commit is contained in:
@@ -127,6 +127,23 @@ On success, tiipost.tcl will output a message that starts with "Success", in
|
||||
case of an error the line will start with "Error". The server-side description
|
||||
will follow this success or error status.
|
||||
|
||||
HTTP client configuration
|
||||
-------------------------
|
||||
For both fetching and posting, you can configure several values in the config
|
||||
file (config.txt in the script directory, the example is included in the repo)
|
||||
that will allow you to set HTTP proxy and override the user agent. As of now,
|
||||
the file is a Tcl dictionary (`key "value"`) and has the following fields:
|
||||
|
||||
* useragent: the user agent string to set for all HTTP requests
|
||||
* proxyhost: the HTTP proxy hostname to use (if empty or omitted, the scripts
|
||||
will connect directly)
|
||||
* proxyport: the HTTP port to use on the proxy (only effective if proxyhost is
|
||||
set to a non-empty string)
|
||||
|
||||
Any of the fields can be omitted, as well as the file itself.
|
||||
You can also use torsocks with any script invocation in order to fully cloak
|
||||
your originating IP address.
|
||||
|
||||
Message database format
|
||||
-----------------------
|
||||
The tiidb format is based upon the official ii/IDEC developer recommendations
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
useragent "curl/7.54.1"
|
||||
proxyhost ""
|
||||
proxyport 0
|
||||
+16
-1
@@ -294,8 +294,23 @@ set appdir [file dirname $scriptpath]
|
||||
if [string match *app-tiifetch $appdir] {
|
||||
set appdir [file normalize [file join $appdir ".." ".." ".." ]]
|
||||
}
|
||||
|
||||
set localdbdir [file join $appdir "tiidb"]
|
||||
|
||||
# populate general HTTP configuration
|
||||
set cfgfile [file join $appdir "config.txt"]
|
||||
if {[file exists $cfgfile]} {
|
||||
set cfg [readfile $cfgfile]
|
||||
if {[dict exists $cfg useragent]} {
|
||||
::http::config -useragent [dict get $cfg useragent]
|
||||
}
|
||||
if {[dict exists $cfg proxyhost]} {
|
||||
::http::config -proxyhost [dict get $cfg proxyhost]
|
||||
}
|
||||
if {[dict exists $cfg proxyport]} {
|
||||
::http::config -proxyport [dict get $cfg proxyport]
|
||||
}
|
||||
}
|
||||
|
||||
if {$argc > 0} {
|
||||
if {$argc > 2} {
|
||||
set localdbdir [lindex $argv 2]
|
||||
|
||||
+18
-10
@@ -57,19 +57,27 @@ set appdir [file dirname $scriptpath]
|
||||
if [string match *app-tiipost $appdir] {
|
||||
set appdir [file normalize [file join $appdir ".." ".." ".." ]]
|
||||
}
|
||||
# auth string mapping
|
||||
|
||||
# populate general HTTP configuration
|
||||
set cfgfile [file join $appdir "config.txt"]
|
||||
if {[file exists $cfgfile]} {
|
||||
set cfg [readfile $cfgfile]
|
||||
if {[dict exists $cfg useragent]} {
|
||||
::http::config -useragent [dict get $cfg useragent]
|
||||
}
|
||||
if {[dict exists $cfg proxyhost]} {
|
||||
::http::config -proxyhost [dict get $cfg proxyhost]
|
||||
}
|
||||
if {[dict exists $cfg proxyport]} {
|
||||
::http::config -proxyport [dict get $cfg proxyport]
|
||||
}
|
||||
}
|
||||
|
||||
# get auth string mapping
|
||||
set authmap ""
|
||||
set authfile [file join $appdir "auth.txt"]
|
||||
if {[file exists $authfile]} {
|
||||
set authdata [readfile $authfile]
|
||||
set authlist [split $authdata "\n"]
|
||||
foreach authline $authlist {
|
||||
set authline [string trim $authline]
|
||||
if {$authline ne ""} {
|
||||
set parts [split $authline " \t"]
|
||||
dict set authmap [string trim [lindex $parts 0]] [string trim [lindex $parts 1]]
|
||||
}
|
||||
}
|
||||
set authmap [readfile $authfile]
|
||||
}
|
||||
|
||||
if {$argc > 3} {
|
||||
|
||||
Reference in New Issue
Block a user