cscg24-guacamole

CSCG 2024 Challenge 'Guacamole Mashup'
git clone https://git.sinitax.com/sinitax/cscg24-guacamole
Log | Files | Refs | sfeed.txt

settings.h (9551B)


      1/*
      2 * Licensed to the Apache Software Foundation (ASF) under one
      3 * or more contributor license agreements.  See the NOTICE file
      4 * distributed with this work for additional information
      5 * regarding copyright ownership.  The ASF licenses this file
      6 * to you under the Apache License, Version 2.0 (the
      7 * "License"); you may not use this file except in compliance
      8 * with the License.  You may obtain a copy of the License at
      9 *
     10 *   http://www.apache.org/licenses/LICENSE-2.0
     11 *
     12 * Unless required by applicable law or agreed to in writing,
     13 * software distributed under the License is distributed on an
     14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
     15 * KIND, either express or implied.  See the License for the
     16 * specific language governing permissions and limitations
     17 * under the License.
     18 */
     19
     20
     21#ifndef __GUAC_VNC_SETTINGS_H
     22#define __GUAC_VNC_SETTINGS_H
     23
     24#include "config.h"
     25
     26#include <stdbool.h>
     27
     28/**
     29 * The filename to use for the screen recording, if not specified.
     30 */
     31#define GUAC_VNC_DEFAULT_RECORDING_NAME "recording"
     32
     33/**
     34 * VNC-specific client data.
     35 */
     36typedef struct guac_vnc_settings {
     37
     38    /**
     39     * The hostname of the VNC server (or repeater) to connect to.
     40     */
     41    char* hostname;
     42
     43    /**
     44     * The port of the VNC server (or repeater) to connect to.
     45     */
     46    int port;
     47
     48    /**
     49     * The username given in the arguments.
     50     */
     51    char* username;
     52    
     53    /**
     54     * The password given in the arguments.
     55     */
     56    char* password;
     57
     58    /**
     59     * Space-separated list of encodings to use within the VNC session.
     60     */
     61    char* encodings;
     62
     63    /**
     64     * Whether the red and blue components of each color should be swapped.
     65     * This is mainly used for VNC servers that do not properly handle
     66     * colors.
     67     */
     68    bool swap_red_blue;
     69
     70    /**
     71     * The color depth to request, in bits.
     72     */
     73    int color_depth;
     74
     75    /**
     76     * Whether this connection is read-only, and user input should be dropped.
     77     */
     78    bool read_only;
     79
     80    /**
     81     * Whether all graphical updates for this connection should use lossless
     82     * compression only.
     83     */
     84    bool lossless;
     85
     86#ifdef ENABLE_VNC_REPEATER
     87    /**
     88     * The VNC host to connect to, if using a repeater.
     89     */
     90    char* dest_host;
     91
     92    /**
     93     * The VNC port to connect to, if using a repeater.
     94     */
     95    int dest_port;
     96#endif
     97
     98#ifdef ENABLE_VNC_LISTEN
     99    /**
    100     * Whether not actually connecting to a VNC server, but rather listening
    101     * for a connection from the VNC server (reverse connection).
    102     */
    103    bool reverse_connect;
    104
    105    /**
    106     * The maximum amount of time to wait when listening for connections, in
    107     * milliseconds.
    108     */
    109    int listen_timeout;
    110#endif
    111
    112    /**
    113     * Whether the cursor should be rendered on the server (remote) or on the
    114     * client (local).
    115     */
    116    bool remote_cursor;
    117   
    118#ifdef ENABLE_PULSE
    119    /**
    120     * Whether audio is enabled.
    121     */
    122    bool audio_enabled;
    123 
    124    /**
    125     * The name of the PulseAudio server to connect to.
    126     */
    127    char* pa_servername;
    128#endif
    129
    130    /**
    131     * The number of connection attempts to make before giving up.
    132     */
    133    int retries;
    134
    135    /**
    136     * The encoding to use for clipboard data sent to the VNC server, or NULL
    137     * to use the encoding required by the VNC standard.
    138     */
    139    char* clipboard_encoding;
    140
    141    /**
    142     * Whether outbound clipboard access should be blocked. If set, it will not
    143     * be possible to copy data from the remote desktop to the client using the
    144     * clipboard.
    145     */
    146    bool disable_copy;
    147
    148    /**
    149     * Whether inbound clipboard access should be blocked. If set, it will not
    150     * be possible to paste data from the client to the remote desktop using
    151     * the clipboard.
    152     */
    153    bool disable_paste;
    154
    155#ifdef ENABLE_COMMON_SSH
    156    /**
    157     * Whether SFTP should be enabled for the VNC connection.
    158     */
    159    bool enable_sftp;
    160
    161    /**
    162     * The hostname of the SSH server to connect to for SFTP.
    163     */
    164    char* sftp_hostname;
    165
    166    /**
    167     * The public SSH host key.
    168     */
    169    char* sftp_host_key;
    170
    171    /**
    172     * The port of the SSH server to connect to for SFTP.
    173     */
    174    char* sftp_port;
    175
    176    /**
    177     * The username to provide when authenticating with the SSH server for
    178     * SFTP.
    179     */
    180    char* sftp_username;
    181
    182    /**
    183     * The password to provide when authenticating with the SSH server for
    184     * SFTP (if not using a private key).
    185     */
    186    char* sftp_password;
    187
    188    /**
    189     * The base64-encoded private key to use when authenticating with the SSH
    190     * server for SFTP (if not using a password).
    191     */
    192    char* sftp_private_key;
    193
    194    /**
    195     * The passphrase to use to decrypt the provided base64-encoded private
    196     * key.
    197     */
    198    char* sftp_passphrase;
    199
    200    /**
    201     * The default location for file uploads within the SSH server. This will
    202     * apply only to uploads which do not use the filesystem guac_object (where
    203     * the destination directory is otherwise ambiguous).
    204     */
    205    char* sftp_directory;
    206
    207    /**
    208     * The path of the directory within the SSH server to expose as a
    209     * filesystem guac_object.
    210     */
    211    char* sftp_root_directory;
    212
    213    /**
    214     * The interval at which SSH keepalive messages are sent to the server for
    215     * SFTP connections.  The default is 0 (disabling keepalives), and a value
    216     * of 1 is automatically increased to 2 by libssh2 to avoid busy loop corner
    217     * cases.
    218     */
    219    int sftp_server_alive_interval;
    220    
    221    /**
    222     * Whether file downloads over SFTP should be blocked.  If set to "true",
    223     * the local client will not be able to download files from the SFTP server.
    224     * If set to "false" or not set, file downloads will be allowed.
    225     */
    226    bool sftp_disable_download;
    227    
    228    /**
    229     * Whether file uploads over SFTP should be blocked.  If set to "true", the
    230     * local client will not be able to upload files to the SFTP server.  If set
    231     * to "false" or not set, file uploads will be allowed.
    232     */
    233    bool sftp_disable_upload;
    234#endif
    235
    236    /**
    237     * The path in which the screen recording should be saved, if enabled. If
    238     * no screen recording should be saved, this will be NULL.
    239     */
    240    char* recording_path;
    241
    242    /**
    243     * The filename to use for the screen recording, if enabled.
    244     */
    245    char* recording_name;
    246
    247    /**
    248     * Whether the screen recording path should be automatically created if it
    249     * does not already exist.
    250     */
    251    bool create_recording_path;
    252
    253    /**
    254     * Whether output which is broadcast to each connected client (graphics,
    255     * streams, etc.) should NOT be included in the session recording. Output
    256     * is included by default, as it is necessary for any recording which must
    257     * later be viewable as video.
    258     */
    259    bool recording_exclude_output;
    260
    261    /**
    262     * Whether changes to mouse state, such as position and buttons pressed or
    263     * released, should NOT be included in the session recording. Mouse state
    264     * is included by default, as it is necessary for the mouse cursor to be
    265     * rendered in any resulting video.
    266     */
    267    bool recording_exclude_mouse;
    268
    269    /**
    270     * Whether keys pressed and released should be included in the session
    271     * recording. Key events are NOT included by default within the recording,
    272     * as doing so has privacy and security implications.  Including key events
    273     * may be necessary in certain auditing contexts, but should only be done
    274     * with caution. Key events can easily contain sensitive information, such
    275     * as passwords, credit card numbers, etc.
    276     */
    277    bool recording_include_keys;
    278    
    279    /**
    280     * Whether or not to send the magic Wake-on-LAN (WoL) packet prior to
    281     * trying to connect to the remote host.  By default this will not be sent.
    282     * If this option is enabled but a MAC address is not provided a warning will
    283     * be logged and the packet will not be sent.
    284     */
    285    bool wol_send_packet;
    286    
    287    /**
    288     * The MAC address to place in the magic WoL packet to wake the remote host.
    289     */
    290    char* wol_mac_addr;
    291    
    292    /**
    293     * The broadcast address to which to send the magic WoL packet to wake
    294     * the remote host.
    295     */
    296    char* wol_broadcast_addr;
    297    
    298    /**
    299     * The UDP port to use when sending the WoL packet.
    300     */
    301    unsigned short wol_udp_port;
    302    
    303    /**
    304     * The number of seconds after sending the magic WoL packet to wait before
    305     * attempting to connect to the remote host.
    306     */
    307    int wol_wait_time;
    308
    309} guac_vnc_settings;
    310
    311/**
    312 * Parses all given args, storing them in a newly-allocated settings object. If
    313 * the args fail to parse, NULL is returned.
    314 *
    315 * @param user
    316 *     The user who submitted the given arguments while joining the
    317 *     connection.
    318 *
    319 * @param argc
    320 *     The number of arguments within the argv array.
    321 *
    322 * @param argv
    323 *     The values of all arguments provided by the user.
    324 *
    325 * @return
    326 *     A newly-allocated settings object which must be freed with
    327 *     guac_vnc_settings_free() when no longer needed. If the arguments fail
    328 *     to parse, NULL is returned.
    329 */
    330guac_vnc_settings* guac_vnc_parse_args(guac_user* user,
    331        int argc, const char** argv);
    332
    333/**
    334 * Frees the given guac_vnc_settings object, having been previously allocated
    335 * via guac_vnc_parse_args().
    336 *
    337 * @param settings
    338 *     The settings object to free.
    339 */
    340void guac_vnc_settings_free(guac_vnc_settings* settings);
    341
    342/**
    343 * NULL-terminated array of accepted client args.
    344 */
    345extern const char* GUAC_VNC_CLIENT_ARGS[];
    346
    347#endif
    348