<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-gb">
	<link rel="self" type="application/atom+xml" href="https://forum.eggheads.org/app.php/feed/topic/15452" />

	<title>egghelp/eggheads community</title>
	<subtitle>Discussion of eggdrop bots, shell accounts and tcl scripts.</subtitle>
	<link href="https://forum.eggheads.org/index.php" />
	<updated>2008-03-04T12:26:42-04:00</updated>

	<author><name><![CDATA[egghelp/eggheads community]]></name></author>
	<id>https://forum.eggheads.org/app.php/feed/topic/15452</id>

		<entry>
		<author><name><![CDATA[nml375]]></name></author>
		<updated>2008-03-04T12:26:42-04:00</updated>

		<published>2008-03-04T12:26:42-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=81437#p81437</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=81437#p81437"/>
		<title type="html"><![CDATA[Accepting DCC Files, without filesys.mod]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=81437#p81437"><![CDATA[
The problem with using fcopy is that it does not provide any means to identify individual packets, which is required for the ack. It will allow you to read a predefined number of bytes, but there's no guarantee that the sending party is using this packet size as there is no enforced size in the dcc implementation.<br><br>fileevent is, unfortunately, not ideal in this matter either, as if there is too much time in between calls to Tcl_DoOneEvent(), multiple packets might have arrived - being read as one chunk of data upon next event run.<br><br>Have you compared the performance of user's script with the filesys/transfer module (as a benchmark)?<br><br>It is unfortunate that the transfer module, although capable of outbound dcc transfers, cannot accept inbound transfers without depending on a separate module (such as filesys).<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8052">nml375</a> — Tue Mar 04, 2008 12:26 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Empus]]></name></author>
		<updated>2008-03-04T07:52:27-04:00</updated>

		<published>2008-03-04T07:52:27-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=81432#p81432</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=81432#p81432"/>
		<title type="html"><![CDATA[Accepting DCC Files, without filesys.mod]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=81432#p81432"><![CDATA[
To be honest, I believe it wasn't being placed in the right area of the code.<br><br>Can you show me what you mean?<br><br>I'm a complete noob when it comes to this, I've never had to deal with TCP sockets like this -reading and writing a file is as close as I've gotten to this :&gt;<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=9751">Empus</a> — Tue Mar 04, 2008 7:52 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[user]]></name></author>
		<updated>2008-03-04T07:17:03-04:00</updated>

		<published>2008-03-04T07:17:03-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=81431#p81431</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=81431#p81431"/>
		<title type="html"><![CDATA[Accepting DCC Files, without filesys.mod]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=81431#p81431"><![CDATA[
<blockquote class="uncited"><div>Forgive me, wasn't the point of this new method, given the prior results, to not use fcopy?</div></blockquote>Yes, because fcopy didn't SEEM to work, but I re-read your comment and this: <blockquote class="uncited"><div>the file is transferring, and CopyMore is being ran, but it seems to lock the bot, and I don't get an acknowledgement that the transfer completed.</div></blockquote> leads me to believe fcopy could work. I'd also like to see your code using "while {![fblocked" as I don't see how it could become alot slower that way.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=2878">user</a> — Tue Mar 04, 2008 7:17 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Empus]]></name></author>
		<updated>2008-03-04T05:57:04-04:00</updated>

		<published>2008-03-04T05:57:04-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=81425#p81425</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=81425#p81425"/>
		<title type="html"><![CDATA[Accepting DCC Files, without filesys.mod]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=81425#p81425"><![CDATA[
Forgive me, wasn't the point of this new method, given the prior results, to not use fcopy?<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=9751">Empus</a> — Tue Mar 04, 2008 5:57 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[user]]></name></author>
		<updated>2008-03-04T05:50:24-04:00</updated>

		<published>2008-03-04T05:50:24-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=81422#p81422</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=81422#p81422"/>
		<title type="html"><![CDATA[Accepting DCC Files, without filesys.mod]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=81422#p81422"><![CDATA[
<blockquote class="uncited"><div>Unfortunately that made it much much slower :&lt;</div></blockquote>That's weird. How about doing a fcopy with -size == file size? That way, when the callback is invoked, you'll either have the entire file or an error. (or SHOULD have - I didn't quite understand what went wrong in your previous fcopy experiment)<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=2878">user</a> — Tue Mar 04, 2008 5:50 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Empus]]></name></author>
		<updated>2008-03-04T05:02:32-04:00</updated>

		<published>2008-03-04T05:02:32-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=81419#p81419</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=81419#p81419"/>
		<title type="html"><![CDATA[Accepting DCC Files, without filesys.mod]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=81419#p81419"><![CDATA[
Unfortunately that made it much much slower :&lt;<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=9751">Empus</a> — Tue Mar 04, 2008 5:02 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[user]]></name></author>
		<updated>2008-03-04T02:11:25-04:00</updated>

		<published>2008-03-04T02:11:25-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=81413#p81413</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=81413#p81413"/>
		<title type="html"><![CDATA[Accepting DCC Files, without filesys.mod]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=81413#p81413"><![CDATA[
<blockquote class="uncited"><div>I would expect the transfer to be a lot faster than that...</div></blockquote>Try adding a loop that keeps reading while {![fblocked $sock]} {...} (in the read_more proc)<br><blockquote class="uncited"><div>Btw, it's "receive" not "recieve" ;p</div></blockquote>Corrected <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_smile.gif" width="15" height="15" alt=":)" title="Smile"><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=2878">user</a> — Tue Mar 04, 2008 2:11 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[strikelight]]></name></author>
		<updated>2008-03-03T20:01:44-04:00</updated>

		<published>2008-03-03T20:01:44-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=81407#p81407</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=81407#p81407"/>
		<title type="html"><![CDATA[Accepting DCC Files, without filesys.mod]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=81407#p81407"><![CDATA[
Just wanted to say nice work as usual, user.  (Btw, it's "receive" not "recieve" ;p)<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=2005">strikelight</a> — Mon Mar 03, 2008 8:01 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Empus]]></name></author>
		<updated>2008-03-03T18:11:39-04:00</updated>

		<published>2008-03-03T18:11:39-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=81402#p81402</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=81402#p81402"/>
		<title type="html"><![CDATA[Accepting DCC Files, without filesys.mod]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=81402#p81402"><![CDATA[
Thanks user and nml375, your help is much appreciated.<br><br>The code is working.  I'm currently sending a 700mb file to the bot from a local client, but the transfer speed is only about 70kB/s<br><br>Any ideas on how to improve this? I would expect the transfer to be a lot faster than that...<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=9751">Empus</a> — Mon Mar 03, 2008 6:11 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[user]]></name></author>
		<updated>2008-03-04T02:08:19-04:00</updated>

		<published>2008-03-03T10:42:56-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=81391#p81391</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=81391#p81391"/>
		<title type="html"><![CDATA[Accepting DCC Files, without filesys.mod]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=81391#p81391"><![CDATA[
It seems like fcopy will prevent you from being able to write to the socket using puts, so you'll have to do what fcopy does yourself. (like nml375 suggested)<br><br>Here's some (untested &amp; written in a hurry) code to get you started:<br><div class="codebox"><p>Code: </p><pre><code>namespace eval ::dccrecv {# change this and make sure the directory existsvariable dir "~/received";bind ctcp - DCC ::dccrecv::ctcpproc ctcp {n u h t a} {variable dirif {![isbotnick $t]} {return 0}if {[scan $a %s]=="SEND"} {set user $n!$uif {![matchattr $h X]} {# access denied (replace this with your own user validation)log "Refused SEND from $user"return 0}if {[scan $a "%s%s%u%u%u" k file ip port size]==5} {# valid ctcp?if {[catch {valid_file $file} err]} {log "SEND request from $user failed: $err"return 0}if {[catch {valid_ip $ip} err]} {log "SEND request from $user failed: $err"return 0}if {$port&lt;1024||$port&gt;65535} {log "SEND request from $user failed: Invalid port"return 0}if {$size&lt;1} {log "SEND request from $user failed: Invalid size"return 0}log "Connecting to [dec2dot $ip]:$port to receive $file from $user..."# merge dir &amp; file nameset file [file join $dir $file]# make sure no file by that name exists...# (remove this if you implement RESUME, of course :)if {[file exists $file]} {set i 0set root [file rootname $file]set ext [file extension $file]set file $root.$i$extwhile {[file exists $file]} {set file $root.[incr i]$ext}log "(new local file name: $file)"}# create socket and wait for connection to completeif {[catch {socket -async $ip $port} sock]} {log "Failed creating socket to receive $file from $user"return 0}fconfigure $sock -blocking 0 -buffering none -buffersize 1000000 -translation binaryfileevent $sock writable [list ::dccrecv::conn $sock $n!$u $file $size]return 1} else {log "Malformed SEND request from $user"return 0}} else {# not DCC SENDreturn 0}}# Connected?proc conn {sock user file size} {if {[set err [fconfigure $sock -error]]!=""} {log "Failed connecting to $user: $err"close $sockreturn}fileevent $sock writable {}fileevent $sock readable [list ::dccrecv::read_first $sock $user $file $size]}# The first packet... create the file if any data is receivedproc read_first {sock user file size} {if {[set err [fconfigure $sock -error]]!=""} {log "Failed reading first packet from $user: $err"close $sockreturn}if {[eof $sock]} {# i'm not sure this will ever happenlog "EOF on connect to $user - no data received"close $sockreturn}if {[catch {set fchan [open $file w]fconfigure $fchan -translation binaryputs -nonewline $fchan [read $sock]puts -nonewline $sock [binary format I [tell $fchan]]} err]} {log "Error reading first packet from $user: $err"close $sockreturn}if {[tell $fchan]&gt;=$size} {close $fchanclose $socklog "Received $file from $user (all in the first packet)"} else {fileevent $sock readable [list ::dccrecv::read_more $sock $user $file $fchan $size]}}# The rest of the file... keep reading and reporting the total size# and check the size to see if we're done.proc read_more {sock user file fchan size} {if {[set err [fconfigure $sock -error]]!=""} {log "Lost connection to $user: $error"close $fchanclose $sock# you might want to [file delete $file] herereturn} elseif {[eof $sock]} {log "DCC SEND from $user incomplete (unexpected EOF)"close $fchanclose $sock# you might want to [file delete $file] herereturn}if {[catch {puts -nonewline $fchan [read $sock]puts -nonewline $sock [binary format I [tell $fchan]]} err]} {log "Error recieving $file from $user: $err"close $fchanclose $sock# you might want to [file delete $file] herereturn}if {[tell $fchan]&gt;=$size} {# you might want to check if the file size &gt; $size (indicating a possible dos attempt)close $fchanclose $socklog "Received $file from $user"}}proc log msg {putlog "\[dccrecv\] $msg"}proc dec2dot ip {join [scan [format %08x $ip] %2x%2x%2x%2x] .}proc valid_ip ip {if {![string is integer -strict $ip]||($ip&lt;0)||($ip&gt;4294967295)} {error "not a valid ipv4 address: $ip"}if {($ip&gt;=2130706432)&amp;&amp;($ip&lt;2147483648)} {error "loopback address: [dec2dot $ip]"}if {(($ip&gt;=167772160)&amp;&amp;($ip&lt;184549376))||\(($ip&gt;=2886729728)&amp;&amp;($ip&lt;2887778304))||\(($ip&gt;=3232235520)&amp;&amp;($ip&lt;3232301056))} {error "private network address: [dec2dot $ip]"}if {($ip&gt;=2851995648)&amp;&amp;($ip&lt;2852061184)} {error "link-local address: [dec2dot $ip]"}}proc valid_file {file {dir {}} {if {[string match {*[/|@&amp;&lt;&gt;]*} $file]} {error "invalid filename (possible exploit attempt?): $file"}if {$dir!={}&amp;&amp;[file isdir [file join $dir $file]]} {error "file is directory: $file}}}</code></pre></div>EDIT: Spelling ;p<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=2878">user</a> — Mon Mar 03, 2008 10:42 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[nml375]]></name></author>
		<updated>2008-03-02T15:06:15-04:00</updated>

		<published>2008-03-02T15:06:15-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=81375#p81375</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=81375#p81375"/>
		<title type="html"><![CDATA[Accepting DCC Files, without filesys.mod]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=81375#p81375"><![CDATA[
I'm not familiar with fcopy in particular, I'm afraid.<br><br>A possible issue might be that the client is waiting for the ack before sending the next packet<br><br>One approach I'd considder is using fileevents to trigger some proc whenever there is data to be read at the input socket. I'll see if I can't craft a rough example in the next day or two.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8052">nml375</a> — Sun Mar 02, 2008 3:06 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Empus]]></name></author>
		<updated>2008-03-02T06:28:46-04:00</updated>

		<published>2008-03-02T06:28:46-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=81357#p81357</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=81357#p81357"/>
		<title type="html"><![CDATA[Accepting DCC Files, without filesys.mod]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=81357#p81357"><![CDATA[
Ah yes, I've changed little bits and pieces in this code for days now trying to work out why it isn't working, but to no avail.<br><br>I did have them declared with 'global', perhaps just not in that example.<br><br>CopyMore doesnt seem to be looping properly.<br><br>In CopyMore, i've added a: puts $in $total, as acknowledgement.<br><br>I've read that page, but the issue seems to be TCL related.  It's not looping so not all blocks are transferred, meaning there is no EOF, and $size never equals $total (because $total is not incrementing.<br><br>Are you able to be any more specific?<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=9751">Empus</a> — Sun Mar 02, 2008 6:28 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[nml375]]></name></author>
		<updated>2008-03-02T06:03:52-04:00</updated>

		<published>2008-03-02T06:03:52-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=81354#p81354</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=81354#p81354"/>
		<title type="html"><![CDATA[Accepting DCC Files, without filesys.mod]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=81354#p81354"><![CDATA[
Namespaces; any variable is defined within a certain namespace, and cannot be accessed from another namespace without full addressing.<br><br>The ones to keep track of in this case are globalspace (::), and and the anonymous spaces within a given invocation of a proc (also known as local variables). That is, $myvar in proc1 is not the same as $myvar in proc2; nor is it the same the first and the second time you call proc1 (ie when doing recursive calls).<br><br>To access the globalspace variables, you have two options, either use the globalspace address ($::myvar) or use the <em class="text-italics">global</em> command to link a local variable to the globalspace one.<br><br>Most likely, you intended to use the global command in CopyMore just as you did in sockConnected.<br><br><br>DCC Ack's;<br>The ack should be a 4 byte, network order, unsigned integer of the number of bytes recieved sofar.<br>A further explanation may be found here: <a href="http://www.irchelp.org/irchelp/rfc/dccspec.html" class="postlink">http://www.irchelp.org/irchelp/rfc/dccspec.html</a><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8052">nml375</a> — Sun Mar 02, 2008 6:03 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Empus]]></name></author>
		<updated>2008-03-02T02:42:54-04:00</updated>

		<published>2008-03-02T02:42:54-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=81350#p81350</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=81350#p81350"/>
		<title type="html"><![CDATA[Accepting DCC Files, without filesys.mod]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=81350#p81350"><![CDATA[
You're right, the script does seem to wait forever.<br><br>I've removed vwait, and it no longer does this, but CopyMore seems to still not run.<br><br>Can you clarify your point of namespaces, and offer advice as to what to do to get this working?<br><br>I used file writes in bgerror to ensure that if the eggdrop itself hangs, the tcl will write to the file.  Plus, when asking TCL folk about this, I've tried to eliminate eggdrop references, otherwise no-one will want to help me.<br><br>This is driving me nuts and I very much so want to get the code working.<br><br>How should the acknowledgements be sent?<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=9751">Empus</a> — Sun Mar 02, 2008 2:42 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[nml375]]></name></author>
		<updated>2008-03-02T01:00:59-04:00</updated>

		<published>2008-03-02T01:00:59-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=81345#p81345</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=81345#p81345"/>
		<title type="html"><![CDATA[Accepting DCC Files, without filesys.mod]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=81345#p81345"><![CDATA[
Roughly, all vwait does is: 1. call Tcl_DoOneEvent(), and 2. Check wether the variable specified on the commandline has been altered; if not, back to 1, else return.<br><br>Since eggdrop itself calls Tcl_DoOneEvent(), there's no need for vwait unless you want your script to block until <em class="text-italics">done</em> has been set.<br><br>I do see a possible error in CopyMore, you try to log the contents of <em class="text-italics">chunk</em>, but it's not set there. You also try to increase the value of <em class="text-italics">total</em>, which also isn't set there. Would seem you're abit confused with namespaces. Further, you don't set the globalspace variable <em class="text-italics">done</em> monitored by vwait, but rather a local one in CopyMore - possibly causing your script to wait forever.<br><br>To simplify logging, you might simply use <em class="text-italics">putlog</em> in your bgerror function.<br><br>Finally, I don't see you sending any Ack's back to the sending party.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8052">nml375</a> — Sun Mar 02, 2008 1:00 am</p><hr />
]]></content>
	</entry>
	</feed>
