1
0
mirror of https://github.com/falk-werner/webfuse-provider synced 2026-03-02 04:09:18 +00:00

allow system to choose port of webfuse server

This commit is contained in:
Falk Werner
2020-06-12 13:32:31 +02:00
parent e72e78180e
commit 8a03f16aa5
9 changed files with 59 additions and 4 deletions

View File

@@ -37,6 +37,11 @@ void wf_server_interrupt(
wf_impl_server_interrupt(server);
}
int wf_server_get_port(
struct wf_server const * server)
{
return wf_impl_server_get_port(server);
}
// server protocol

View File

@@ -22,6 +22,7 @@ struct wf_server
struct lws_context * context;
struct lws_http_mount mount;
struct lws_context_creation_info info;
int port;
};
static bool wf_impl_server_tls_enabled(
@@ -55,6 +56,7 @@ static struct lws_context * wf_impl_server_context_create(
server->info.vhost_name = server->config.vhost_name;
server->info.ws_ping_pong_interval = 10;
server->info.options = LWS_SERVER_OPTION_HTTP_HEADERS_SECURITY_BEST_PRACTICES_ENFORCE;
server->info.options |= LWS_SERVER_OPTION_EXPLICIT_VHOSTS;
if (NULL == server->config.document_root)
{
@@ -71,8 +73,11 @@ static struct lws_context * wf_impl_server_context_create(
}
struct lws_context * const context = lws_create_context(&server->info);
return context;
struct lws_vhost * const vhost = lws_create_vhost(context, &server->info);
server->port = lws_get_vhost_port(vhost);
return context;
}
struct wf_server * wf_impl_server_create(
@@ -119,3 +124,8 @@ void wf_impl_server_interrupt(
lws_cancel_service(server->context);
}
extern int wf_impl_server_get_port(
struct wf_server const * server)
{
return server->port;
}

View File

@@ -28,6 +28,9 @@ extern void wf_impl_server_service(
extern void wf_impl_server_interrupt(
struct wf_server * server);
extern int wf_impl_server_get_port(
struct wf_server const * server);
#ifdef __cplusplus
}
#endif