CBielstein / APRSsharp

APRS# - Modern APRS software for the amateur radio community
MIT License
12 stars 5 forks source link

`AprsIsConnection` should save which APRS-IS server it is connected to #120

Closed CBielstein closed 2 years ago

CBielstein commented 2 years ago

Description

The AprsIsConnection object is used to connect to, authenticate with, and receive from APRS-IS servers. Given that we often use a rotating address, the actual connected server is often not known to the user. The server does identify itself in the auth response message, however.

This issue is to add parsing to AprsIsConnection to save that server name so that it can be exposed to the user and/or logged.

Acceptance Criteria

martelro commented 2 years ago

I would like to contribute with this enhancement. Please assign to me if you would like me to give it a go. Thanks.

CBielstein commented 2 years ago

I would like to contribute with this enhancement. Please assign to me if you would like me to give it a go. Thanks.

@martelro Great, it's yours! Always happy to have help. 😊 Let me know and I'm happy to provide examples of server messages or discuss the change!

martelro commented 2 years ago

Thank you, @CBielstein for the assignment!

Yes, I'd be happy to see any examples of server messages.

Also, do you have any preference/convention on what the property should be named? Would ConnectedServer or ConnectedServerName work?

CBielstein commented 2 years ago

@martelro Great! Here are some details!

Most of APRS Internet Service servers (to which this project connects) use the aprsc server software, so we can code to that. aprsc sends a response to a login request by a client with the following pattern: # logresp <clientCallsign> <verified|unverified>, server <serverName> (where anything in pointy brackets is replaced with an actual value)

I just ran several tests around the world to ensure this looked right and got the following response strings that you can use for examples and tests. (I used "N0CALL" string as a callsign (user ID) for connection. Consider it like "example.com" in that it points to nothing.)

Here are the result strings:

With the server names from these being T2ONTARIO, T2PERTH, T2BRAZIL, T2NANJING, and T2KA, respectively.

You'll see that the AprsIsClient is already reading for login responses from the server (albeit a bit primitively with startsWith and contains checks, but it gets the job done 😅): src/AprsIsClient/AprsIsClient.cs#135 to set the connection state. You should be able to piggy back on that and parse out the server name.

One request is that should the parsing fail, we shouldn't throw an exception or fail. Given the distributed nature and tinkerer culture of amateur radio operators, I think we're better off with flexibility than rigidity in this project.

For testing, we have an appropriately mocked out test of server response here: test/AprsIsClientUnitTests/ReceiveUnitTests.cs#57. You can either follow that pattern to write a new test or (and this might be easier) update the test to be a [Theory] and use [InlineData] and pass in various logresp and expected server values. Let me know if you're unfamiliar with xUnit theories and I'm happy to point to some examples. 😃

As far as property name, I think either of what you suggested sound just fine. I'll leave it to your choice!

Thanks again for the help here! Again, please let me know if you have any questions!

martelro commented 2 years ago

@CBielstein Thank you for the helpful information!