proxy: Handle Uri-Host correctly when using Proxy-Scheme

Updated documentation at the same time.
This commit is contained in:
Jon Shallow authored and Jon Shallow committed 2024-05-29 10:20:57 +01:00
1 parent 5171694d09
commit c830c15551
4 files changed
+39 -4

No files matched your search

+3 -1
View File
@@ -567,7 +567,8 @@ usage(const char *program, const char *version) {
"\t \t\tScheme, address and optional port to define how to\n"
"\t \t\tconnect to a CoAP proxy (automatically adds Proxy-Uri\n"
"\t \t\toption to request) to forward the request to.\n"
"\t \t\tScheme is one of coap, coaps, coap+tcp and coaps+tcp\n"
"\t \t\tScheme is one of coap, coaps, coap+tcp, coaps+tcp,\n"
"\t \t\tcoap+ws, and coaps+ws\n"
"\t-T token\tDefine the initial starting token (up to 24 characters)\n"
"\t-U \t\tNever include Uri-Host or Uri-Port options\n"
"\t-V num \t\tVerbosity level (default 3, maximum is 7) for (D)TLS\n"
@@ -641,6 +642,7 @@ usage(const char *program, const char *version) {
"\tcoap-client -m get coaps://%%2Funix%%2Fdomain%%2Fpath%%2Fdtls/.well-known/core\n"
"\tcoap-client -m get coaps+tcp://%%2Funix%%2Fdomain%%2Fpath%%2Ftls/.well-known/core\n"
"\tcoap-client -m get -T cafe coap://[::1]/time\n"
"\tcoap-client -m get -T cafe -P coap://upstream-proxy coap://[::1]/time\n"
"\techo -n 1000 | coap-client -m put -T cafe coap://[::1]/time -f -\n"
);
}
+11 -1
View File
@@ -674,6 +674,14 @@ get_uri_proxy_scheme_info(const coap_pdu_t *request,
strncasecmp(opt_val, "coap", 4) == 0) {
uri->scheme = COAP_URI_SCHEME_COAP;
uri->port = COAP_DEFAULT_PORT;
} else if (opt_len == 7 &&
strncasecmp(opt_val, "coap+ws", 7) == 0) {
uri->scheme = COAP_URI_SCHEME_COAP_WS;
uri->port = 80;
} else if (opt_len == 8 &&
strncasecmp(opt_val, "coaps+ws", 8) == 0) {
uri->scheme = COAP_URI_SCHEME_COAPS_WS;
uri->port = 443;
} else {
coap_log_warn("Unsupported Proxy Scheme '%*.*s'\n",
opt_len, opt_len, opt_val);
@@ -1123,6 +1131,7 @@ hnd_proxy_uri(coap_resource_t *resource COAP_UNUSED,
case COAP_OPTION_PROXY_SCHEME:
case COAP_OPTION_URI_PATH:
case COAP_OPTION_URI_PORT:
case COAP_OPTION_URI_HOST:
case COAP_OPTION_URI_QUERY:
if (proxy_scheme_option) {
/* Need to add back in */
@@ -2210,7 +2219,8 @@ usage(const char *program, const char *version) {
"\t \t\tfinal endpoint. If scheme://address[:port] is not\n"
"\t \t\tdefined before the leading , (comma) of the first name,\n"
"\t \t\tthen the ongoing connection will be a direct connection.\n"
"\t \t\tScheme is one of coap, coaps, coap+tcp and coaps+tcp\n"
"\t \t\tScheme is one of coap, coaps, coap+tcp, coaps+tcp,\n"
"\t \t\tcoap+ws, and coaps+ws. http(s) is not currently supported\n"
"\t-T max_token_length\tSet the maximum token length (8-65804)\n"
"\t-U type\t\tTreat address defined by -A as a Unix socket address.\n"
"\t \t\ttype is 'coap', 'coaps', 'coap+tcp' or 'coaps+tcp'\n"
+8 -1
View File
@@ -179,7 +179,7 @@ OPTIONS - General
*-P* scheme://addr[:port]::
Scheme, address and optional port to define how to connect to a CoAP proxy
(automatically adds Proxy-Uri option to request) to forward the request to.
Scheme is one of coap, coaps, coap+tcp and coaps+tcp.
Scheme is one of coap, coaps, coap+tcp, coaps+tcp, coap+ws, and coaps+ws.
*-T* token::
Define the initial starting 'token' for the request (up to 24 characters).
@@ -279,6 +279,13 @@ coap-client -m get coap://[::1]/
Query the resource '/' on localhost using the 'GET' method to get back the
summary information.
* Example
----
coap-client -m get -P coap://upstream-proxy coap://[::1]/
----
Query the resource '/' on 'upstream-proxy' using the 'GET' method to get back
the summary information.
* Example
----
coap-client -m get coap://%2Fsome%2Funix%2Fdomain%2Fpath/time
+17 -1
View File
@@ -138,7 +138,8 @@ OPTIONS - General
then this server is considered to be the final endpoint. If
scheme://address[:port] is not defined before the leading , (comma) of the
first name, then the ongoing connection will be a direct connection.
Scheme is one of coap, coaps, coap+tcp and coaps+tcp.
Scheme is one of coap, coaps, coap+tcp, coaps+tcp, coap+ws, and coaps+ws.
http and https not currently supported.
*-T* max_token_size::
Set the maximum token length (8-65804).
@@ -293,6 +294,21 @@ coap-server -A 2001:db8:81a8:0:6ef0:dead:feed:beef -g FF02::FD
Set listening address to '2001:db8:81a8:0:6ef0:dead:feed:beef' and join the
All CoAP Nodes multicast group 'FF02::FD'.
* Example
----
coap-server -P, -A ::1
----
Let the server listen on localhost (port '5683') for UDP/TCP, as well as
accept any CoAP proxy requests and directly respond to them.
* Example
----
coap-server -P coap://upstream-proxy, -A ::1
----
Let the server listen on localhost (port '5683') for UDP/TCP, and then
open an upstream coap session to 'upstream-proxy' for proxying onwards
the CoAP client's request.
FILES
------
There are no configuration files.