• Sending message to user from protocol

    From deepthaw@VERT/CORTEX to All on Thu Nov 12 18:32:24 2020
    I'm working on a bash script to generate a URL to download a requested file via http which can then work as a protocol.

    All of it works, except for sending a message back to the user. I know very little about socket programming, would this involve the socket passed via the %h parameter?

    I tried something similar to:

    echo -e "test message\n" | netcat $1 $2

    Where $1 and $2 map to %i %h (client ip, socket descriptor). But I don't see anything on the client's end.

    ---
    þ Synchronet þ c.o.r.t.e.x 2.0.2.0 | telnet://deepthaw.net
  • From Digital Man@VERT to deepthaw on Thu Nov 12 17:41:50 2020
    Re: Sending message to user from protocol
    By: deepthaw to All on Thu Nov 12 2020 06:32 pm

    I'm working on a bash script to generate a URL to download a requested file via http which can then work as a protocol.

    All of it works, except for sending a message back to the user. I know very little about socket programming, would this involve the socket passed via the %h parameter?

    I tried something similar to:

    echo -e "test message\n" | netcat $1 $2

    Where $1 and $2 map to %i %h (client ip, socket descriptor). But I don't see anything on the client's end.

    '%h' would be a socket descriptor. 'netcat' does not accept a socket descriptor as an argument. I think you're passing the socket descriptor where netcat would expect to find a port (TCP or UDP).

    The easiest way to send a message to a user is to write (append) to the file data/msgs/####.msg where #### is the 0-padded user number. You could pass this value as an argument to your script using the %4 specifier.
    http://wiki.synchro.net/config:cmdline

    The node won't know it has a message waiting until you set the "MSGW" flag for the node. This can be done using the exec/node utility.

    All of these could be done via JS, so consider just writing your entire script in JS.
    --
    digital man

    Rush quote #32:
    Begging hands and bleeding hearts will only cry out for more
    Norco, CA WX: 60.2øF, 54.0% humidity, 6 mph E wind, 0.00 inches rain/24hrs
    ---
    þ Synchronet þ Vertrauen þ Home of Synchronet þ [vert/cvs/bbs].synchro.net
  • From deepthaw@VERT/CORTEX to Digital Man on Thu Nov 12 20:57:39 2020
    Re: Sending message to user from protocol
    By: Digital Man to deepthaw on Thu Nov 12 2020 05:41 pm

    '%h' would be a socket descriptor. 'netcat' does not accept a socket descriptor as an argument. I think you're passing the socket descriptor where netcat would expect to find a port (TCP or UDP).

    This was actually the hint I needed, and I now have it working, I used:
    >&$1 printf 'your file will be ...' ($1 is the parameter %h)
    and ended it with
    exec >&-

    Now I just need to re-verify my permissions are safe by uploading/downloading arbitrary php files, then get it working with batch downloads. I'll share it with everybody then if there's interest.

    Then I'll go rewrite it in JavaScript. My JS is rusty, but porting this over should be a good way to jump back into it.

    ---
    þ Synchronet þ c.o.r.t.e.x 2.0.2.0 | telnet://deepthaw.net
  • From deepthaw@VERT/CORTEX to All on Thu Nov 12 23:12:59 2020
    Re: Sending message to user from protocol
    By: deepthaw to Digital Man on Thu Nov 12 2020 08:57 pm

    As mentioned earlier, I spent the evening teaching myself bash scripting by writing an http file transfer protocol. Nothing fancy, what it does is copy the files requested to a directory on your web server then sends them a URL which expires that they can use to download them in a web browser. Might be nice for sites that use that fancy HTML telnet client for which I never got any of the protocols to work (but then they're probably using the rest of echicken's stuff which lets them download via ftp and ... i just wanted to learn some bash.)

    Anyways: This is barely tested but seems to work. I'm new with linux programming, bash especially, so there's bound to be some security bugs I've not found yet.

    Save it to your /sbbs/exec, and add a new protocol called HTTP or whatever. command line for download should be %!httpdl.sh%. %h %f and batch download should be %!httpdl.sh%. %h @%f make sure to enable native application and socket IO. (It was DM himself who tipped me off that my approach was wrong.)

    #!/bin/bash

    # we generate a uuid to use for storage of the files. we only keep
    # the first 8 characters
    uuid=$(uuidgen)
    dirhash="${uuid:0:8}"

    # the base url from which files will be downloaded downloadprefix="http://deepthaw.net/bbs_downloads/"
    mkdir -m715 "/var/www/html/bbs_downloads/$dirhash" # is 715 safe?

    # setup some needed variables
    descriptor="$1" # socket descriptor
    files="$2" # file or list of files if it starts with @

    # if the first character in the name of $files is @, we read every line
    if [ "${files:0:1}" == '@' ]; then
    batch="${files:1}"
    while IFS=$' \t\n\r' read -r line; # i hate bash
    do
    cp -p "$line" "/var/www/html/bbs_downloads/$dirhash"
    done < "$batch"
    else
    cp -p "$files" "/var/www/html/bbs_downloads/$dirhash"
    fi

    # from at package - lets us schedule jobs for later
    echo "rm -rf /var/www/html/bbs_downloads/$dirhash" | at now +60 minutes

    # tell users where to find the files on the website
    &$descriptor printf 'your file(s) will be available at\r\n%s%s/ for one hour.\$

    # close socket
    exec >&-

    ---
    þ Synchronet þ c.o.r.t.e.x 2.0.2.0 | telnet://deepthaw.net
  • From Ragnarok@VERT/DOCKSUD to deepthaw on Fri Nov 13 11:56:17 2020
    El 12/11/20 a las 21:32, deepthaw escribió:
    I'm working on a bash script to generate a URL to download a requested file via http which can then work as a protocol.

    All of it works, except for sending a message back to the user. I know very little about socket programming, would this involve the socket passed via the %h parameter?

    I tried something similar to:

    echo -e "test message\n" | netcat $1 $2

    Where $1 and $2 map to %i %h (client ip, socket descriptor). But I don't see anything on the client's end.

    ---
    þ Synchronet þ c.o.r.t.e.x 2.0.2.0 | telnet://deepthaw.net

    hello!

    i have implemented a "mailer" protocol, you can check it, is a prof of concept. that the user, select this download protocol instead of zmodem,
    and sbbs send a email with the url of file


    ftp://bbs.docksud.com.ar/dsmailer.js

    ---
    ï¿­ Synchronet ï¿­ Dock Sud BBS TLD 24 HS - bbs.docksud.com.ar
  • From deepthaw@VERT/CORTEX to Ragnarok on Fri Nov 13 10:49:18 2020
    Re: Re: Sending message to user from protocol
    By: Ragnarok to deepthaw on Fri Nov 13 2020 11:56 am

    i have implemented a "mailer" protocol, you can check it, is a prof of concept. that the user, select this download protocol instead of zmodem,
    and sbbs send a email with the url of file


    ftp://bbs.docksud.com.ar/dsmailer.js
    þ Synchronet þ Dock Sud BBS TLD 24 HS - bbs.docksud.com.ar

    Very nice, I probably will take a look at it.

    ---
    þ Synchronet þ c.o.r.t.e.x 2.0.2.0 | telnet://deepthaw.net