Skip to content

Commit 946cacb

Browse files
committed
server session FEATURE any transport combination support
1 parent 7fe4f2c commit 946cacb

2 files changed

Lines changed: 29 additions & 13 deletions

File tree

src/session_server.c

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1716,8 +1716,6 @@ nc_ps_clear(struct nc_pollsession *ps, int all, void (*data_free)(void *))
17161716
nc_ps_unlock(ps, q_id, __func__);
17171717
}
17181718

1719-
#if defined(NC_ENABLED_SSH) || defined(NC_ENABLED_TLS)
1720-
17211719
static int
17221720
nc_get_uid(int sock, uid_t *uid)
17231721
{
@@ -2103,13 +2101,24 @@ nc_server_endpt_set_address_port(const char *endpt_name, const char *address, ui
21032101
}
21042102

21052103
if (sock > -1) {
2106-
#if defined(NC_ENABLED_SSH) && defined(NC_ENABLED_TLS)
2107-
VRB("Listening on %s:%u for %s connections.", address, port, (endpt->ti == NC_TI_LIBSSH ? "SSH" : "TLS"));
2108-
#elif defined(NC_ENABLED_SSH)
2109-
VRB("Listening on %s:%u for SSH connections.", address, port);
2110-
#else
2111-
VRB("Listening on %s:%u for TLS connections.", address, port);
2104+
switch (endpt->ti) {
2105+
case NC_TI_UNIX:
2106+
VRB("Listening on %s for UNIX connections.", address);
2107+
break;
2108+
#ifdef NC_ENABLED_SSH
2109+
case NC_TI_LIBSSH:
2110+
VRB("Listening on %s:%u for SSH connections.", address, port);
2111+
break;
21122112
#endif
2113+
#ifdef NC_ENABLED_TLS
2114+
case NC_TI_OPENSSL:
2115+
VRB("Listening on %s:%u for TLS connections.", address, port);
2116+
break;
2117+
#endif
2118+
default:
2119+
ERRINT;
2120+
break;
2121+
}
21132122
}
21142123

21152124
cleanup:
@@ -2128,12 +2137,16 @@ nc_server_endpt_set_address(const char *endpt_name, const char *address)
21282137
return nc_server_endpt_set_address_port(endpt_name, address, 0);
21292138
}
21302139

2140+
#if defined(NC_ENABLED_SSH) || defined(NC_ENABLED_TLS)
2141+
21312142
API int
21322143
nc_server_endpt_set_port(const char *endpt_name, uint16_t port)
21332144
{
21342145
return nc_server_endpt_set_address_port(endpt_name, NULL, port);
21352146
}
21362147

2148+
#endif
2149+
21372150
API int
21382151
nc_server_endpt_set_perms(const char *endpt_name, mode_t mode, uid_t uid, gid_t gid)
21392152
{
@@ -2363,6 +2376,8 @@ nc_accept(int timeout, struct nc_session **session)
23632376
return msgtype;
23642377
}
23652378

2379+
#if defined(NC_ENABLED_SSH) || defined(NC_ENABLED_TLS)
2380+
23662381
/* client is expected to be locked */
23672382
static int
23682383
_nc_server_ch_client_del_endpt(struct nc_ch_client *client, const char *endpt_name, NC_TRANSPORT_IMPL ti)

src/session_server.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -340,8 +340,6 @@ int nc_ps_poll(struct nc_pollsession *ps, int timeout, struct nc_session **sessi
340340
*/
341341
void nc_ps_clear(struct nc_pollsession *ps, int all, void (*data_free)(void *));
342342

343-
#if defined(NC_ENABLED_SSH) || defined(NC_ENABLED_TLS)
344-
345343
/**@} Server Session */
346344

347345
/**
@@ -400,9 +398,12 @@ int nc_server_is_endpt(const char *name);
400398
*/
401399
int nc_server_endpt_set_address(const char *endpt_name, const char *address);
402400

401+
#if defined(NC_ENABLED_SSH) || defined(NC_ENABLED_TLS)
402+
403403
/**
404404
* @brief Change endpoint listening port.
405405
*
406+
* This is only valid on SSH/TLS transport endpoint.
406407
* On error the previous listening socket (if any) is left untouched.
407408
*
408409
* @param[in] endpt_name Existing endpoint name.
@@ -411,10 +412,12 @@ int nc_server_endpt_set_address(const char *endpt_name, const char *address);
411412
*/
412413
int nc_server_endpt_set_port(const char *endpt_name, uint16_t port);
413414

415+
#endif
416+
414417
/**
415418
* @brief Change endpoint permissions.
416419
*
417-
* This is only valid on unix transport endpoint.
420+
* This is only valid on UNIX transport endpoint.
418421
* On error the previous listening socket (if any) is left untouched.
419422
*
420423
* @param[in] endpt_name Existing endpoint name.
@@ -466,8 +469,6 @@ int nc_server_endpt_set_keepalives(const char *endpt_name, int idle_time, int ma
466469
*/
467470
NC_MSG_TYPE nc_accept(int timeout, struct nc_session **session);
468471

469-
#endif /* NC_ENABLED_SSH || NC_ENABLED_TLS */
470-
471472
#ifdef NC_ENABLED_SSH
472473

473474
/**

0 commit comments

Comments
 (0)