forked from shaytan/rdgen
106 lines
5.5 KiB
Python
106 lines
5.5 KiB
Python
from django import forms
|
|
from PIL import Image
|
|
|
|
class GenerateForm(forms.Form):
|
|
#Platform
|
|
platform = forms.ChoiceField(choices=[('windows','Windows'),('linux','Linux (currently unavailable)'),('android','Android'),('macos','macOS')], initial='windows')
|
|
version = forms.ChoiceField(choices=[('master','nightly'),('1.3.8','1.3.8'),('1.3.7','1.3.7'),('1.3.6','1.3.6'),('1.3.5','1.3.5'),('1.3.4','1.3.4'),('1.3.3','1.3.3')], initial='1.3.8')
|
|
help_text="'master' is the development version (nightly build) with the latest features but may be less stable"
|
|
delayFix = forms.BooleanField(initial=True, required=False)
|
|
|
|
#General
|
|
exename = forms.CharField(label="Name for EXE file", required=True)
|
|
appname = forms.CharField(label="Custom App Name", required=False)
|
|
direction = forms.ChoiceField(widget=forms.RadioSelect, choices=[
|
|
('incoming', 'Incoming Only'),
|
|
('outgoing', 'Outgoing Only'),
|
|
('both', 'Bidirectional')
|
|
], initial='both')
|
|
installation = forms.ChoiceField(label="Disable Installation", choices=[
|
|
('installationY', 'No, enable installation'),
|
|
('installationN', 'Yes, DISABLE installation')
|
|
], initial='installationY')
|
|
settings = forms.ChoiceField(label="Disable Settings", choices=[
|
|
('settingsY', 'No, enable settings'),
|
|
('settingsN', 'Yes, DISABLE settings')
|
|
], initial='settingsY')
|
|
|
|
#Custom Server
|
|
serverIP = forms.CharField(label="Host", required=False)
|
|
apiServer = forms.CharField(label="API Server", required=False)
|
|
key = forms.CharField(label="Key", required=False)
|
|
urlLink = forms.CharField(label="Custom URL for links", required=False)
|
|
downloadLink = forms.CharField(label="Custom URL for downloading new versions", required=False)
|
|
compname = forms.CharField(label="Company name",required=False)
|
|
|
|
#Visual
|
|
iconfile = forms.FileField(label="Custom App Icon (in .png format)", required=False, widget=forms.FileInput(attrs={'accept': 'image/png'}))
|
|
logofile = forms.FileField(label="Custom App Logo (in .png format)", required=False, widget=forms.FileInput(attrs={'accept': 'image/png'}))
|
|
iconbase64 = forms.CharField(required=False)
|
|
logobase64 = forms.CharField(required=False)
|
|
theme = forms.ChoiceField(choices=[
|
|
('light', 'Light'),
|
|
('dark', 'Dark'),
|
|
('system', 'Follow System')
|
|
], initial='system')
|
|
themeDorO = forms.ChoiceField(choices=[('default', 'Default'),('override', 'Override')], initial='default')
|
|
|
|
#Security
|
|
passApproveMode = forms.ChoiceField(choices=[('password','Accept sessions via password'),('click','Accept sessions via click'),('password-click','Accepts sessions via both')],initial='password-click')
|
|
permanentPassword = forms.CharField(widget=forms.PasswordInput(), required=False)
|
|
runasadmin = forms.ChoiceField(choices=[('false','No'),('true','Yes')], initial='false')
|
|
denyLan = forms.BooleanField(initial=False, required=False)
|
|
enableDirectIP = forms.BooleanField(initial=False, required=False)
|
|
#ipWhitelist = forms.BooleanField(initial=False, required=False)
|
|
autoClose = forms.BooleanField(initial=False, required=False)
|
|
|
|
#Permissions
|
|
permissionsDorO = forms.ChoiceField(choices=[('default', 'Default'),('override', 'Override')], initial='default')
|
|
permissionsType = forms.ChoiceField(choices=[('custom', 'Custom'),('full', 'Full Access'),('view','Screen share')], initial='custom')
|
|
enableKeyboard = forms.BooleanField(initial=True, required=False)
|
|
enableClipboard = forms.BooleanField(initial=True, required=False)
|
|
enableFileTransfer = forms.BooleanField(initial=True, required=False)
|
|
enableAudio = forms.BooleanField(initial=True, required=False)
|
|
enableTCP = forms.BooleanField(initial=True, required=False)
|
|
enableRemoteRestart = forms.BooleanField(initial=True, required=False)
|
|
enableRecording = forms.BooleanField(initial=True, required=False)
|
|
enableBlockingInput = forms.BooleanField(initial=True, required=False)
|
|
enableRemoteModi = forms.BooleanField(initial=False, required=False)
|
|
|
|
#Other
|
|
removeWallpaper = forms.BooleanField(initial=True, required=False)
|
|
|
|
defaultManual = forms.CharField(widget=forms.Textarea, required=False)
|
|
overrideManual = forms.CharField(widget=forms.Textarea, required=False)
|
|
|
|
#custom added features
|
|
cycleMonitor = forms.BooleanField(initial=False, required=False)
|
|
xOffline = forms.BooleanField(initial=False, required=False)
|
|
hidecm = forms.BooleanField(initial=False, required=False)
|
|
removeNewVersionNotif = forms.BooleanField(initial=False, required=False)
|
|
|
|
def clean_iconfile(self):
|
|
print("checking icon")
|
|
image = self.cleaned_data['iconfile']
|
|
if image:
|
|
try:
|
|
# Open the image using Pillow
|
|
img = Image.open(image)
|
|
|
|
# Check if the image is a PNG (optional, but good practice)
|
|
if img.format != 'PNG':
|
|
raise forms.ValidationError("Only PNG images are allowed.")
|
|
|
|
# Get image dimensions
|
|
width, height = img.size
|
|
|
|
# Check for square dimensions
|
|
if width != height:
|
|
raise forms.ValidationError("Custom App Icon dimensions must be square.")
|
|
|
|
return image
|
|
except OSError: # Handle cases where the uploaded file is not a valid image
|
|
raise forms.ValidationError("Invalid icon file.")
|
|
except Exception as e: # Catch any other image processing errors
|
|
raise forms.ValidationError(f"Error processing icon: {e}")
|