-
-
Notifications
You must be signed in to change notification settings - Fork 529
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
Protocol handler #540
Protocol handler #540
Conversation
You can also install the protocol handler on Windows by applying this |
Yea, the situation is kinda annoying, not even the Windows build on GitHub works here (missing zip bug). My PR to fix the Visual Studio solution is also not merged e.g. This project could probably benefit from more maintainers, that want to review additions and then merge. At least everyone else can review and leave their opinions, too, to help brainstorm the side effects of new PR's plus debugging them. |
@stefansundin |
@maintainers Why not add such a short HOWTO-Build txt file (or included in the current README) just as a basic tutorial. |
Please keep this PR to discussing the PR, I'm glad for protocol handler support it's something we should have had a long time ago. Wiki movement status is here: https://discourse.ioquake.org/t/moving-the-wiki-content-to-wordpress/1606/ |
Please let me know if there's anything else in this that should be changed. Is there a process for moving this forward or even merging it? Or do we leave it like this until there's free time for the maintainers to take a deeper look? Thanks! |
Looks good, in general. Style wise it's a bit inconsistent (e.g. brace position); try and match the prevailing style in the file you're changing. One thing I think you should change is to avoid the I don't know if installing the handler should be optional on Windows? Seems unlikely you would not want to have it, and it isn't really harmful if you don't use it. That's perhaps something of a wider discussion though, I have no strong feelings there. |
Ah, good point, I'll try to match it better.
Ok, will give this a try too.
I had the same thought regarding the various optional DLLs. Why not always install SDL and OpenAL stuff as part of the required ioquake3 section? 🤷 |
I suspect the SDL option might be a historical thing from the before times when we didn't have SDL working on Windows? I don't actually know though. I think curl and OpenAL are separated out just so they can be conditionally enabled, but that could probably be done in a more fine grained way like the rest of the libraries. But yeah I would just install the protocol handler without asking, other opinions may differ. I haven't touched ioq3 for quite some time now so my opinion is probably worth less that it used to. |
I guess the only benefit of having it in the installer is that it might bring some awareness to the feature. Otherwise most people won't know that it is there. Thinking about it more, it is more important to make sure that admins of server directories such as quakeservers.net learn about the feature so that they can add buttons to their websites. But before they can do that there has to be a new release of ioquake3 so that users can actually install a version that supports the protocol handler. |
FYI: i've integrated this into worldofpadman: PadWorld-Entertainment/worldofpadman@8efa0b3 Thanks a lot. |
@mgerhardy Looks great! I'm guessing Join buttons will eventually appear on https://worldofpadman.net/en/servers/? :) |
@timangus I pushed some code style updates. Let me know if you can think of anything else. |
2c2da0f
to
bb31630
Compare
IPv6This is missing support -std=gnu89Newer GCC changed default C standard from gnu89 to gnu99. Variable declarations should be at the beginning of a {} block and not in strstr
|
Thanks @zturtleman, will look into your suggestions. Definitely want to make sure this works on the net of the future. 👍 |
I'm not sure if this will help you, just in case you still want to know how your work compiles on Windows with Cygwin. |
Okay, so I think I addressed all of the new feedback. Thanks @KuehnhammerTobias. I was able to compile it on Windows but I don't recall seeing the warnings. I had so much pain getting it to work so I probably missed it. To support IPv6 addresses, I simply added I paginated through all the servers on https://www.quakeservers.net/quake3/servers/ but I couldn't see any IPv6 addresses there, so I haven't been able to test that it works as intended. Another thing that is worth mentioning is that we've discussed this a bit in one of the Star Trek: Elite Force discords. It is very common to distribute mods using simple zip files, so without any installer that would perform the windows registry setup. This is less of a problem on macOS (just drag it to Another option would be to include a |
Arbitrary command executionUsing this pull request it's possible to run arbitrary console commands from clicking a link in a web browser. This has been tested on Linux. Windows has not been tested but is most likely also affected. macOS doesn't pass "quake3:…" on the command line so it is not affected. This code has not been included in released software in my knowledge. It has been integrated into World of Padman source code by @mgerhardy though. Main credit to @Daggolin for pointing out the arbitrary command execution issue. ProblemThe As it is, the
These launch the game and set When run from a web browser (tested on Linux with Firefox and Google Chrome) spaces and others that are whitespace in Q3 parser are URL encoded. Spaces in "set pwned 1" become Quote escapeThis part is largely irrelevant since web browsers (Firefox and Google Chrome on Linux at least) turned out to replace spaces with If
Outer double quotes so Linux shell will pass it as a single argument to ioquake3 and escaped double quotes SolutionI would move checking for PROTOCOL_HANDLER to above In code/sys/sys_main.c (pseudocode):
ConclusionI was going to test this issue on Windows and actually patch it but I haven't worked on this for almost two weeks now so I'm giving up. I haven't thoroughly reviewed whether It would be a good idea to limit the hostname/address+port length to be less or equal to I think more security testing/review would probably be a good idea before shipping this to users. (I've run out of interest to work on it though.) |
Ah, nice catch. There's also a slight risk if the user installs an ioq3 without protocol handler support (or a build where To make this more robust, a new switch can be added before the protocol URI itself, e.g. Example: The installer would write a slightly different registry key with
And to be safe it should just drop any extra arguments after the URI. |
It's similar for the Lilium Voyager project, which is derived from ioQuake3. Personally I cross-compile via Linux. Works a lot easier and the result does not disappoint. If only I could do that for MacOS target was well... |
} | ||
|
||
bufsize = strlen( "connect " ) + i + 1; | ||
out = malloc( bufsize ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code now run too early for Z_malloc
to work (I got segfault when I tried to use it).
Would this allow a malicious mod/game to write arbitrary commands to the registry or is that already protected by the other changes above? |
You mean a random quake 3 mod that you downloaded somewhere on the internet? Since it is already executing code on your computer it wouldn't need By the way, is it possible for a server to run console commands on clients? Could a server initiate this command on a client's game? Even if that is the case I don't think it could be used particularly maliciously. The command doesn't take any arguments so it always writes the same registry keys based on what
In the installer, Hope this answered the question. |
There is one problem on macOS that I am having a bit of a hard time solving.. For some reason, because of the
Deleting Commenting out the call to |
What's the thinking behind the command in the first place? Not sure I understand the necessity if the installer already does it. |
It was explained in this comment: #540 (comment)
I'm okay with removing it if that's a consensus that is reached here. |
It seems like an odd thing to include, since it's solving a problem that exists outside of ioq3 and that could be solved by a simple .reg file as you say. (And I doubt people extracting things from zip files manually particularly care if the protocol handler registration ends up in HKLM or HKCU.) Other than that it looks good. |
Removed the console command. Edit: I also rebased locally and made sure it works with all the changes merged since I forked. It seems to work just fine in my quick test. |
Is the Sys_*ExecutablePath stuff still necessary? |
1d9dade
to
cde04a4
Compare
@timangus You're completely right, I forgot that it was related to the console command. Removed it. I had a thought that calling this "protocol handler" might confuse it with the quake 3 network protocol. Perhaps it would be better to call it "os protocol handler" or "system protocol handler"? Let me know if I should rename it. |
Hyperlink/link/url/uri handler would probably be more appropriate, and less open to misinterpretation as you say... In any case you'll need to rebase onto main at some point since the Linux CI was apparently broken until recently, and won't complete if I do a test run here. What was the error you got when pushing? |
This lets the user click a link in a web browser to very easily join a Quake 3 multiplayer game. As browser-based matchmaking websites become more popular, this makes it a lot more convenient and simple to play Quake 3 with others. The links have the following URI format: quake3://connect/example.com:27950. The format has been designed to be flexible to allow more types of links in the future and avoiding having to make a breaking change. At the moment, "connect" is the only supported command.
…quake3:" matches, and then advances two more characters if "//" comes after it.
…ndLine instead of calling Com_QueueEvent directly. For security reasons, require that a "--uri" argument is before the protocol URI, so that an arbitrary URI from a browser can easily be ignored (this is important if the registry keys are configured even though PROTOCOL_HANDLER is undefined). Ignore any extraneous arguments after the protocol URI.
… on Windows (for the current user only).
…inal on macOS too.
… be initialized before any call to Sys_Dialog). Return the protocol command from Sys_InitProtocolHandler on macOS so that all platforms can append the console command to commandLine.
cde04a4
to
480dc24
Compare
I was able to do it now. I had accidentally configured my git remote to use https instead of SSH and this is the error I got:
I usually never use https to clone but I had used it to test something completely unrelated. |
This lets the user click a link in a web browser to very easily join a Quake 3 multiplayer game. As browser-based matchmaking websites become more popular, this makes it a lot more convenient and simple to play Quake 3 with others.
The links have the following URI format:
quake3://connect/example.com:27950
. The format has been designed to be flexible to allow more types of links in the future and avoiding having to make a breaking change. At the moment,connect
is the only supported command.Just imagine if each of the servers on the page https://www.quakeservers.net/quake3/servers/ had a button next to it that said Join Server. I think that would make it easier to both attract new players, and keep them engaged in the longer term.
When you click a link, you will see a prompt like the following:
Just click Open Link and you'll be connected to the server. Simple!
An example of a mod/website that already does this is https://efservers.com/. The only difficulty there is that you have to make further modifications to your system and install a program that sits in between the website and the game. If we can get protocol handler support added directly into ioq3 then the steps that a user has to follow is minimized and the whole process is simpler and more user friendly.
The efservers website has only supported Windows. Recently I contributed handlers for Linux and macOS. My hope is that we can get this added to ioq3, and then I will work to update Lilium Voyager and Tulip Voyager in a way that supports this new protocol handler format, in addition to the current format that efservers is currently using.
I have tested this on Windows, Linux, and macOS, and it works very well on all of them. For Windows you need to create registry entries (the installer creates them if you don't unselect "Protocol Handler"). For Linux you need to install the updated
.desktop
file. For macOS you just need to drop the bundle in/Applications
like normal.The second commit adds descriptions to the Windows installer. I think I really need that to explain what a "Protocol handler" is, and I like the result.
As a final note, I found it extremely hard to figure out how to compile and build on Windows. Even worse since the wiki is down. I eventually found it on archive.org (https://web.archive.org/web/20190506050817/http://wiki.ioquake3.org/Building_ioQuake3). I first tried to use Cygwin but failed. Then I tried msys2 and got it working but I had to mess with a lot of files. Lots that could be improved here. I should probably have abandoned my attempts and just relied on GitHub Actions for Windows builds. 🤷
Please let me know what you think. :)