mirror of
https://gitlab.com/openconnect/ocserv.git
synced 2026-02-10 08:46:58 +08:00
ipc: pass the connection status as integer
Conversion to textual form now happens at the client (occtl) instead of the main server.
This commit is contained in:
@@ -32,7 +32,7 @@ message user_info_rep
|
|||||||
required uint32 conn_time = 10;
|
required uint32 conn_time = 10;
|
||||||
optional string hostname = 11;
|
optional string hostname = 11;
|
||||||
optional string user_agent = 12;
|
optional string user_agent = 12;
|
||||||
required string status = 13;
|
required uint32 status = 13; /* PS_ */
|
||||||
optional string tls_ciphersuite = 14;
|
optional string tls_ciphersuite = 14;
|
||||||
optional string dtls_ciphersuite = 15;
|
optional string dtls_ciphersuite = 15;
|
||||||
|
|
||||||
|
|||||||
@@ -291,7 +291,7 @@ message cookie_int_msg
|
|||||||
required string user_agent = 7;
|
required string user_agent = 7;
|
||||||
required string remote_ip = 8;
|
required string remote_ip = 8;
|
||||||
required string psid = 9; /* printable form of sid */
|
required string psid = 9; /* printable form of sid */
|
||||||
optional string status = 10; /* printable version of auth status */
|
required uint32 status = 10; /* the authentication status (PS_*) */
|
||||||
}
|
}
|
||||||
|
|
||||||
/* SECM_LIST_COOKIES - no content */
|
/* SECM_LIST_COOKIES - no content */
|
||||||
|
|||||||
@@ -351,7 +351,7 @@ static int append_user_info(method_ctx *ctx,
|
|||||||
rep->hostname = ctmp->hostname;
|
rep->hostname = ctmp->hostname;
|
||||||
rep->user_agent = ctmp->user_agent;
|
rep->user_agent = ctmp->user_agent;
|
||||||
|
|
||||||
rep->status = (char*)ps_status_to_str(ctmp->status, 0);
|
rep->status = ctmp->status;
|
||||||
|
|
||||||
rep->tls_ciphersuite = ctmp->tls_ciphersuite;
|
rep->tls_ciphersuite = ctmp->tls_ciphersuite;
|
||||||
rep->dtls_ciphersuite = ctmp->dtls_ciphersuite;
|
rep->dtls_ciphersuite = ctmp->dtls_ciphersuite;
|
||||||
|
|||||||
@@ -560,7 +560,7 @@ void common_user_list(struct unix_ctx *ctx, UserListRep *rep, FILE *out, cmd_par
|
|||||||
|
|
||||||
dtls_ciphersuite = fix_ciphersuite(rep->user[i]->dtls_ciphersuite);
|
dtls_ciphersuite = fix_ciphersuite(rep->user[i]->dtls_ciphersuite);
|
||||||
|
|
||||||
fprintf(out, "%s %14s %9s\n", tmpbuf, dtls_ciphersuite, rep->user[i]->status);
|
fprintf(out, "%s %14s %9s\n", tmpbuf, dtls_ciphersuite, ps_status_to_str(rep->user[i]->status, 0));
|
||||||
|
|
||||||
entries_add(ctx, username, strlen(username), rep->user[i]->id);
|
entries_add(ctx, username, strlen(username), rep->user[i]->id);
|
||||||
}
|
}
|
||||||
@@ -642,7 +642,7 @@ void cookie_list(struct unix_ctx *ctx, SecmListCookiesReplyMsg *rep, FILE *out,
|
|||||||
|
|
||||||
fprintf(out, "%.6s %8s %8s %14s %.24s %8s %8s\n",
|
fprintf(out, "%.6s %8s %8s %14s %.24s %8s %8s\n",
|
||||||
rep->cookies[i]->psid, username, groupname, rep->cookies[i]->remote_ip,
|
rep->cookies[i]->psid, username, groupname, rep->cookies[i]->remote_ip,
|
||||||
rep->cookies[i]->user_agent, tmpbuf, rep->cookies[i]->status);
|
rep->cookies[i]->user_agent, tmpbuf, ps_status_to_str(rep->cookies[i]->status, 1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -946,7 +946,7 @@ int common_info_cmd(UserListRep * args, FILE *out, cmd_params_st *params)
|
|||||||
groupname = NO_GROUP;
|
groupname = NO_GROUP;
|
||||||
|
|
||||||
print_pair_value(out, params, "Username", username, "Groupname", groupname, 1);
|
print_pair_value(out, params, "Username", username, "Groupname", groupname, 1);
|
||||||
print_single_value(out, params, "State", args->user[i]->status, 1);
|
print_single_value(out, params, "State", ps_status_to_str(args->user[i]->status, 0), 1);
|
||||||
if (args->user[i]->has_mtu != 0)
|
if (args->user[i]->has_mtu != 0)
|
||||||
print_pair_value(out, params, "Device", args->user[i]->tun, "MTU", int2str(tmpbuf, args->user[i]->mtu), 1);
|
print_pair_value(out, params, "Device", args->user[i]->tun, "MTU", int2str(tmpbuf, args->user[i]->mtu), 1);
|
||||||
else
|
else
|
||||||
@@ -1079,7 +1079,7 @@ int cookie_info_cmd(SecmListCookiesReplyMsg * args, FILE *out, cmd_params_st *pa
|
|||||||
|
|
||||||
print_single_value_int(out, params, "session_is_open", args->cookies[i]->session_is_open, 1);
|
print_single_value_int(out, params, "session_is_open", args->cookies[i]->session_is_open, 1);
|
||||||
print_single_value_int(out, params, "tls_auth_ok", args->cookies[i]->tls_auth_ok, 1);
|
print_single_value_int(out, params, "tls_auth_ok", args->cookies[i]->tls_auth_ok, 1);
|
||||||
print_single_value(out, params, "State", args->cookies[i]->status, 1);
|
print_single_value(out, params, "State", ps_status_to_str(args->cookies[i]->status, 1), 1);
|
||||||
|
|
||||||
t = args->cookies[i]->last_modified;
|
t = args->cookies[i]->last_modified;
|
||||||
tm = localtime(&t);
|
tm = localtime(&t);
|
||||||
@@ -1306,10 +1306,6 @@ int handle_events_cmd(struct unix_ctx *ctx, const char *arg, cmd_params_st *para
|
|||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
if (HAVE_JSON(params)) {
|
if (HAVE_JSON(params)) {
|
||||||
if (rep2->connected == 0)
|
|
||||||
rep2->user->user[0]->status = talloc_strdup(rep2, "disconnected");
|
|
||||||
else
|
|
||||||
rep2->user->user[0]->status = talloc_strdup(rep2, "connected");
|
|
||||||
common_info_cmd(rep2->user, stdout, params);
|
common_info_cmd(rep2->user, stdout, params);
|
||||||
} else {
|
} else {
|
||||||
groupname = rep2->user->user[0]->groupname;
|
groupname = rep2->user->user[0]->groupname;
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ void handle_secm_list_cookies_reply(void *pool, int fd, sec_mod_st *sec)
|
|||||||
cookies[msg.n_cookies].user_agent = t->acct_info.user_agent;
|
cookies[msg.n_cookies].user_agent = t->acct_info.user_agent;
|
||||||
cookies[msg.n_cookies].remote_ip = t->acct_info.remote_ip;
|
cookies[msg.n_cookies].remote_ip = t->acct_info.remote_ip;
|
||||||
cookies[msg.n_cookies].psid = t->acct_info.psid;
|
cookies[msg.n_cookies].psid = t->acct_info.psid;
|
||||||
cookies[msg.n_cookies].status = (char*)ps_status_to_str(t->status, 1);
|
cookies[msg.n_cookies].status = t->status;
|
||||||
|
|
||||||
msg.cookies[msg.n_cookies] = &cookies[msg.n_cookies];
|
msg.cookies[msg.n_cookies] = &cookies[msg.n_cookies];
|
||||||
msg.n_cookies++;
|
msg.n_cookies++;
|
||||||
|
|||||||
Reference in New Issue
Block a user