Store detected hosts in server memory (closes #37) #54

Merged
luca0N merged 5 commits from dev_server_history into dev 2026-02-17 20:40:27 +00:00
Owner

Implement a history of detected hosts in the Lanbassador server, so that the client has a way of displaying hosts that were previously detected when the page is opened for the first time by an end user.

To enforce good client etiquette, the QUERY_HISTORY command shall be requested only once during a connection, reducing the possibility of denial of service (DoS) attacks.

  • Server
    • Store detected hosts in the server memory
    • Implement QUERY_HISTORY packet action for querying the server detected host history
    • Modify LanbassadorDetectedHost so that it also includes information on the detection timestamp
    • Refactor the code (moved to #56)
  • Client
    • Send the QUERY_HISTORY packet action right after displaying the page
    • Display hosts from the server history
Implement a history of detected hosts in the Lanbassador server, so that the client has a way of displaying hosts that were previously detected when the page is opened for the first time by an end user. To enforce good client etiquette, the `QUERY_HISTORY` command shall be requested only once during a connection, reducing the possibility of denial of service (DoS) attacks. - [x] Server - [x] Store detected hosts in the server memory - [x] Implement `QUERY_HISTORY` packet action for querying the server detected host history - [x] Modify `LanbassadorDetectedHost` so that it also includes information on the detection timestamp - ~Refactor the code~ (moved to #56) - [x] Client - [x] Send the `QUERY_HISTORY` packet action right after displaying the page - [x] Display hosts from the server history
luca0N self-assigned this 2026-02-15 20:11:02 +00:00
When a new host is detected by liblanbassador, store it in the server
memory by using a map static variable.  This variable will then be
queried by the server when a client requests a list of previously
detected hosts. This is useful when it's connecting for the first time
and doesn't have any entries to display initially.
luca0N changed title from Store detected hosts in server memory (closes #37) to WIP: Store detected hosts in server memory (closes #37) 2026-02-15 20:11:05 +00:00
Author
Owner

Since the LanbassadorDetectedHost struct is being repurposed to store detected hosts in memory, I think it should be changed to include a new field that stores the detection timestamp. The reasoning behind this is that I am not sure whether iterating through that map will get us entries in the order they were assigned to the map. Regardless, the client still would not know the time at which the hosts were detected, so there would be no way of displaying that information when opening the host list.

Since [the `LanbassadorDetectedHost` struct is being repurposed to store detected hosts in memory](https://git.luca0n.com/luca0N/lanbassador/src/commit/b90461a748e1f2311c068b56b5a864e601d2defb/server/main.go#L45), I think it should be changed to include a new field that stores the detection timestamp. The reasoning behind this is that I am not sure whether iterating through that map will get us entries in the order they were assigned to the map. Regardless, the client still would not know the time at which the hosts were detected, so there would be no way of displaying that information when opening the host list.
Implement code to support the new QUERY_HISTORY request action, which
returns to the requesting client an array of previously detected hosts.
This commit does not modify the `LanbassadorDetectedHost' struct to
include a new field for detection timestamps, and it also lacks some
refactoring (which will be added in a separate commit).
luca0N force-pushed dev_server_history from 3b58923fa9 to e77eead99d 2026-02-16 14:03:10 +00:00 Compare
Author
Owner

The previous force-push changes the casing in the commit message in e77eead99d. No other changes were made.

The previous force-push changes the casing in the commit message in e77eead99d. No other changes were made.
Author
Owner

I went ahead and added two new items to the checklist so that the server can provide clients with detection timestamps, and to refactor the affected server code.

I've been quite busy with IRL stuff as of late so this pacing is the best I can do for now.

I went ahead and added two new items to the checklist so that the server can provide clients with detection timestamps, and to refactor the affected server code. I've been quite busy with IRL stuff as of late so this pacing is the best I can do for now.
In the server code, create a new field in the `LanbassadorDetectedHost'
struct so that it supplies clients with a timestamp of each detection.
This way, clients will know the exact time of detection when the
server-client connection is unstable, or if the client is querying the
server detection history.
Add support for the new server action `QUERY_HISTORY' request, which
causes the server to return an array of past detections.

These detections are not sorted, so sorting is currently done every time
a new detection is received in the web app.  This will likely result in
poor performance for very large networks, and so, a future commit should
address this.
Update the internationalization web app `messages' files to address a
new `$localize' string used in `host-list.ts', which is a message that
is displayed in the user-agent console.
luca0N changed title from WIP: Store detected hosts in server memory (closes #37) to Store detected hosts in server memory (closes #37) 2026-02-17 20:39:32 +00:00
Author
Owner

I went ahead and modified the checklist one more time to remove an entry about refactoring the server code. The refactoring that I have in mind will affect some other parts of the code, so I think it's best to keep it outside of this pull request.

I went ahead and modified the checklist one more time to remove an entry about refactoring the server code. The refactoring that I have in mind will affect some other parts of the code, so I think it's best to keep it outside of this pull request.
luca0N deleted branch dev_server_history 2026-02-17 20:40:27 +00:00
Author
Owner

As mentioned in commit becebe192e, I am afraid that sorting the host list every time a new detection is received from the server will degrade the performance, specifically for very busy networks and servers with high availability.

This problem is now being tracked on issue #57.

As mentioned in commit becebe192e, I am afraid that sorting the host list every time a new detection is received from the server will degrade the performance, specifically for very busy networks and servers with high availability. This problem is now being tracked on issue #57.
Author
Owner

Another thing that I forgot to mention is that the client expects responses from the server with action RET_SUCCESS to be QUERY_HISTORY responses. Since there's not much back and forth between the client and the server, I figured assumption was appropriate in this case. Nonetheless, I added a class variable for keeping track of the last request (which will likely need some work due to the potential for concurrency).

Should more actions be implemented in the future, then the code would have to be enhanced in this regard.

Another thing that I forgot to mention is that the client expects responses from the server with action `RET_SUCCESS` to be `QUERY_HISTORY` responses. Since there's not much back and forth between the client and the server, I figured assumption was appropriate in this case. Nonetheless, I added a [class variable](https://git.luca0n.com/luca0N/lanbassador/src/commit/becebe192ea285f4824492cdb0b8c475fa8fc790/client/src/app/host-list.ts#L93) for keeping track of the last request (which will likely need some work due to the potential for concurrency). Should more actions be implemented in the future, then the code would have to be enhanced in this regard.
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
luca0N/lanbassador!54
No description provided.