AllStarLink / app_rpt

Refactoring and upgrade of AllStarLink's app_rpt, etc.
9 stars 8 forks source link

res-rpt-http-registrations.so: Incorrectly Shows Registered #325

Closed tsawyer closed 5 months ago

tsawyer commented 6 months ago

HTTP registration command rpt show registry incorrectly shows Registered when user has entered a wrong node password.

tsawyer commented 6 months ago

I helped a new tester with setting up an ASL3 Pi install. He could not connect. rpt show registrations showed registered but was not in DNS or nodes list. We switched him to IAX registration and got a reply suggesting the password was wrong. Sure enough it was wrong.

InterLinked1 commented 6 months ago

I helped a new tester with setting up an ASL3 Pi install. He could not connect. rpt show registrations showed registered but was not in DNS or nodes list. We switched him to IAX registration and got a reply suggesting the password was wrong. Sure enough it was wrong.

Can you include the relevant debug output for this module?

core set debug 10 res_rpt_http_registrations

tsawyer commented 6 months ago

core set debug 10 res_rpt_http_registrations

With correct password...

Connected to Asterisk 20.6.0 currently running on Rack (pid = 538526)
[2024-05-14 14:11:04.000] DEBUG[538606]: res_rpt_http_registrations.c:280 do_refresh: Doing periodic registrations
[2024-05-14 14:11:04.000] DEBUG[538606]: res_rpt_http_registrations.c:235 http_register: Making request to https://register.allstarlink.org/ with data '{"port":4567,"data":{"nodes":{"2509":{"node":"2509","passwd":"435009","remote":0}}}}'
[2024-05-14 14:11:04.228] DEBUG[538606]: res_rpt_http_registrations.c:165 curl_post: Response: {"ipaddr":"47.153.23.156","port":4569,"refresh":179,"data":["2509 successfully registered."]}
[2024-05-14 14:11:04.228] DEBUG[538606]: res_rpt_http_registrations.c:244 http_register: Received response data: {"ipaddr":"47.153.23.156","port":4569,"refresh":179,"data":["2509 successfully registered."]}
[2024-05-14 14:11:04.228] DEBUG[538606]: res_rpt_http_registrations.c:254 http_register: Response: ipaddr=47.153.23.156, port=4569, refresh=179, data=["2509 successfully registered."]
Rack*CLI> core set debug 10 res_rpt_http_registrations
Rack*CLI> rpt show registrations
Host                                           Username    Perceived                            Refresh  State
162.248.92.131:443                             2509        47.153.23.156:4569                       179  Registered
1 HTTP registration.
Rack*CLI>

With wrong password...

module refresh res_rpt_http_registrations.so
Unloaded and loaded res_rpt_http_registrations.so
[2024-05-14 14:15:08.276]  Unloading res_rpt_http_registrations.so
[2024-05-14 14:15:08.270] DEBUG[541709]: res_rpt_http_registrations.c:502 load_config: Registration interval: 60
[2024-05-14 14:15:08.270] DEBUG[541709]: res_rpt_http_registrations.c:454 parse_register: Loaded HTTP registration: 2509:a435009@register.allstarlink.org
[2024-05-14 14:15:08.275] DEBUG[541709]: res_rpt_http_registrations.c:367 get_bindport: Our IAX2 bindport is 4567
[2024-05-14 14:15:08.276]  Loaded res_rpt_http_registrations.so => (RPT HTTP Periodic Registrations)
[2024-05-14 14:15:08.276] DEBUG[541727]: res_rpt_http_registrations.c:280 do_refresh: Doing periodic registrations
[2024-05-14 14:15:08.276] DEBUG[541727]: res_rpt_http_registrations.c:235 http_register: Making request to https://register.allstarlink.org/ with data '{"port":4567,"data":{"nodes":{"2509":{"node":"2509","passwd":"a435009","remote":0}}}}'
[2024-05-14 14:15:09.026] DEBUG[541727]: res_rpt_http_registrations.c:165 curl_post: Response: {"ipaddr":"47.153.23.156","port":4569,"refresh":179,"data":["2509 failed authentication. Please check your password and node number."]}
[2024-05-14 14:15:09.026] DEBUG[541727]: res_rpt_http_registrations.c:244 http_register: Received response data: {"ipaddr":"47.153.23.156","port":4569,"refresh":179,"data":["2509 failed authentication. Please check your password and node number."]}
[2024-05-14 14:15:09.026] DEBUG[541727]: res_rpt_http_registrations.c:254 http_register: Response: ipaddr=47.153.23.156, port=4569, refresh=179, data=["2509 failed authentication. Please check your password and node number."]
Rack*CLI>
Rack*CLI> rpt show registrations
Host                                           Username    Perceived                            Refresh  State
34.105.111.212:443                             2509        47.153.23.156:4569                       179  Registered
1 HTTP registration.
InterLinked1 commented 6 months ago

core set debug 10 res_rpt_http_registrations

With correct password...

Connected to Asterisk 20.6.0 currently running on Rack (pid = 538526)
[2024-05-14 14:11:04.000] DEBUG[538606]: res_rpt_http_registrations.c:280 do_refresh: Doing periodic registrations
[2024-05-14 14:11:04.000] DEBUG[538606]: res_rpt_http_registrations.c:235 http_register: Making request to https://register.allstarlink.org/ with data '{"port":4567,"data":{"nodes":{"2509":{"node":"2509","passwd":"435009","remote":0}}}}'
[2024-05-14 14:11:04.228] DEBUG[538606]: res_rpt_http_registrations.c:165 curl_post: Response: {"ipaddr":"47.153.23.156","port":4569,"refresh":179,"data":["2509 successfully registered."]}
[2024-05-14 14:11:04.228] DEBUG[538606]: res_rpt_http_registrations.c:244 http_register: Received response data: {"ipaddr":"47.153.23.156","port":4569,"refresh":179,"data":["2509 successfully registered."]}
[2024-05-14 14:11:04.228] DEBUG[538606]: res_rpt_http_registrations.c:254 http_register: Response: ipaddr=47.153.23.156, port=4569, refresh=179, data=["2509 successfully registered."]
Rack*CLI> core set debug 10 res_rpt_http_registrations
Rack*CLI> rpt show registrations
Host                                           Username    Perceived                            Refresh  State
162.248.92.131:443                             2509        47.153.23.156:4569                       179  Registered
1 HTTP registration.
Rack*CLI>

With wrong password...

module refresh res_rpt_http_registrations.so
Unloaded and loaded res_rpt_http_registrations.so
[2024-05-14 14:15:08.276]  Unloading res_rpt_http_registrations.so
[2024-05-14 14:15:08.270] DEBUG[541709]: res_rpt_http_registrations.c:502 load_config: Registration interval: 60
[2024-05-14 14:15:08.270] DEBUG[541709]: res_rpt_http_registrations.c:454 parse_register: Loaded HTTP registration: 2509:a435009@register.allstarlink.org
[2024-05-14 14:15:08.275] DEBUG[541709]: res_rpt_http_registrations.c:367 get_bindport: Our IAX2 bindport is 4567
[2024-05-14 14:15:08.276]  Loaded res_rpt_http_registrations.so => (RPT HTTP Periodic Registrations)
[2024-05-14 14:15:08.276] DEBUG[541727]: res_rpt_http_registrations.c:280 do_refresh: Doing periodic registrations
[2024-05-14 14:15:08.276] DEBUG[541727]: res_rpt_http_registrations.c:235 http_register: Making request to https://register.allstarlink.org/ with data '{"port":4567,"data":{"nodes":{"2509":{"node":"2509","passwd":"a435009","remote":0}}}}'
[2024-05-14 14:15:09.026] DEBUG[541727]: res_rpt_http_registrations.c:165 curl_post: Response: {"ipaddr":"47.153.23.156","port":4569,"refresh":179,"data":["2509 failed authentication. Please check your password and node number."]}
[2024-05-14 14:15:09.026] DEBUG[541727]: res_rpt_http_registrations.c:244 http_register: Received response data: {"ipaddr":"47.153.23.156","port":4569,"refresh":179,"data":["2509 failed authentication. Please check your password and node number."]}
[2024-05-14 14:15:09.026] DEBUG[541727]: res_rpt_http_registrations.c:254 http_register: Response: ipaddr=47.153.23.156, port=4569, refresh=179, data=["2509 failed authentication. Please check your password and node number."]
Rack*CLI>
Rack*CLI> rpt show registrations
Host                                           Username    Perceived                            Refresh  State
34.105.111.212:443                             2509        47.153.23.156:4569                       179  Registered
1 HTTP registration.

Looks like the current logic considers it registered if a refresh interval is returned, which it is in both cases. Is that intentional? How should it be determined if it succeeded or not? Certain response code, or something else?

tsawyer commented 6 months ago

The response shows a failed registration message in the second debug.

InterLinked1 commented 6 months ago

The response shows a failed registration message in the second debug.

Sure, but that's a human readable message, it's not intended to be machine parseable. I'm assuming there's some other way that's intended.

tsawyer commented 6 months ago

The response to rpt show registrations is intended to be human readable. The State should showed Failed or similar with a bad password.

Host                                           Username    Perceived                            Refresh  State
34.105.111.212:443                             2506        47.153.23.156:4569                       179  Registered
1 HTTP registration.
InterLinked1 commented 6 months ago

The response to rpt show registrations is intended to be human readable. The State should showed Failed or similar.

Host                                           Username    Perceived                            Refresh  State
34.105.111.212:443                             2506        47.153.23.156:4569                       179  Registered
1 HTTP registration.

I'm not talking about the CLI command, I'm talking about the registration API. In order to determine if it's registered or failed, it needs to know that from the API response. Right now, there doesn't seem to be any indication of whether it succeeded or not apart from a human readable description, which is generally not considered appropriate for machine consumption. That's why I was wondering if I'm missing something.

tsawyer commented 6 months ago

We can't change what the server returns at this point.

tsawyer commented 6 months ago

The https registration API returns a number of failure messages including from this snip:

           if (!UserNode::verifyPassword($nodeNumber, $data['passwd'])) {
                $messages[] = "$nodeNumber failed authentication. Please check your password and node number.";
                continue;
            }

If all the checks pass then this:

            $messages[] = "$nodeNumber successfully registered.";

There are no machine readable return codes.

At this point all that can be done is to check for a "successfully registered" string and print Registered. Otherwise print Failed or Not Registered.

For what it's worth, app_rpt itself isn't doing anything with this response. Valid IAX registration is tested elsewhere.

Of course there can be more than one registration per server:

rpt show registrations
Host                                           Username    Perceived                            Refresh  State
34.105.111.212:443                             25334       47.153.23.156:4567                       179  Registered
34.105.111.212:443                             2509        47.153.23.156:4567                       179  Registered
2 HTTP registrations.
tsawyer commented 6 months ago

@InterLinked1 What is your preference on this? How do we proceed?

Is this json not machine readable?

Good response:

[2024-05-23 08:30:21.000] DEBUG[38309] res_rpt_http_registrations.c: Doing periodic registrations
[2024-05-23 08:30:21.000] DEBUG[38309] res_rpt_http_registrations.c: Making request to https://register.allstarlink.org/ with data '{"port":4569,"data":{"nodes":{"2501":{"node":"2501","passwd":"hidden","remote":0}}}}'
[2024-05-23 08:30:21.396] DEBUG[38309] res_rpt_http_registrations.c: Response: {"ipaddr":"192.5.222.91","port":4569,"refresh":179,"data":["2501 successfully registered."]}
[2024-05-23 08:30:21.396] DEBUG[38309] res_rpt_http_registrations.c: Received response data: {"ipaddr":"192.5.222.91","port":4569,"refresh":179,"data":["2501 successfully registered."]}
[2024-05-23 08:30:21.396] DEBUG[38309] res_rpt_http_registrations.c: Response: ipaddr=192.5.222.91, port=4569, refresh=179, data=["2501 successfully registered."]

Bad response:

[2024-05-23 08:37:38.082] DEBUG[43444] res_rpt_http_registrations.c: Doing periodic registrations
[2024-05-23 08:37:38.082] DEBUG[43444] res_rpt_http_registrations.c: Making request to https://register.allstarlink.org/ with data '{"port":4569,"data":{"nodes":{"2501":{"node":"2501","passwd":"hidden","remote":0}}}}'
[2024-05-23 08:37:39.008] DEBUG[43444] res_rpt_http_registrations.c: Response: {"ipaddr":"192.5.222.91","port":4569,"refresh":179,"data":["2501 failed authentication. Please check your password and node number."]}
[2024-05-23 08:37:39.008] DEBUG[43444] res_rpt_http_registrations.c: Received response data: {"ipaddr":"192.5.222.91","port":4569,"refresh":179,"data":["2501 failed authentication. Please check your password and node number."]}
[2024-05-23 08:37:39.008] DEBUG[43444] res_rpt_http_registrations.c: Response: ipaddr=192.5.222.91, port=4569, refresh=179, data=["2501 failed authentication. Please check your password and node number."]