Update uS, add AsyncSocket::getRemoteAddress()
This commit is contained in:
@@ -87,6 +87,14 @@ protected:
|
|||||||
return getAsyncSocketData()->buffer.size();
|
return getAsyncSocketData()->buffer.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Returns the remote IP address or empty string on failure */
|
||||||
|
std::string_view getRemoteAddress() {
|
||||||
|
static thread_local char buf[16];
|
||||||
|
int ipLength = 16;
|
||||||
|
us_new_socket_remote_address(SSL, (us_new_socket_t *) this, buf, &ipLength);
|
||||||
|
return std::string_view(buf, ipLength);
|
||||||
|
}
|
||||||
|
|
||||||
/* Write in three levels of prioritization: cork-buffer, syscall, socket-buffer. Always drain if possible.
|
/* Write in three levels of prioritization: cork-buffer, syscall, socket-buffer. Always drain if possible.
|
||||||
* Returns pair of bytes written (anywhere) and wheter or not this call resulted in the polling for
|
* Returns pair of bytes written (anywhere) and wheter or not this call resulted in the polling for
|
||||||
* writable (or we are in a state that implies polling for writable). */
|
* writable (or we are in a state that implies polling for writable). */
|
||||||
|
|||||||
+1
-1
@@ -59,7 +59,7 @@ private:
|
|||||||
/* Init the HttpContext by registering libusockets event handlers */
|
/* Init the HttpContext by registering libusockets event handlers */
|
||||||
HttpContext<SSL> *init() {
|
HttpContext<SSL> *init() {
|
||||||
/* Handle socket connections */
|
/* Handle socket connections */
|
||||||
us_new_socket_context_on_open(SSL, getSocketContext(), [](auto *s, int is_client) {
|
us_new_socket_context_on_open(SSL, getSocketContext(), [](auto *s, int is_client, char *ip, int ip_length) {
|
||||||
/* Any connected socket should timeout until it has a request */
|
/* Any connected socket should timeout until it has a request */
|
||||||
us_new_socket_timeout(SSL, s, HTTP_IDLE_TIMEOUT_S);
|
us_new_socket_timeout(SSL, s, HTTP_IDLE_TIMEOUT_S);
|
||||||
|
|
||||||
|
|||||||
@@ -167,6 +167,8 @@ public:
|
|||||||
/* Immediately terminate this Http response */
|
/* Immediately terminate this Http response */
|
||||||
using Super::close;
|
using Super::close;
|
||||||
|
|
||||||
|
using Super::getRemoteAddress;
|
||||||
|
|
||||||
/* Note: Headers are not checked in regards to timeout.
|
/* Note: Headers are not checked in regards to timeout.
|
||||||
* We only check when you actively push data or end the request */
|
* We only check when you actively push data or end the request */
|
||||||
|
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ public:
|
|||||||
|
|
||||||
/* See AsyncSocket */
|
/* See AsyncSocket */
|
||||||
using Super::getBufferedAmount;
|
using Super::getBufferedAmount;
|
||||||
|
using Super::getRemoteAddress;
|
||||||
|
|
||||||
/* Simple, immediate close of the socket. Emits close event */
|
/* Simple, immediate close of the socket. Emits close event */
|
||||||
using Super::close;
|
using Super::close;
|
||||||
|
|||||||
+1
-1
Submodule uSockets updated: a83f8423af...824ff9708b
Reference in New Issue
Block a user