eggheads / eggdrop

The Eggdrop IRC Bot
GNU General Public License v2.0
510 stars 84 forks source link

Share an file to botnet : commands putfile/putallfile, bind file like putbot/putallbots, bind bot #1026

Open ZarTek-Creole opened 4 years ago

ZarTek-Creole commented 4 years ago

Pastebin example

Hello, Do you know if it is possible to transfer / share a file between two bots via the partyline / botnet? I know it is ``` possible to share the userfile .. and for a specific file an idea? <@Geo> ZarTek: take a look at the filesys module perhaps? <@Geo> I don't know that it shares a file "between two bots", but what are you trying to do specifically? Geo: I would like to transfer a file through the botnet. The goal is to share a configuration file of a TCL script from bot1 to bot2 by the botnet. As a message via putbot. something like a putfile It may not be implemented. I will reread the filesys module, in my memory it is useful for files via DCC on IRC. I imagine that a solution could be to read the file on bot1 encrypt in base64 use a putbot. on bot2 capture the base64 message and decrypt to write the file. <@Geo> ZarTek: docs.eggheads.org, look at the documentation for the filesys module <@Geo> other than that, you probably want to load a Tcl script <@Geo> I'm trying to figure out the use case for doing such a thing though <@Geo> oh, you pasted it, I missed that line <@Geo> sorry! <@Geo> also, base64 isn't encryption, its encoding. If you're trying to protect the contents, that is mostly pointless Yes, encoding sorry. the base64 would be to create the contents of the file in character string The goal would be such that the userfile share a file from the hub to the slaves to share the information contained and load each bot. a duplication of a file from the hub on the slaves. via the botnet and not via the dcc send. Geo: Yes, I'm sorry if I express myself poorly in English. I don't speak English very well. In the end, the idea is to be able to have a file sent from one robot to another using the botnet protocol. The interest may be various. In my case, it is to be able to send the updates of my tcl script from one robot to another and the configuration files of this one. ``` `# On the hub proc update { } { putlog "update..." set leaf "BOT2" set CURPATH [file dirname [file normalize [info script]]] set FULLPATH "$CURPATH/my_script.tcl"
# * Sent file 'my_script.tcl' to all bot on the botnet
putallfile  "update_systeme my_script.tcl"      $FULLPATH
#### Output Commands
### putallfile <message> <file>
## Description: sends a file across the botnet to all bots. If no script intercepts the message on the other end, the message is ignored.
## Returns: nothing

# * Sent file 'my_script.tcl' to 'BOT2' on the botnet
putfile $leaf "update_systeme my_script.tcl "   $FULLPATH

#### Output Commands
### putfile <bot-nick> <message> <file>
## Description: sends a file across the botnet to another bot. If no script intercepts the message on the other end, the message is ignored.
## Returns: nothing
## Module: core

}

on the leaf

bind FILE

triggered by a file coming from another bot in the botnet. The first word is the command and the rest becomes the text argument; flags are ignored.

Syntaxe: bind file

proc: proc-name

Module: core

bind file - update_file update:file:from:botnet proc update:file:from:botnet { bot cmd arg fileid } {

# fileid : like [open "$CURPATH/my_script.tcl" r] on the hub

set filename    [lindex $arg 1]

putlog "UPDATE FILE: $filename"
set number  0
#
# gets with two arguments returns the length of the line,
# -1 if the end of the file is found
#
while { [gets $fileid line] >= 0 } {
    incr number
}
close $fileid

putlog "Number of lines: $number"

}`

vanosg commented 4 years ago

To summarize what the user is asking, they are interested in a Tcl command that sends a file from one bot to another, and a bind to detect when that transfer starts (and/or finishes).

Things to consider (and discuss) should this be implemented, is this going to be a raw socket transfer (requiring a new port to be opened on the opposite bot and the subsequent network configuration required to support that), or could it be sent "in-line" using the already-established bot link socket (kinda like putbot)?

ZarTek-Creole commented 4 years ago

Precisely, the idea is the second solution :

using the already-established bot link socket (kinda like putbot)?

Otherwise it is useless. It can be done natively by TCL.

sends a file from one bot to another

More exactly, the content of the file by a channel. channel that gives access to the content of the open resource. .

can be used by gets, read, etc. https://wiki.tcl-lang.org/page/channel A size limit will obviously be necessary. The goal is to transfer scripts, script configurations or small files. Something similar to the userfile sharing method in [src/mod/transfer.mod/transfer.c](https://github.com/eggheads/eggdrop/blob/282809f41f29f27e7e3d3ed55705adfb1aef6170/src/mod/transfer.mod/transfer.c)
key2peace commented 4 years ago

-bind file - update_file update:file:from:botnet +bind file - "update_systeme *" update:file:from:botnet

michaelortmann commented 4 years ago

Precisely, the idea is the second solution :

using the already-established bot link socket (kinda like putbot)?

Something similar to the userfile sharing method in src/mod/transfer.mod/transfer.c

eggdrop user file sharing uses transfer.mod, but it uses the first method, opening another socket. i would rather like to change userfile sharing to use the main botlink instead of opening yet another socket. if we can do a botlink file transfer with this PR, we could change the userfile sharing to also switch to using that new method.

like with user file sharing, we could add optional compression via compress.mod.