mirror of
https://gitlab.uni-freiburg.de/opensourcevdi/spice
synced 2025-12-26 22:48:19 +00:00
new libspice api: configure port + ticket
Add new functions to configure spice port and ticketing. Yes, this is incomplete, it includes just the most important bits to get something up'n'running. These functions are supposed to replace both spice_parse_args() and the monitor interaction via qterm interface.
This commit is contained in:
parent
232dbd8710
commit
4e014aa13f
@ -5504,3 +5504,52 @@ void spice_server_destroy(SpiceServer *s)
|
||||
ASSERT(reds == s);
|
||||
reds_exit();
|
||||
}
|
||||
|
||||
int spice_server_set_port(SpiceServer *s, int port)
|
||||
{
|
||||
ASSERT(reds == s);
|
||||
if (port < 0 || port > 0xffff) {
|
||||
return -1;
|
||||
}
|
||||
spice_port = port;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int spice_server_set_noauth(SpiceServer *s)
|
||||
{
|
||||
ASSERT(reds == s);
|
||||
memset(taTicket.password, 0, sizeof(taTicket.password));
|
||||
ticketing_enabled = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int spice_server_set_ticket(SpiceServer *s, const char *passwd, int lifetime,
|
||||
int fail_if_connected, int disconnect_if_connected)
|
||||
{
|
||||
ASSERT(reds == s);
|
||||
|
||||
if (reds->peer) {
|
||||
if (fail_if_connected) {
|
||||
return -1;
|
||||
}
|
||||
if (disconnect_if_connected) {
|
||||
reds_disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
on_activating_ticketing();
|
||||
ticketing_enabled = 1;
|
||||
if (lifetime == 0) {
|
||||
taTicket.expiration_time = INT_MAX;
|
||||
} else {
|
||||
time_t now = time(NULL);
|
||||
taTicket.expiration_time = now + lifetime;
|
||||
}
|
||||
if (passwd != NULL) {
|
||||
strncpy(taTicket.password, passwd, sizeof(taTicket.password));
|
||||
} else {
|
||||
memset(taTicket.password, 0, sizeof(taTicket.password));
|
||||
taTicket.expiration_time = 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -32,4 +32,9 @@ SpiceServer *spice_server_new(void);
|
||||
int spice_server_init(SpiceServer *s, CoreInterface *core);
|
||||
void spice_server_destroy(SpiceServer *s);
|
||||
|
||||
int spice_server_set_port(SpiceServer *s, int port);
|
||||
int spice_server_set_noauth(SpiceServer *s);
|
||||
int spice_server_set_ticket(SpiceServer *s, const char *passwd, int lifetime,
|
||||
int fail_if_connected, int disconnect_if_connected);
|
||||
|
||||
#endif
|
||||
|
||||
Loading…
Reference in New Issue
Block a user