cscg24-guacamole

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

settings.h (9213B)


      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#ifndef GUAC_TELNET_SETTINGS_H
     21#define GUAC_TELNET_SETTINGS_H
     22
     23#include "config.h"
     24
     25#include <guacamole/user.h>
     26
     27#include <sys/types.h>
     28#include <regex.h>
     29#include <stdbool.h>
     30/**
     31 * The port to connect to when initiating any telnet connection, if no other
     32 * port is specified.
     33 */
     34#define GUAC_TELNET_DEFAULT_PORT "23"
     35
     36/**
     37 * The filename to use for the typescript, if not specified.
     38 */
     39#define GUAC_TELNET_DEFAULT_TYPESCRIPT_NAME "typescript" 
     40
     41/**
     42 * The filename to use for the screen recording, if not specified.
     43 */
     44#define GUAC_TELNET_DEFAULT_RECORDING_NAME "recording"
     45
     46/**
     47 * The regular expression to use when searching for the username/login prompt
     48 * if no other regular expression is specified.
     49 */
     50#define GUAC_TELNET_DEFAULT_USERNAME_REGEX "[Ll]ogin:"
     51
     52/**
     53 * The regular expression to use when searching for the password prompt if no
     54 * other regular expression is specified.
     55 */
     56#define GUAC_TELNET_DEFAULT_PASSWORD_REGEX "[Pp]assword:"
     57
     58/**
     59 * Settings for the telnet connection. The values for this structure are parsed
     60 * from the arguments given during the Guacamole protocol handshake using the
     61 * guac_telnet_parse_args() function.
     62 */
     63typedef struct guac_telnet_settings {
     64
     65    /**
     66     * The hostname of the telnet server to connect to.
     67     */
     68    char* hostname;
     69
     70    /**
     71     * The port of the telnet server to connect to.
     72     */
     73    char* port;
     74
     75    /**
     76     * The name of the user to login as, if any. If no username is specified,
     77     * this will be NULL.
     78     */
     79    char* username;
     80
     81    /**
     82     * The regular expression to use when searching for the username/login
     83     * prompt. If no username is specified, this will be NULL. If a username
     84     * is specified, this will either be the specified username regex, or the
     85     * default username regex.
     86     */
     87    regex_t* username_regex;
     88
     89    /**
     90     * The password to give when authenticating, if any. If no password is
     91     * specified, this will be NULL.
     92     */
     93    char* password;
     94
     95    /**
     96     * The regular expression to use when searching for the password prompt. If
     97     * no password is specified, this will be NULL. If a password is specified,
     98     * this will either be the specified password regex, or the default
     99     * password regex.
    100     */
    101    regex_t* password_regex;
    102
    103    /**
    104     * The regular expression to use when searching for whether login was
    105     * successful. If no such regex is specified, or if no login failure regex
    106     * was specified, this will be NULL.
    107     */
    108    regex_t* login_success_regex;
    109
    110    /**
    111     * The regular expression to use when searching for whether login failed.
    112     * If no such regex is specified, or if no login success regex was
    113     * specified, this will be NULL.
    114     */
    115    regex_t* login_failure_regex;
    116
    117    /**
    118     * Whether this connection is read-only, and user input should be dropped.
    119     */
    120    bool read_only;
    121
    122    /**
    123     * The maximum size of the scrollback buffer in rows.
    124     */
    125    int max_scrollback;
    126
    127    /**
    128     * The name of the font to use for display rendering.
    129     */
    130    char* font_name;
    131
    132    /**
    133     * The size of the font to use, in points.
    134     */
    135    int font_size;
    136
    137    /**
    138     * The name of the color scheme to use.
    139     */
    140    char* color_scheme; 
    141
    142    /**
    143     * The desired width of the terminal display, in pixels.
    144     */
    145    int width;
    146
    147    /**
    148     * The desired height of the terminal display, in pixels.
    149     */
    150    int height;
    151
    152    /**
    153     * The desired screen resolution, in DPI.
    154     */
    155    int resolution;
    156
    157    /**
    158     * Whether outbound clipboard access should be blocked. If set, it will not
    159     * be possible to copy data from the terminal to the client using the
    160     * clipboard.
    161     */
    162    bool disable_copy;
    163
    164    /**
    165     * Whether inbound clipboard access should be blocked. If set, it will not
    166     * be possible to paste data from the client to the terminal using the
    167     * clipboard.
    168     */
    169    bool disable_paste;
    170
    171    /**
    172     * The path in which the typescript should be saved, if enabled. If no
    173     * typescript should be saved, this will be NULL.
    174     */
    175    char* typescript_path;
    176
    177    /**
    178     * The filename to use for the typescript, if enabled.
    179     */
    180    char* typescript_name;
    181
    182    /**
    183     * Whether the typescript path should be automatically created if it does
    184     * not already exist.
    185     */
    186    bool create_typescript_path;
    187
    188    /**
    189     * The path in which the screen recording should be saved, if enabled. If
    190     * no screen recording should be saved, this will be NULL.
    191     */
    192    char* recording_path;
    193
    194    /**
    195     * The filename to use for the screen recording, if enabled.
    196     */
    197    char* recording_name;
    198
    199    /**
    200     * Whether the screen recording path should be automatically created if it
    201     * does not already exist.
    202     */
    203    bool create_recording_path;
    204
    205    /**
    206     * Whether output which is broadcast to each connected client (graphics,
    207     * streams, etc.) should NOT be included in the session recording. Output
    208     * is included by default, as it is necessary for any recording which must
    209     * later be viewable as video.
    210     */
    211    bool recording_exclude_output;
    212
    213    /**
    214     * Whether changes to mouse state, such as position and buttons pressed or
    215     * released, should NOT be included in the session recording. Mouse state
    216     * is included by default, as it is necessary for the mouse cursor to be
    217     * rendered in any resulting video.
    218     */
    219    bool recording_exclude_mouse;
    220
    221    /**
    222     * Whether keys pressed and released should be included in the session
    223     * recording. Key events are NOT included by default within the recording,
    224     * as doing so has privacy and security implications.  Including key events
    225     * may be necessary in certain auditing contexts, but should only be done
    226     * with caution. Key events can easily contain sensitive information, such
    227     * as passwords, credit card numbers, etc.
    228     */
    229    bool recording_include_keys;
    230
    231    /**
    232     * The ASCII code, as an integer, that the telnet client will use when the
    233     * backspace key is pressed.  By default, this is 127, ASCII delete, if
    234     * not specified in the client settings.
    235     */
    236    int backspace;
    237
    238    /**
    239     * The terminal emulator type that is passed to the remote system.
    240     */
    241    char* terminal_type;
    242    
    243    /**
    244     * Whether or not to send the magic Wake-on-LAN (WoL) packet prior to
    245     * continuing the connection.
    246     */
    247    bool wol_send_packet;
    248    
    249    /**
    250     * The MAC address to put in the magic WoL packet for the remote host to
    251     * wake.
    252     */
    253    char* wol_mac_addr;
    254    
    255    /**
    256     * The broadcast address to which to send the magic WoL packet to wake
    257     * the remote host.
    258     */
    259    char* wol_broadcast_addr;
    260    
    261    /**
    262     * The UDP port to use when sending the WoL packet.
    263     */
    264    unsigned short wol_udp_port;
    265    
    266    /**
    267     * The number of seconds to wait after sending the magic WoL packet before
    268     * continuing the connection.
    269     */
    270    int wol_wait_time;
    271
    272} guac_telnet_settings;
    273
    274/**
    275 * Parses all given args, storing them in a newly-allocated settings object. If
    276 * the args fail to parse, NULL is returned.
    277 *
    278 * @param user
    279 *     The user who submitted the given arguments while joining the
    280 *     connection.
    281 *
    282 * @param argc
    283 *     The number of arguments within the argv array.
    284 *
    285 * @param argv
    286 *     The values of all arguments provided by the user.
    287 *
    288 * @return
    289 *     A newly-allocated settings object which must be freed with
    290 *     guac_telnet_settings_free() when no longer needed. If the arguments fail
    291 *     to parse, NULL is returned.
    292 */
    293guac_telnet_settings* guac_telnet_parse_args(guac_user* user,
    294        int argc, const char** argv);
    295
    296/**
    297 * Frees the regex pointed to by the given pointer, assigning the value NULL to
    298 * that pointer once the regex is freed. If the pointer already contains NULL,
    299 * this function has no effect.
    300 *
    301 * @param regex
    302 *     The address of the pointer to the regex that should be freed.
    303 */
    304void guac_telnet_regex_free(regex_t** regex);
    305
    306/**
    307 * Frees the given guac_telnet_settings object, having been previously
    308 * allocated via guac_telnet_parse_args().
    309 *
    310 * @param settings
    311 *     The settings object to free.
    312 */
    313void guac_telnet_settings_free(guac_telnet_settings* settings);
    314
    315/**
    316 * NULL-terminated array of accepted client args.
    317 */
    318extern const char* GUAC_TELNET_CLIENT_ARGS[];
    319
    320#endif
    321