Allow dots in client hostnames
I rely on the HOSTNAME environment variable in my connect/disconnect scripts and have observed that it is empty for many clients.
Further investigation revealed that all affected clients have a dot character in their hostname. Common examples include:
-
MacBook-Air.local(approximately 80% of cases) Laptop.lanMPB.dlink
While these are predominantly macOS clients (Apple commonly uses .local hostnames), the issue is not exclusive to Apple devices - suffixes like .lan and .dlink are also quite common.
Currently, ocserv rejects hostnames containing dots ('.') as invalid.
This validation is overly restrictive. Even if a client reports a name like 192.168.1.2, it is prefereable to retain this information rather than have no hostname data at all.
This MR relaxes hostname validation to allow dots in non-initial positions.
Checklist
-
Code modified for feature -
Test suite updated with functionality tests -
Documentation updated / NEWS entry present (for non-trivial changes)
Reviewer's checklist:
-
Any issues marked for closing are addressed -
There is a test suite reasonably covering new functionality or modifications -
Function naming, parameters, return values, types, etc., are consistent and according to CONTRIBUTING.md -
This feature/change has adequate documentation added -
No obvious mistakes in the code