tis-rustdesk-config-template

20
Config for RustDesk
1044 downloads
Download
See build result See VirusTotal scan
tis-rustdesk-config-template icon
  • package : tis-rustdesk-config-template
  • name : RustDesk Config
  • version : 20
  • categories : Utilities
  • maintainer : WAPT Team,Tranquil IT
  • editor :
  • licence :
  • locale : all
  • target_os : all
  • impacted_process :
  • architecture : all
  • signature_date : 2025-01-23 21:15
  • size : 7.65 Ko
  • homepage : https://rustdesk.com/
  • depends :
package           : tis-rustdesk-config-template
version           : 20
architecture      : all
section           : base
priority          : optional
name              : RustDesk Config
categories        : Utilities
maintainer        : WAPT Team,Tranquil IT
description       : Config for RustDesk
depends           : tis-rustdesk
conflicts         : 
maturity          : PROD
locale            : all
target_os         : all
min_wapt_version  : 2.3
sources           : 
installed_size    : 
impacted_process  : 
description_fr    : Config rustdesk
description_pl    : 
description_de    : 
description_es    : 
description_pt    : 
description_it    : 
description_nl    : 
description_ru    : 
audit_schedule    : 30d
editor            : 
keywords          : RustDesk
licence           : 
homepage          : https://rustdesk.com/
package_uuid      : f0fd4a57-5409-4352-a7c2-6e0c84b10192
valid_from        : 
valid_until       : 
forced_install_on : 
changelog         : https://github.com/rustdesk/rustdesk/releases
min_os_version    : 
max_os_version    : 
icon_sha256sum    : 2435ab1227e19048fc0d782821cc7258a41b69dc1e22914aedddd288a38b6ccc
signer            : Tranquil IT
signer_fingerprint: 8c5127a75392be9cc9afd0dbae1222a673072c308c14d88ab246e23832e8c6bb
signature_date    : 2025-01-23T21:15:15.000000
signed_attributes : package,version,architecture,section,priority,name,categories,maintainer,description,depends,conflicts,maturity,locale,target_os,min_wapt_version,sources,installed_size,impacted_process,description_fr,description_pl,description_de,description_es,description_pt,description_it,description_nl,description_ru,audit_schedule,editor,keywords,licence,homepage,package_uuid,valid_from,valid_until,forced_install_on,changelog,min_os_version,max_os_version,icon_sha256sum,signer,signer_fingerprint,signature_date,signed_attributes
signature         : HgBuwk2/4JZCDQZogoeMjUiTF6ukc+oBCJ2BqqFZmpsgYnYo0h98BCnx1ooTpZf7bIqqHlA9AzA5fez+AX/n2ogOtVMmnmLouxCg3hazkdafMIxwQpZVrDJe7k3H/T8E8A9Nn410U/EIiAm3ARNE9fF/xvxnhs9rVgh4TAo4Hdsqa+wSTbmt6rorZoyMytrFDXghczEhAHZBz8NnCG5EBfBPuihFWiRkm+gn3LfQymQJV0a75eRT7gblDPQzCVx0f6JE6VhdWjEjnr2jxcGAfrXPHRVv5XB0LcPwzZe6yvJPrMb+O+7tGxNnjTDzTmojsCXQz1d+Ws7+rZcG3g7ktQ==
# -*- coding: utf-8 -*-
from setuphelpers import *
import string, secrets
import platform
import json
import base64

r"""
Usable WAPT package functions: install(), uninstall(), session_setup(), audit(), update_package()

"""

if platform.system() == 'Windows':
    if uninstall_key_exists('RustDesk'):
        RustDeskBin = makepath(install_location('RustDesk'),'rustdesk.exe')
elif platform.system() == 'Darwin':
    RustDeskBin = "/Applications/RustDesk.app/Contents/MacOS/RustDesk"
else:
    RustDeskBin = "/usr/lib/rustdesk/rustdesk"


def install():
    rustdesk_cfg = open('rustdesk.cfg').read()

    alphabet = string.ascii_letters + string.digits
    rustdesk_pw = ''.join(secrets.choice(alphabet) for i in range(12))

    run_notfatal('"%s" --config %s' % (RustDeskBin,rustdesk_cfg))
    run('"%s" --password %s' % (RustDeskBin,rustdesk_pw ))

    if platform.system() == 'Windows':
        if service_is_running("rustdesk"):
            service_stop("rustdesk")
        service_start("rustdesk")

    elif platform.system() == 'Darwin':
        print('todo')
    else:
        systemd_restart_service('rustdesk')

def audit():
    rustdesk_id = run('"%s" --get-id' % RustDeskBin)
    if rustdesk_id.endswith('\n'):
        rustdesk_id = rustdesk_id.split('\n')[-2]

    alphabet = string.ascii_letters + string.digits
    rustdesk_pw = ''.join(secrets.choice(alphabet) for i in range(12))
    run('"%s" --password %s' % (RustDeskBin, rustdesk_pw))

    WAPT.write_audit_data_if_changed("rustdesk", 'rustdesk-id', rustdesk_id, max_count=365)
    WAPT.write_audit_data_if_changed("rustdesk", 'password_encryption', rsa_encrypted_data_str(rustdesk_pw, WAPT.public_certs_dir), max_count=365)
    
    return "OK"

def encode_rustdesk_config(config):
    rustdesk_list = list(base64.b64encode(json.dumps(config, separators=(',', ':')).encode('utf-8')).decode('utf-8').replace('=',''))
    rustdesk_list.reverse()
    return ''.join(rustdesk_list)

def update_package():
    old_conf = ""
    if isfile('rustdesk.cfg'):
        old_conf = open('rustdesk.cfg').read()
        
    newconf = ""
    if not params.get("install_with_luti", False):
        from waptguihelper import message_dialog, memo_dialog,input_dialog, MB_YESNO, MB_ICONQUESTION, ID_YES

        is_cfg_config = message_dialog("RUSTDESK Config", "Do you have an cfg config file ?", MB_YESNO + MB_ICONQUESTION)
        if is_cfg_config == ID_YES:
            newconf = memo_dialog('RUSTDESK Config', "Please give your rustdesk cfg config that you can retrieved in the 'Audit data' of your host server", old_conf)
        else:
            conf = {"api":""}
            conf['host'] = input_dialog('Host','Please give ip or dns name of HOST rustdesk server :','rustdesk.mydomain.lan')
            conf['relay'] = input_dialog('Host','Please give ip or dns name of RELAY rustdesk server :',conf['host'])
            conf['key'] = input_dialog('Host','Please give the public key of the rustdesk server (content of the file /opt/rustdesk/*.pub) :','')

            newconf = encode_rustdesk_config(conf)

        control.package = control.package.replace('-template', '')
        control.save_control_to_wapt()

    with open('rustdesk.cfg', 'w') as f:
        f.write(newconf)
38d056ab130f7bf7c481c12636a4e9959de36561d3dfcbe54c6e3571bc0c1dc3 : WAPT/certificate.crt
8560d08d228ba1bdc3f08f3436385ec4464334904f8bb9b6a3f404b0a2431b36 : WAPT/control
2435ab1227e19048fc0d782821cc7258a41b69dc1e22914aedddd288a38b6ccc : WAPT/icon.png
15f15ba8cece6ad38ccfd433f0ce56bf14b1708a2e79bc2742913dfc7128d3f3 : luti.json
e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 : rustdesk.cfg
8ab73a6b42dd022ba89e21125c74465535e51047c787a5eea8e9772073b1a9db : setup.py