Skip to content

Commit eb03191

Browse files
committed
Fix DCC SEND resuming.
1 parent 6769538 commit eb03191

File tree

1 file changed

+84
-32
lines changed

1 file changed

+84
-32
lines changed

dlFilter.mrc

Lines changed: 84 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ dlFilter uses the following code from other people:
108108
Close filter window now closes / hides (depending on keep in background) all Filter / FilterSearch windows.
109109
Options dialog is now associated with active window's connection so show of Filter / Ads makes correct window active.
110110
On start / load warn user if "Options/Sounds/Requests/Send '!nick file' as Private Message" is checked (since it misdirects triggers).
111+
Fix interception of DCC ACCEPT CTCP messages preventing DCC SEND resumes.
111112
112113
*/
113114

@@ -578,6 +579,7 @@ ctcp ^*:PING*:?: { DLF.Priv.ctcpBlock $1- }
578579

579580
ctcp *:DCC CHAT *:?: { DLF.DccChat.Chat $1- }
580581
ctcp *:DCC SEND *:?: { DLF.DccSend.Send $1- }
582+
ctcp *:DCC ACCEPT *:?: { DLF.DccSend.Accept $1- }
581583
ctcp *:*:?: { DLF.Priv.ctcp $1- }
582584
ctcp *:*:%DLF.channels: { if ($DLF.Chan.IsChanEvent) DLF.Chan.ctcp $1- }
583585

@@ -1477,13 +1479,13 @@ alias -l DLF.Priv.ctcpReply {
14771479
alias -l DLF.Priv.SpamFilter {
14781480
if (%DLF.opwarning.spamchan == 1) {
14791481
var %msg $c(4,15,Private spam from $nick $br($address($nick,5)) $+ : $q($1-))
1480-
var %i $comchan($nick,0)
1482+
var %i $comchan($nick,0).op
14811483
while (%i) {
1482-
var %chan $comchan($nick,%i)
1483-
if ($me isop %chan) .DLF.notice @ $+ $chan $logo %msg
1484+
var %chan $comchan($nick,%i).op
1485+
.DLF.notice @ $+ %chan $logo %msg
14841486
dec %i
14851487
}
1486-
DLF.Win.Echo Filter Blocked Private $nick %msg
1488+
DLF.Win.Echo Blocked Private $nick %msg
14871489
}
14881490
DLF.Win.Filter $1-
14891491
}
@@ -1874,7 +1876,6 @@ alias -l DLF.DccSend.GetRequest {
18741876
return $hfind(DLF.dccsend.requests,$+($network,|*|,%trig,|,%srch,|*),1,w).item
18751877
}
18761878
}
1877-
DLF.Watch.Log hfind(DLF.dccsend.requests, $+($network,|*|XDCC-,$nick,|*|*) ,1,w).item
18781879
var %req $hfind(DLF.dccsend.requests,$+($network,|*|XDCC-,$nick,|*|*),1,w).item
18791880
if (%req) return %req
18801881
var %req $hfind(DLF.dccsend.requests,$+($network,|*|@,$nick,||),1,w).item
@@ -1953,7 +1954,7 @@ alias -l DLF.DccSend.SendNotice {
19531954

19541955
alias -l DLF.DccSend.Send {
19551956
DLF.Watch.Called DLF.DccSend.Send : $1-
1956-
var %fn $DLF.GetFileName($3-)
1957+
var %fn $noqt($gettok($3-,-4-1,$asc($space)))
19571958
if ($chr(8238) isin %fn) {
19581959
DLF.Win.Echo Blocked Private $nick DCC Send - filename contains malicious unicode U+8238
19591960
DLF.Halt Blocked: DCC Send - filename contains malicious unicode U+8238
@@ -1963,7 +1964,7 @@ alias -l DLF.DccSend.Send {
19631964
if ($DLF.DccSend.IsRequest(%fn)) {
19641965
if ((%DLF.dccsend.autoaccept == 1) && (!%trusted)) DLF.DccSend.TrustAdd
19651966
DLF.Watch.Log Accepted: DCC Send - you requested this file from this server
1966-
DLF.DccSend.Receiving %fn
1967+
DLF.DccSend.Receiving $1-
19671968
return
19681969
}
19691970
if (!%trusted) {
@@ -1980,7 +1981,7 @@ alias -l DLF.DccSend.Send {
19801981
DLF.Watch.Log DCC Send accepted from untrusted user due to file receiving options
19811982
}
19821983
else DLF.Watch.Log DCC Send accepted from trusted user
1983-
DLF.DccSend.Receiving %fn
1984+
DLF.DccSend.Receiving $1-
19841985
}
19851986

19861987
alias -l DLF.DccSend.Block {
@@ -1993,17 +1994,74 @@ alias -l DLF.DccSend.Block {
19931994
}
19941995

19951996
alias -l DLF.DccSend.Receiving {
1996-
var %req $DLF.DccSend.GetRequest($1-)
1997+
var %fn $noqt($gettok($3-,-4-1,$asc($space)))
1998+
DLF.DccSend.AddAccepted %fn
1999+
var %req $DLF.DccSend.GetRequest(%fn)
19972000
if (%req == $null) return
19982001
var %chan $gettok(%req,2,$asc(|))
19992002
var %origfn $decode($gettok(%req,5,$asc(|)))
2000-
if (%origfn == $null) %origfn = $1-
2003+
if (%origfn == $null) %origfn = %fn
20012004
var %secs 86400 - $hget(DLF.dccsend.requests,%req)
2002-
DLF.Win.Log Server ctcp %chan $nick DCC Get of $qt(%origfn) from $nick starting $br(waited $duration(%secs,3))
2005+
var %starting starting
2006+
if ($dccIfFileExists == Resume) {
2007+
var %pathfile $+($getdir(%fn),%fn)
2008+
if ($isfile(%pathfile)) {
2009+
if ($file(%pathfile).size > 0) %starting = resuming
2010+
}
2011+
}
2012+
DLF.Win.Log Server ctcp %chan $nick DCC Get of $qt(%origfn) from $nick %starting $br(waited $duration(%secs,3))
2013+
}
2014+
2015+
alias -l DLF.DccSend.Accept {
2016+
DLF.Watch.Called DLF.DccSend.Accept : $1-
2017+
var %fn $noqt($gettok($3-,-3-1,$asc($space)))
2018+
if ($DLF.DccSend.IsntAccepted(%fn)) DLF.Priv.ctcp $1-
2019+
}
2020+
2021+
alias -l DLF.DccSend.AddAccepted {
2022+
var %hash $DLF.DccSend.Hash($1-)
2023+
.hadd -mz DLF.dccsend.accepted %hash 300
2024+
}
2025+
2026+
alias -l DLF.DccSend.IsntAccepted {
2027+
var %hash $DLF.DccSend.Hash($1-)
2028+
if ($hget(DLF.dccsend.accepted,%hash)) return $false
2029+
return $true
2030+
}
2031+
2032+
alias -l DLF.DccSend.DelAccepted {
2033+
var %hash $DLF.DccSend.Hash($1-)
2034+
if ($hget(DLF.dccsend.accepted,%hash)) .hdel DLF.dccsend.accepted %hash
2035+
}
2036+
2037+
alias -l DLF.DccSend.Hash { return $encode($network $nick $1-) }
2038+
2039+
alias -l DLF.DccSend.Retry {
2040+
if (!%DLF.serverretry) return $false
2041+
var %hash $DLF.DccSend.Hash($1-)
2042+
var %attempts $hget(DLF.dccsend.retries,%hash)
2043+
if (%attempts == 3) {
2044+
DLF.DccSend.RetryDelete $1-
2045+
return $false
2046+
}
2047+
if (%attempts == $null) {
2048+
; First retry
2049+
.hadd -m DLF.dccsend.retries %hash 1
2050+
}
2051+
else {
2052+
.hinc DLF.dccsend.retries %hash
2053+
}
2054+
return $true
2055+
}
2056+
2057+
alias -l DLF.DccSend.RetryDelete {
2058+
var %hash $DLF.DccSend.Hash($1-)
2059+
if ($hget(DLF.dccsend.retries,%hash)) .hdel DLF.dccsend.retries %hash
20032060
}
20042061

20052062
alias -l DLF.DccSend.FileRcvd {
20062063
var %fn $nopath($filename)
2064+
DLF.DccSend.DelAccepted %fn
20072065
DLF.Watch.Called DLF.DccSend.FileRcvd %fn : $1-
20082066
var %req $DLF.DccSend.GetRequest(%fn)
20092067
if (%req == $null) return
@@ -2013,8 +2071,7 @@ alias -l DLF.DccSend.FileRcvd {
20132071
var %trig $gettok(%req,3,$asc(|))
20142072
var %origfn $decode($gettok(%req,5,$asc(|)))
20152073
if (%origfn == $null) %origfn = %fn
2016-
var %hash $encode(%trig %origfn)
2017-
if ($hget(DLF.dccsend.retries,%hash)) .hdel DLF.dccsend.retries %hash
2074+
DLF.DccSend.RetryDelete %trig %origfn
20182075
var %bytes $get(-1).rcvd / %dur
20192076
DLF.Win.Log Server ctcp %chan $nick DCC Get of $qt(%origfn) from $nick complete $br($duration(%dur,3) $bytes(%bytes,3).suf $+ /Sec)
20202077
; Some servers change spaces to underscores
@@ -2064,31 +2121,16 @@ alias -l DLF.DccSend.GetFailed {
20642121

20652122
var %fn $nopath($filename)
20662123
DLF.Watch.Called DLF.DccSend.GetFailed %fn : $1-
2124+
DLF.DccSend.DelAccepted %fn
20672125
var %req $DLF.DccSend.GetRequest(%fn)
20682126
if (%req == $null) return
20692127
.hdel -s DLF.dccsend.requests %req
20702128
var %chan $gettok(%req,2,$asc(|))
20712129
var %trig $gettok(%req,3,$asc(|))
20722130
var %origfn $decode($gettok(%req,5,$asc(|)))
20732131
if (%origfn == $null) %origfn = %fn
2074-
var %hash $encode(%trig %origfn)
2075-
var %retry %DLF.serverretry
2076-
if (%retry) {
2077-
var %attempts $hget(DLF.dccsend.retries,%hash)
2078-
if (%attempts == $null) {
2079-
; First retry
2080-
.hadd -m DLF.dccsend.retries %hash 1
2081-
}
2082-
elseif (%attempts == 3) {
2083-
.hdel DLF.dccsend.retries %hash
2084-
%retry = $false
2085-
}
2086-
else {
2087-
.hinc DLF.dccsend.retries %hash
2088-
}
2089-
}
20902132
var %bytes $get(-1).rcvd / $get(-1).secs
2091-
var %retrying
2133+
var %retry $DLF.DccSend.Retry(%trig %origfn), %retrying
20922134
if (%retry) %retrying = - $c(3,retrying)
20932135
DLF.Win.Log Server ctcp %chan $nick DCC Get of %origfn from $nick incomplete $br($duration(%dur,3) $bytes(%bytes).suf $+ /Sec) %retrying
20942136
if (xdcc-* iswm %trig) %trig = $null
@@ -5556,9 +5598,11 @@ alias -l DLF.IsServiceUser {
55565598
return $false
55575599
}
55585600

5601+
; Remove trailing stuff from filename
5602+
; Common (OmenServe) response has filename followed by e.g. ::INFO::
5603+
; and colons are not allowable characters in file names
5604+
; DCC SEND / ACCEPT messages have ipaddress port filesize or position following filename
55595605
alias -l DLF.GetFileName {
5560-
; common (OmenServe) response has filename followed by e.g. ::INFO::
5561-
; and colons are not allowable characters in file names
55625606
var %txt $gettok($replace($strip($1-),$nbsp,$space,$tab $+ $space,$space,$tab,$null),1,$asc(:))
55635607
var %n $numtok(%txt,$asc($space))
55645608
; delete trailing info: CRC(*) or (*)
@@ -5913,6 +5957,14 @@ alias -l shortjoinsparts return $DLF.mIRCini(options,2,19)
59135957
alias -l windowbuffer return $DLF.mIRCini(options,3,1)
59145958
alias -l usesinglemsg return $DLF.mIRCini(options,0,22)
59155959
alias -l sendPlingNickAsPrivate return $DLF.mIRCini(options,1,23)
5960+
alias -l dccIfFileExists {
5961+
var %value = $DLF.mIRCini(options,1,27)
5962+
if (%value == 0) return Ask
5963+
if (%value == 1) return Resume
5964+
if (%value == 2) return Overwrite
5965+
if (%value == 3) return Cancel
5966+
return Unknown
5967+
}
59165968

59175969
alias -l DLF.mIRCini {
59185970
var %item $2

0 commit comments

Comments
 (0)