Skip to content

Commit

Permalink
Add "mg_get_local_addr". Return the local listening address used.
Browse files Browse the repository at this point in the history
civetweb can listen to multiple addresses.  Some of these can have
ssl enabled, and some not.  The "using_ssl" flag is
already returned to the client, but the local address (lsa) is not,
This allows a calling application to determine on which local
address/portno a connection was accepted.

Signed-off-by: Marcus Watts <[email protected]>
  • Loading branch information
mdw-at-linuxbox committed Nov 3, 2016
1 parent 0c30720 commit ad8d91f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
4 changes: 4 additions & 0 deletions include/civetweb.h
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,10 @@ CIVETWEB_API int mg_modify_passwords_file(const char *passwords_file_name,
CIVETWEB_API const struct mg_request_info *
mg_get_request_info(const struct mg_connection *);

/* Return the local address (server side) of the socket for a connection */
CIVETWEB_API struct sockaddr *
mg_get_local_addr(struct mg_connection *);

/* Send data to the client.
Return:
0 when the connection has been closed
Expand Down
7 changes: 7 additions & 0 deletions src/civetweb.c
Original file line number Diff line number Diff line change
Expand Up @@ -1919,6 +1919,13 @@ mg_get_request_info(const struct mg_connection *conn)
}


struct sockaddr *
mg_get_local_addr(struct mg_connection *conn)
{
return &conn->client.lsa.sa;
}


/* Skip the characters until one of the delimiters characters found.
* 0-terminate resulting word. Skip the delimiter and following whitespaces.
* Advance pointer to buffer to the next word. Return found 0-terminated word.
Expand Down

0 comments on commit ad8d91f

Please sign in to comment.