Closed anyc closed 2 months ago
I think when I first put this in place, I wanted to differentiate between an IP address of 1.2.3.4
and a filename of 1.2.3.4
(albeit an unlikely overlap).
Certainly when parsing a CoAP URI, this was implemented as starting with coap://%2F
(i.e. implicit leading /
for the file name following discussion (coap+unix://
was considered at one point)). So a filename of 1.2.3.4
is very unlikely to be used, but there is nothing stopping this being done programmatically rather than using the examples coap-client or coap-server.
coap_resolve_address_info()
now checks for leading %2F
or /
in the host name before treating it as a Unix Domain name, so 1.2.3.4
is not ambiguous.
So, from that perspective, there is no need for the '
s around around the file name.
I think it unlikely that things will get broken if the change is made. However, if coap_session_get_addr_local(session)->addr.sa.sa_family == AF_UNIX
, you just need to access coap_session_get_addr_local(session)->addr.cun.sun_path
to do your comparisons.
Thanks!
Hello,
in the
coap_print_addr()
function, the path to a unix domain socket is enclosed in quotations marks:https://github.com/obgm/libcoap/blob/a1a16f3f5a1ab0bbafdbd29ecd82f5011c637c9a/src/coap_debug.c#L258
Is there a specific reason why this is done?
In my code, I want to check over which endpoint a session has been started and I do a string comparison of the paths which becomes unnecessarily complicated with the quotation marks in my opinion. It is not a huge problem to work around this but if there is no need for the quotation marks I would open a PR to remove them. Or do you have concerns that this might break existing applications?
Thank you!