Add Remote IP on log file for invalid user or connexion#1653
Add Remote IP on log file for invalid user or connexion#1653drmanu011 wants to merge 1 commit intocoturn:masterfrom
Conversation
Added Remote IP logging on TURN_LOG_FUNC for invalid user, needed for protect turnserver with fail2ban Are you OK?
|
Hi @drmanu011 2 comments:
|
There was a problem hiding this comment.
Pull Request Overview
This PR enhances log messages by adding the remote IP address when logging invalid usernames or missing credentials.
- Adds remote IP logging to error messages in TURN_LOG_FUNC for invalid user credentials.
- Implements remote address extraction via addr_to_string and get_remote_addr_from_ioa_socket in two logging locations.
| if (!is_secure_string(usname, 1)) { | ||
| TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR, "session %018llu: %s: wrong username: %s\n", (unsigned long long)(ss->id), | ||
| __FUNCTION__, (char *)usname); | ||
| char saddr[129] = "\0"; |
There was a problem hiding this comment.
The code for obtaining the remote IP is duplicated. Consider extracting the IP retrieval logic into a separate helper function to improve maintainability.
| TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR, "session %018llu: %s: Cannot find credentials of user <%s>\n", | ||
| (unsigned long long)(ss->id), __FUNCTION__, (char *)usname); | ||
| char saddr[129] = "\0"; | ||
| addr_to_string(get_remote_addr_from_ioa_socket(ss->client_socket), (uint8_t *)saddr); |
There was a problem hiding this comment.
Duplicate remote IP extraction code is present here as well. Refactoring this logic into a common helper function could reduce code duplication and ease future maintenance.
| addr_to_string(get_remote_addr_from_ioa_socket(ss->client_socket), (uint8_t *)saddr); | |
| extract_remote_ip(ss->client_socket, saddr, sizeof(saddr)); |
|
@drmanu011 can you review the feedback received? |
|
Yes, it is easier to use a function rather than duplicating the code. |
Added Remote IP logging on TURN_LOG_FUNC for invalid user, needed for protect turnserver with fail2ban
Are you OK?