Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linux version #2

Open
Atrate opened this issue Aug 27, 2021 · 8 comments
Open

Linux version #2

Atrate opened this issue Aug 27, 2021 · 8 comments
Labels
enhancement New feature or request

Comments

@Atrate
Copy link

Atrate commented Aug 27, 2021

Hey there,

thanks for continuing the work on the plugin! I feel like one important thing that's missing is an installer for Linux, especially given the fact that the target audience (people interested in protecting their privacy through encryption) are also highly likely to be Linux users.

@Atrate
Copy link
Author

Atrate commented Aug 27, 2021

One way to achieve that would be to provide a version of SDC-E that would be loaded via BetterDiscord. Another would be to simply provide an .sh file that would install SDC-E for Linux.

@Ceiridge
Copy link
Owner

I generally never support Linux (because in my opinion it is a server OS and not a desktop OS), but maybe you can hack it together in this case:
The powershell installer writes to javascript files and replaces common shortcuts with this command line:
C:\Windows\System32\cmd.exe /c "set NODE_OPTIONS=-r ../../SimpleDiscordCrypt/NodeLoad.js && start ^"^" ^"C:\Users\PPG\AppData\Local\Discord\Update.exe^" --processStart Discord.exe"

So, you would need to create a bash file or something that sets the environment variable NODE_OPTIONS to the NodeLoad.js file (can be found in the installer script somewhere) and you will also have to store SimpleDiscordCryptLoader.js (also in the installer) in the same folder.
SimpleDiscordCrypt cannot be installed as a BetterDiscord plugin, because it hooks some Electron stuff.
So basically, you would need to translate the command line above to Linux.

The original developer also doesn't seem to care much: https://gitlab.com/An0/SimpleDiscordCrypt/-/issues/2
If you manage to get it running, you can create a pull request or explain how you did it and maybe I will add a Linux installer here.

@Atrate
Copy link
Author

Atrate commented Aug 28, 2021

It's possible to do it if Discord is installed via flatpak, but for some reason SDC simply does not load, how would I go about debugging that?

The flatpak command to do it is:

flatpak override --user --env=NODE_OPTIONS='-r /home/<USER>/.var/app/com.discordapp.Discord/config/discord/simplediscordcrypt/NodeLoad.js' com.discordapp.Discord

@Ceiridge
Copy link
Owner

Maybe you can view the output of the devtools (Ctrl+Shift+I). -r stands for require in the NODE_OPTIONS, so maybe it has to be a relative path to the working directory. Also make sure that the SimpleDiscordCryptLoader.js exists in the same location.
Another way to debug would be to add a file write, alert? or even a while(true){} loop in the NodeLoad.js to make sure that it is executed

@Ceiridge Ceiridge added the enhancement New feature or request label Sep 5, 2021
@kup1o
Copy link

kup1o commented Jun 10, 2022

I was wondered about end-to-end encryption in Discord so Google put me there. Thank you @Ceiridge for the extended version of the plugin!

I was writing Linux bash script and I need to say that I'm not so familliar with powershell and nodejs syntax. Here is my Linux setup script.

However, when I run Discord with NodeJS file on a Linux machine I've got this error.
I've run Discord without NodeJS — everything works fine. I've run NodeJS file without Discord and I've got the same error.

Do you have any suggestions about how to resolve that error? Do I need to read some NodeJS documentation to resolve it on my own?

@Ceiridge
Copy link
Owner

@kup1o The Linux install script looks good, but you execute NodeLoad.js with nodejs after/while Discord is running.
https://github.com/Kup1o/SimpleDiscordCrypt-Extended/blob/5d6b2a7733754265a1e5946a2f0d2c322a9cf144/SimpleDiscordCryptInstaller.sh#L186

Instead, it should be executed by the Electron runtime, which can be done with an environment variable called NODE_OPTIONS:

$shortcut.Arguments = "/c `"set NODE_OPTIONS=-r ../../SimpleDiscordCrypt/NodeLoad.js && start ^`"^`" ^`"$path\Update.exe^`" --processStart electron.exe`""

  • The Windows SET command sets an environment variable
  • It is a relative path, because apparently the working directory is somewhere nearby NodeLoad. It would be worth looking at the working directory in Linux or you could find out the absolute path within the bash script
  • Then, Update.exe is started, which is quite an important Electron helper-application that checks for a new Discord version and then starts electron.exe in the newest application subfolder (with the commandline option --processStart). I recently have had an issue with it, because a hardlink in an application folder was missing, so maybe it should be changed to Discord.exe again.

By the way: The error probably occurs, because your NodeJS version is outdated and has some issues with the null coalescing operator ?, but updating wouldn't fix this anyway.

@kup1o
Copy link

kup1o commented May 11, 2023

@Ceiridge Finally got a freetime to work with the plugin. Oh, I didn't even notice how a year had passed through.

I installed discord_arch_electron package from AUR, which brings me discord and electron packages together so there's no a hardlink from discord to electron.

I got discord successfully running with node_options at electron runtime

➜  ~ ps -aux | grep electron
kjw        54608  1.1  2.3 1176641780 139164 pts/7 Sl+ 14:00   0:00 /usr/lib/electron/electron --NODE_OPTIONS /home/kjw/.config/SimpleDiscordCrypt/NodeLoad.js
kjw        54693 14.0  3.3 1176764960 196752 ?   Sl   14:00   0:03 /usr/lib/electron/electron /usr/lib/discord/app.asar

As I understand app.asar functions as Update.exe there.

But today plugin did not load either in windows or linux. I opened up my windows virtual machine and ran your SimpleDiscordCryptInstaller.ps1. The log was finished great as expected. NodeLoad.js & SimpleDiscordCryptLoader.js are located in the %LocalAppData%\Discord\app-1.0.901\SimpleDiscordCrypt. The discord shortcut's written properly. And even in the windows virtual machine the plugin could not be loaded. I tried install nodejs with additional modules on windows but plugin could not be loaded still.

I should note you that electron package flagged out of date now in AUR and I'm currently working on compiling discord_arch_electron with the latest electron 24.3.0 version, keep in mind that affects only linux.

Does the plugin work right now on your machine? If yes, where could I mess up something?

@Ceiridge
Copy link
Owner

@kup1o I know. It is (currently) broken. The original https://gitlab.com/An0/SimpleDiscordCrypt/ is also broken, too. I already tried looking into it and the bug is very difficult to solve, which is also why the original repo probably doesn't have a fix (yet).
It was enough for me to switch to Element/Matrix ( https://element.io/ ) for one user I had an encrypted conversation with.
I extremely appreciate you taking time trying to get it to work on Linux! Very good attempt!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants