tii

Tcl-based suite for working with ii/idec protocol
git clone git://git.luxferre.top/tii.git
Log | Files | Refs | README

commit 2f04542cf6e90ab8f52d0a0dc8a4ec662b54511a
parent 374be3b9afff4eec6844b9c9f85f0891441ca1cd
Author: Luxferre <lux@ferre>
Date:   Fri,  1 Nov 2024 07:47:58 +0200

reflected the recent standard changes in the doc

Diffstat:
Mconfig.txt | 1+
Mii-doc.txt | 21++++++++++-----------
Mtiifetch.tcl | 12++++++++----
Mtiix.tcl | 4++++
4 files changed, 23 insertions(+), 15 deletions(-)

diff --git a/config.txt b/config.txt @@ -1,6 +1,7 @@ useragent "tii/current" proxyhost "" proxyport "0" +net_timeout 10000 tiix_font "Fira Code" tiix_fontsize "12" tiix_fgcolor "#eee" diff --git a/ii-doc.txt b/ii-doc.txt @@ -61,6 +61,11 @@ Response: newline-separated message ID list When a new message is posted to the echo, it gets appended to the end of the corresponding message ID list for this echo. +The message order in an echo does not always match the timestamp ordering; +it is fully up to the client on how to sort the messages internally. The +messages are only guaranteed to be saved by the server in the order they +arrive onto the server. + - Listing messages in any amount of echos - Request: GET /u/e/echo.1.name/echo.2.name/... @@ -77,7 +82,10 @@ msgid2fromecho2 ... In case of limited request, the offset can be negative. E.g. -10:10 means -requesting last 10 messages from the index. +requesting last 10 messages from the index. If the offset:limit pair is not +valid for a particular echo, all message IDs from this echo are returned. + +The same message ID ordering rule as for /e applies to /u/e as well. - Fetching a single message by its ID - @@ -90,6 +98,7 @@ Request: GET /u/m/msgid1/msgid2/... Response: newline-separated list of msgid:base64_msgtext Here, base64_msgtext is a Base64-encoded Node-to-Point Message (see below). +The standardized ID count limit is at most 40 messages per bundle. - Posting a message (via POST) - @@ -171,14 +180,4 @@ This algorithm must be implemented by every station to generate message IDs: 4. Replace all occurrences of + or - with A, and / or _ with z. 5. The result of these operations is your ii message ID. -Implementation notes --------------------- -* Most HTTP servers are configured to reject long GET lines, so tii passes a - limited amount of message IDs to the /u/m endpoints. This behaviour can be - configured in the stations.txt file. -* The message order in an echo does not always match the timestamp ordering; - it is fully up to the client on how to sort the messages internally. The - messages are only guaranteed to be saved by the server in the order they - arrive onto the server. - --- Luxferre --- diff --git a/tiifetch.tcl b/tiifetch.tcl @@ -78,8 +78,7 @@ proc url2dict {inputurl} { } proc reqresp {host port reqline is_tls encoding} { - global sock_response - set sock_net_timeout 5000 + global sock_response net_timeout set sock 0 if {$is_tls eq 1} { catch {set sock [::tls::socket -autoservername true -async $host $port]} @@ -109,7 +108,7 @@ proc reqresp {host port reqline is_tls encoding} { } set rcv_end_$sock 0 } - after $sock_net_timeout "global rcv_end_$sock; set rcv_end_$sock 1" + after $net_timeout "global rcv_end_$sock; set rcv_end_$sock 1" vwait rcv_end_$sock catch {close $sock} unset -nocomplain rcv_end_$sock @@ -118,6 +117,7 @@ proc reqresp {host port reqline is_tls encoding} { # file download helper proc getfile {url} { + global net_timeout set url [regsub -all {([^:])//} $url {\1/}] set urlparts [url2dict $url] set scheme [dict get $urlparts scheme] @@ -156,7 +156,7 @@ proc getfile {url} { https - http { set hs "" while {$hs eq ""} { - set hs [::http::geturl $url -binary 1 -keepalive 0 -timeout 10000] + set hs [::http::geturl $url -binary 1 -keepalive 0 -timeout $net_timeout] } if {[::http::ncode $hs] eq "200"} { return [::http::data $hs] @@ -369,6 +369,7 @@ set localdb [file join $appdir "tii.db"] # populate general HTTP configuration set cfgfile [file join $appdir "config.txt"] +set net_timeout 5000 if {[file exists $cfgfile]} { set cfg [readfile $cfgfile] if {[dict exists $cfg useragent]} { @@ -380,6 +381,9 @@ if {[file exists $cfgfile]} { if {[dict exists $cfg proxyport]} { ::http::config -proxyport [dict get $cfg proxyport] } + if {[dict exists $cfg net_timeout]} { + set net_timeout [dict get $cfg net_timeout] + } } if {$argc > 0} { diff --git a/tiix.tcl b/tiix.tcl @@ -29,6 +29,7 @@ set tiix_linkcolor blue set useragent "" set proxyhost "" set proxyport 0 +set net_timeout 5000 set cfgfile [file join $appdir "config.txt"] if {[file exists $cfgfile]} { set cfg [readfile $cfgfile] @@ -44,6 +45,9 @@ if {[file exists $cfgfile]} { set proxyport [dict get $cfg proxyport] ::http::config -proxyport $proxyport } + if {[dict exists $cfg net_timeout]} { + set net_timeout [dict get $cfg net_timeout] + } if {[dict exists $cfg tiix_font]} { set tiix_font [dict get $cfg tiix_font] }