Rename client_ip to connection_description

This commit is contained in:
matt335672
2021-08-27 12:14:52 +01:00
parent e867c925d5
commit 60016c1f75
13 changed files with 48 additions and 46 deletions
+4 -6
View File
@@ -1389,11 +1389,9 @@ g_sck_accept(int sck, char *addr, int addr_bytes, char *port, int port_bytes)
}
/*****************************************************************************/
/*
* TODO: this function writes not only IP address, name is confusing
*/
void
g_write_ip_address(int rcv_sck, char *ip_address, int bytes)
g_write_connection_description(int rcv_sck, char *description, int bytes)
{
char *addr;
int port;
@@ -1454,13 +1452,13 @@ g_write_ip_address(int rcv_sck, char *ip_address, int bytes)
if (ok)
{
g_snprintf(ip_address, bytes, "%s:%d - socket: %d", addr, port, rcv_sck);
g_snprintf(description, bytes, "%s:%d - socket: %d", addr, port, rcv_sck);
}
}
if (!ok)
{
g_snprintf(ip_address, bytes, "NULL:NULL - socket: %d", rcv_sck);
g_snprintf(description, bytes, "NULL:NULL - socket: %d", rcv_sck);
}
g_free(addr);
+2 -1
View File
@@ -93,7 +93,8 @@ int g_sck_socket_ok(int sck);
int g_sck_can_send(int sck, int millis);
int g_sck_can_recv(int sck, int millis);
int g_sck_select(int sck1, int sck2);
void g_write_ip_address(int rcv_sck, char *ip_address, int bytes);
void g_write_connection_description(int rcv_sck,
char *description, int bytes);
void g_sleep(int msecs);
tintptr g_create_wait_obj(const char *name);
tintptr g_create_wait_obj_from_socket(tintptr socket, int write);
+1 -1
View File
@@ -91,7 +91,7 @@ struct xrdp_client_info
int rdp5_performanceflags;
int brush_cache_code; /* 0 = no cache 1 = 8x8 standard cache
2 = arbitrary dimensions */
char client_ip[256];
char connection_description[256];
int max_bpp;
int jpeg; /* non standard bitmap cache v2 cap */
int offscreen_support_level;
+4 -2
View File
@@ -378,8 +378,10 @@ xrdp_rdp_create(struct xrdp_session *session, struct trans *trans)
self->client_info.cache3_entries = 262;
self->client_info.cache3_size = 4096;
/* load client ip info */
bytes = sizeof(self->client_info.client_ip) - 1;
g_write_ip_address(trans->sck, self->client_info.client_ip, bytes);
bytes = sizeof(self->client_info.connection_description) - 1;
g_write_connection_description(trans->sck,
self->client_info.connection_description,
bytes);
self->mppc_enc = mppc_enc_new(PROTO_RDP_50);
#if defined(XRDP_NEUTRINORDP)
self->rfx_enc = rfx_context_new();
+10 -10
View File
@@ -307,24 +307,24 @@ scp_session_set_directory(struct SCP_SESSION *s, const char *str)
/*******************************************************************/
int
scp_session_set_client_ip(struct SCP_SESSION *s, const char *str)
scp_session_set_connection_description(struct SCP_SESSION *s, const char *str)
{
if (0 == str)
{
LOG(LOG_LEVEL_WARNING, "[session:%d] set_client_ip: null ip", __LINE__);
LOG(LOG_LEVEL_WARNING, "[session:%d] set_connection_description: null description", __LINE__);
return 1;
}
if (0 != s->client_ip)
if (0 != s->connection_description)
{
g_free(s->client_ip);
g_free(s->connection_description);
}
s->client_ip = g_strdup(str);
s->connection_description = g_strdup(str);
if (0 == s->client_ip)
if (0 == s->connection_description)
{
LOG(LOG_LEVEL_WARNING, "[session:%d] set_client_ip: strdup error", __LINE__);
LOG(LOG_LEVEL_WARNING, "[session:%d] set_connection_description: strdup error", __LINE__);
return 1;
}
@@ -439,7 +439,7 @@ scp_session_destroy(struct SCP_SESSION *s)
g_free(s->domain);
g_free(s->program);
g_free(s->directory);
g_free(s->client_ip);
g_free(s->connection_description);
g_free(s->errstr);
g_free(s);
}
@@ -464,7 +464,7 @@ scp_session_clone(const struct SCP_SESSION *s)
result->domain = g_strdup(s->domain);
result->program = g_strdup(s->program);
result->directory = g_strdup(s->directory);
result->client_ip = g_strdup(s->client_ip);
result->connection_description = g_strdup(s->connection_description);
/* Did all the string copies succeed? */
if ((s->username != NULL && result->username == NULL) ||
@@ -474,7 +474,7 @@ scp_session_clone(const struct SCP_SESSION *s)
(s->domain != NULL && result->domain == NULL) ||
(s->program != NULL && result->program == NULL) ||
(s->directory != NULL && result->directory == NULL) ||
(s->client_ip != NULL && result->client_ip == NULL))
(s->connection_description != NULL && result->connection_description == NULL))
{
scp_session_destroy(result);
result = NULL;
+1 -1
View File
@@ -85,7 +85,7 @@ int
scp_session_set_directory(struct SCP_SESSION *s, const char *str);
int
scp_session_set_client_ip(struct SCP_SESSION *s, const char *str);
scp_session_set_connection_description(struct SCP_SESSION *s, const char *str);
int
scp_session_set_hostname(struct SCP_SESSION *s, const char *str);
+1 -1
View File
@@ -84,7 +84,7 @@ struct SCP_SESSION
char *domain;
char *program;
char *directory;
char *client_ip;
char *connection_description;
tui8 guid[16];
/* added for state */
int current_cmd;
+2 -2
View File
@@ -355,13 +355,13 @@ scp_v0s_accept(struct trans *atrans, struct SCP_SESSION *session)
if (s_check_rem(in_s, 2))
{
/* reading client IP address */
if (!in_string16(in_s, buf, "client IP"))
if (!in_string16(in_s, buf, "connection description"))
{
return SCP_SERVER_STATE_SIZE_ERR;
}
if (buf[0] != '\0')
{
scp_session_set_client_ip(session, buf);
scp_session_set_connection_description(session, buf);
}
}
}
+6 -5
View File
@@ -77,17 +77,18 @@ scp_v0_process(struct trans *t, struct SCP_SESSION *s)
else if (data)
{
s_item = session_get_bydata(s->username, s->width, s->height,
s->bpp, s->type, s->client_ip);
s->bpp, s->type, s->connection_description);
if (s_item != 0)
{
display = s_item->display;
g_memcpy(s->guid, s_item->guid, 16);
if (0 != s->client_ip)
if (0 != s->connection_description)
{
LOG( LOG_LEVEL_INFO, "++ reconnected session: username %s, "
"display :%d.0, session_pid %d, ip %s",
s->username, display, s_item->pid, s->client_ip);
s->username, display, s_item->pid,
s->connection_description);
}
else
{
@@ -109,10 +110,10 @@ scp_v0_process(struct trans *t, struct SCP_SESSION *s)
g_random((char *)guid, 16);
scp_session_set_guid(s, guid);
if (0 != s->client_ip)
if (0 != s->connection_description)
{
LOG(LOG_LEVEL_INFO, "++ created session (access granted): "
"username %s, ip %s", s->username, s->client_ip);
"username %s, ip %s", s->username, s->connection_description);
}
else
{
+4 -4
View File
@@ -108,10 +108,10 @@ scp_v1_process1(struct trans *t, struct SCP_SESSION *s)
LOG(LOG_LEVEL_DEBUG, "No disconnected sessions for this user "
"- we create a new one");
if (0 != s->client_ip)
if (0 != s->connection_description)
{
LOG(LOG_LEVEL_INFO, "++ created session (access granted): "
"username %s, ip %s", s->username, s->client_ip);
"username %s, ip %s", s->username, s->connection_description);
}
else
{
@@ -219,9 +219,9 @@ scp_v1_process43(struct trans *t, struct SCP_SESSION *s)
{
LOG(LOG_LEVEL_ERROR, "scp_v1s_reconnect_session failed");
}
if (0 != s->client_ip)
if (0 != s->connection_description)
{
LOG(LOG_LEVEL_INFO, "++ reconnected session: username %s, display :%d.0, session_pid %d, ip %s", s->username, display, sitem->pid, s->client_ip);
LOG(LOG_LEVEL_INFO, "++ reconnected session: username %s, display :%d.0, session_pid %d, ip %s", s->username, display, sitem->pid, s->connection_description);
}
else
{
+8 -8
View File
@@ -92,7 +92,7 @@ dumpItemsToString(struct list *self, char *outstr, int len)
/******************************************************************************/
struct session_item *
session_get_bydata(const char *name, int width, int height, int bpp, int type,
const char *client_ip)
const char *connection_description)
{
struct session_chain *tmp;
enum SESMAN_CFG_SESS_POLICY policy = g_cfg->sess.policy;
@@ -117,7 +117,7 @@ session_get_bydata(const char *name, int width, int height, int bpp, int type,
LOG(LOG_LEVEL_DEBUG,
"session_get_bydata: search policy %d U %s W %d H %d bpp %d T %d IP %s",
policy, name, width, height, bpp, type, client_ip);
policy, name, width, height, bpp, type, connection_description);
while (tmp != 0)
{
@@ -127,15 +127,15 @@ session_get_bydata(const char *name, int width, int height, int bpp, int type,
tmp->item->name,
tmp->item->width, tmp->item->height,
tmp->item->bpp, tmp->item->type,
tmp->item->client_ip);
tmp->item->connection_description);
if (g_strncmp(name, tmp->item->name, 255) == 0 &&
(!(policy & SESMAN_CFG_SESS_POLICY_D) ||
(tmp->item->width == width && tmp->item->height == height)) &&
(!(policy & SESMAN_CFG_SESS_POLICY_I) ||
(g_strncmp_d(client_ip, tmp->item->client_ip, ':', 255) == 0)) &&
(g_strncmp_d(connection_description, tmp->item->connection_description, ':', 255) == 0)) &&
(!(policy & SESMAN_CFG_SESS_POLICY_C) ||
(g_strncmp(client_ip, tmp->item->client_ip, 255) == 0)) &&
(g_strncmp(connection_description, tmp->item->connection_description, 255) == 0)) &&
tmp->item->bpp == bpp &&
tmp->item->type == type)
{
@@ -925,14 +925,14 @@ session_start_fork(tbus data, tui8 type, struct SCP_SESSION *s)
LOG(LOG_LEVEL_INFO, "Starting session: session_pid %d, "
"display :%d.0, width %d, height %d, bpp %d, client ip %s, "
"user name %s",
pid, display, s->width, s->height, s->bpp, s->client_ip, s->username);
pid, display, s->width, s->height, s->bpp, s->connection_description, s->username);
temp->item->pid = pid;
temp->item->display = display;
temp->item->width = s->width;
temp->item->height = s->height;
temp->item->bpp = s->bpp;
temp->item->data = data;
g_strncpy(temp->item->client_ip, s->client_ip, 255); /* store client ip data */
g_strncpy(temp->item->connection_description, s->connection_description, 255); /* store client ip data */
g_strncpy(temp->item->name, s->username, 255);
g_memcpy(temp->item->guid, s->guid, 16);
@@ -1064,7 +1064,7 @@ session_kill(int pid)
/* deleting the session */
LOG(LOG_LEVEL_INFO,
"++ terminated session: username %s, display :%d.0, session_pid %d, ip %s",
tmp->item->name, tmp->item->display, tmp->item->pid, tmp->item->client_ip);
tmp->item->name, tmp->item->display, tmp->item->pid, tmp->item->connection_description);
g_free(tmp->item);
if (prev == 0)
+2 -2
View File
@@ -75,7 +75,7 @@ struct session_item
struct session_date connect_time;
struct session_date disconnect_time;
struct session_date idle_time;
char client_ip[256];
char connection_description[256];
tui8 guid[16];
};
@@ -93,7 +93,7 @@ struct session_chain
*/
struct session_item *
session_get_bydata(const char *name, int width, int height, int bpp, int type,
const char *client_ip);
const char *connection_description);
#ifndef session_find_item
#define session_find_item(a, b, c, d, e, f) session_get_bydata(a, b, c, d, e, f);
#endif
+3 -3
View File
@@ -261,10 +261,10 @@ xrdp_mm_send_login(struct xrdp_mm *self)
out_uint16_be(s, index);
out_uint8a(s, self->wm->client_info->directory, index);
/* send client ip */
index = g_strlen(self->wm->client_info->client_ip);
/* send client connection description */
index = g_strlen(self->wm->client_info->connection_description);
out_uint16_be(s, index);
out_uint8a(s, self->wm->client_info->client_ip, index);
out_uint8a(s, self->wm->client_info->connection_description, index);
s_mark_end(s);