• Perl on_handshake(): @me contains no valid addresses

    From Oli@2:280/464.47 to All on Wed Sep 8 11:37:42 2021
    HELP! ;)
    I'm trying to use the @me array in on_handshake(), but no matter what I do I always get the error:

    "Perl on_handshake(): @me contains no valid addresses"

    even with this simple sub:

    sub on_handshake
    {
    @me;
    }

    + 08 Sep 09:45:26 [51014] incoming session with unknown
    - 08 Sep 09:45:27 [51014] VER binkd/1.1a-112/Linux binkp/1.1
    + 08 Sep 09:45:27 [51014] addr: 4000:1/1@testnet
    + 08 Sep 09:45:27 [51014] Perl on_handshake(): @me contains no valid addresses - 08 Sep 09:45:27 [51014] hiding aka 2000:1/2@fakenet

    Is this a bug or how do I use @me? The perlhooks documentation says

    5) on_handshake()
    - for server called after receiving remote addresses (before addr is sent)
    - best for hide_aka and present_aka logic :-)
    - return non-empty string to abort session with that reason
    otherwise, if @me is defined present @me as our akas


    The error message is from perlhooks.c

    if ((me = perl_get_av("me", FALSE)) != NULL) {
    FTN_ADDR addr;
    int n = 0, N = av_len(me) + 1;
    if (N > 0) state->pAddr = xalloc(N*sizeof(FTN_ADDR));
    for (i = 0; i < N; i++) {
    svp = av_fetch(me, i, FALSE);
    if (svp == NULL) continue;
    if (!parse_ftnaddress(SvPV(*svp, len), &addr, cfg->pDomains.first)) continue;
    exp_ftnaddress(&addr, cfg->pAddr, cfg->nAddr, cfg->pDomains.first);
    state->pAddr[n++] = addr;
    }
    state->nAddr = n;
    if (n == 0) Log(LL_WARN, "Perl on_handshake(): @me contains no valid addresses");
    }

    ---
    * Origin: 1995| Invention of the Cookie. The End. (2:280/464.47)
  • From Michael Dukelsky@2:5020/1042 to Oli on Wed Sep 8 17:44:36 2021
    Hello Oli,

    Wednesday September 08 2021, Oli wrote to All:

    HELP! ;)
    I'm trying to use the @me array in on_handshake(), but no matter what
    I do I always get the error:

    "Perl on_handshake(): @me contains no valid addresses"

    even with this simple sub:

    sub on_handshake
    {
    @me;
    }

    I've never used this hook but as far as I understand you have to put the AKAs you want to present to the @me array. The array in your sub contains no addresses, so you receive the error message.

    Michael

    ... node (at) f1042 (dot) ru
    --- GoldED+/LNX 1.1.5-b20180707
    * Origin: Moscow, Russia (2:5020/1042)
  • From Oli@2:280/464.47 to Michael Dukelsky on Wed Sep 8 16:43:13 2021
    Michael wrote (2021-09-08):

    HELP! ;)
    I'm trying to use the @me array in on_handshake(), but no matter
    what I do I always get the error:

    "Perl on_handshake(): @me contains no valid addresses"

    even with this simple sub:

    sub on_handshake
    {
    @me;
    }

    I've never used this hook but as far as I understand you have to put the AKAs you want to present to the @me array. The array in your sub contains no addresses, so you receive the error message.

    Hi Michael,

    your right. It does work when I use

    @me = ("5:6/7");

    I was sure I've already tried it like this. Maybe it was a typo, which I didn't see.

    I also thought the variable is pre-filled with the AKAs, like it is with $hosts etc. And then the unusual behavior of Perl confused me. I didn't expect that a variable can be created without explicit declaration or assignment. So Log(3, $me[0]) initialized an empty array @me. Most other languages would complain about an non existent variable.

    Thanks :)

    ---
    * Origin: 1995| Invention of the Cookie. The End. (2:280/464.47)
  • From Oli@2:280/464.47 to Michael Dukelsky on Thu Sep 9 09:00:25 2021
    Michael wrote (2021-09-08):

    Hello Oli,

    Wednesday September 08 2021, Oli wrote to All:

    HELP! ;)
    I'm trying to use the @me array in on_handshake(), but no matter
    what I do I always get the error:

    "Perl on_handshake(): @me contains no valid addresses"

    even with this simple sub:

    sub on_handshake
    {
    @me;
    }

    I've never used this hook but as far as I understand you have to put the AKAs you want to present to the @me array. The array in your sub contains no addresses, so you receive the error message.

    The side effects are a bit confusing:

    sub on_handshake
    {
    Log(3, "<<< on_handshake() >>>");
    }

    sub after_handshake
    {
    Log(3, "<<< after_handshake() >>> @me");
    }


    + 08:43 [1459] outgoing session with 127.0.0.1:24554
    - 08:43 [1459] <<< on_handshake() >>>
    + 08:43 [1459] Perl on_handshake(): @me contains no valid addresses
    - 08:43 [1459] OPT CRAM-MD5-fffdf8c077e8c9b94ce2e83d8da0a8ee
    [...]
    - 08:43 [1459] session in CRYPT mode
    - 08:43 [1459] <<< after_handshake() >>> 2000:1/2@fakenet 4000:1/1@testnet


    I'm not sure if this is considered to be expected behavior or a bug?

    ---
    * Origin: 1995| Invention of the Cookie. The End. (2:280/464.47)
  • From Michael Dukelsky@2:5020/1042 to Oli on Thu Sep 9 11:54:22 2021
    Hello Oli,

    Thursday September 09 2021, Oli wrote to Michael Dukelsky:

    HELP! ;)
    I'm trying to use the @me array in on_handshake(), but no matter
    what I do I always get the error:

    "Perl on_handshake(): @me contains no valid addresses"

    even with this simple sub:

    sub on_handshake
    {
    @me;
    }

    I've never used this hook but as far as I understand you have to
    put the AKAs you want to present to the @me array. The array in
    your sub contains no addresses, so you receive the error message.

    The side effects are a bit confusing:

    sub on_handshake
    {
    Log(3, "<<< on_handshake() >>>");
    }

    sub after_handshake
    {
    Log(3, "<<< after_handshake() >>> @me");
    }


    + 08:43 [1459] outgoing session with 127.0.0.1:24554
    - 08:43 [1459] <<< on_handshake() >>>
    + 08:43 [1459] Perl on_handshake(): @me contains no valid addresses
    - 08:43 [1459] OPT CRAM-MD5-fffdf8c077e8c9b94ce2e83d8da0a8ee
    [...]
    - 08:43 [1459] session in CRYPT mode
    - 08:43 [1459] <<< after_handshake() >>> 2000:1/2@fakenet
    4000:1/1@testnet


    I'm not sure if this is considered to be expected behavior or a bug?

    Well, from my POV the binkd behavior looks logical here. If you specified the values of the @me array, then only the AKA specified in that array would be presented. Since you did not specify any values in @me, binkd presented all of your AKAs during the handshake. In after_handshake() hook, you see the AKAs that were presented during the handshake.

    "Perl on_handshake(): @me contains no valid addresses" is here rather not an error message but a warning.

    Michael

    ... node (at) f1042 (dot) ru
    --- GoldED+/LNX 1.1.5-b20180707
    * Origin: Moscow, Russia (2:5020/1042)
  • From Oli@2:280/464.47 to Michael Dukelsky on Thu Sep 9 10:51:50 2021
    Michael wrote (2021-09-09):

    The side effects are a bit confusing:

    sub on_handshake
    {
    Log(3, "<<< on_handshake() >>>");
    }

    sub after_handshake
    {
    Log(3, "<<< after_handshake() >>> @me");
    }


    + 08:43 [1459] outgoing session with 127.0.0.1:24554
    - 08:43 [1459] <<< on_handshake() >>>
    + 08:43 [1459] Perl on_handshake(): @me contains no valid addresses
    - 08:43 [1459] OPT CRAM-MD5-fffdf8c077e8c9b94ce2e83d8da0a8ee
    [...]
    - 08:43 [1459] session in CRYPT mode
    - 08:43 [1459] <<< after_handshake() >>> 2000:1/2@fakenet
    4000:1/1@testnet


    I'm not sure if this is considered to be expected behavior or a
    bug?

    Well, from my POV the binkd behavior looks logical here. If you specified the values of the @me array, then only the AKA specified in that array would be presented. Since you did not specify any values in @me, binkd presented all of your AKAs during the handshake. In after_handshake() hook, you see the AKAs that were presented during the handshake.

    "Perl on_handshake(): @me contains no valid addresses" is here rather not an error message but a warning.


    What I find strange is that there is a warning message even if I don't use @me in on_handshake() at all. From my POV it would be more logical, if @me would already initialized with my AKAs and @me = () would let binkd send an "M_BSY: No AKAs in common domains or all AKAs are busy".

    Anyway, even if the warning is more confusing than helping, it does work and it can be ignored.

    ---
    * Origin: 1995| Invention of the Cookie. The End. (2:280/464.47)