RetGal / Dayon

Dayon! - A cross-platform remote desktop assistance solution for your family and friends
https://retgal.github.io/Dayon/
GNU General Public License v3.0
146 stars 45 forks source link

QUESTION: How do I run a self hosted rendevous server? #67

Closed bmcgonag closed 10 months ago

bmcgonag commented 11 months ago

I was reading the site, and the README.md, but didn't see anything about the rendezvous server listed. Just the application. If the application connects to an outside server to "meet up" with an assistant, then it would be nice to be able to run my own rendezvous server as well.

Is this possible today? If not, will it be in the future?

RetGal commented 11 months ago

It depends: Currently, the TOKEN_SERVER_URL is hard coded. So you may alter it and build your own jars. The PHP script for running an rendezvous server instance can be found here: https://github.com/RetGal/Dayon/tree/master/ext

To make this configurable in the future is a bit tricky, as both, the assistant and the assisted must use the same rendezvous server. So either both would need an external config file containing the same rendezvous server URL, or the right rendezvous server URL would have to be somehow communicated to the assisted.

But Dayon! also works perfectly without a rendezvous server - you just have to communicate the public IP of the assistant to the assisted. You can even provide an assisted.yaml to to the assisted as described here: https://retgal.github.io/Dayon/quickstart.html (section Automatic connection of the assisted towards the bottom of the page)

RetGal commented 8 months ago

@bmcgonag I just added a config option for the token server url: https://retgal.github.io/Dayon/assisted.yaml. So in the next release, it will be possible to configure a self hosted rendez vous server. (no custom build required any more)

However, it will be crucial to put an additional assisted.yaml and assistant.yaml containing the same tokenServerUrl on each side!

lammel-hub commented 6 months ago

Just for my understanding: does this mean that Dayon! has the RVS "built in" all ready to run and be used as long as:

  1. The two yaml files are configured correctly, and
  2. Assistant is started
RetGal commented 6 months ago

Dayon! is prepared to use any custom hosted RVS aka token server.

If for example someone decides to run and use a custom RVS @ https://example.com/my-very-own-rvs Then this line is required in the two files (assisted.yaml and assistant.yaml), which then need to be placed nearby the assistant and assisted:

tokenServerUrl: "https://example.com/my-very-own-rvs"

nearby means: either in the Dayon! home directory, in the user directory, or in the same directory as the .jar, resp. .exe file

lammel-hub commented 6 months ago

Apologies, my question was unclear. I understand Dayon! Is prepared to use any RVS, but what I meant to ask was "Is Dayon! able to setup and run an RVS (as opposed to calling a pre-existing RVS), or is the RVS required to be setup and run as a completely separate matter (i.e. out of scope for the Dayton! source code)"

RetGal commented 6 months ago

No, it's not Dayon! itself who can directly setup run the RVS. But the script to do so is also available in this repository: https://github.com/RetGal/Dayon/tree/master/ext Perhaps I should add a Readme.md there - basically one just has to put the index.php file on a webserver, set the right permissions for the db which will be autocreated and it should already be up and running.

lammel-hub commented 6 months ago
  1. It would be fantastic if you could add a readme.md - I believe many would benefit from that. I would also like to see if I could get it up and running. It might be above my technical competence level, but I won't know before I try.
  2. Re. your comment above about putting the two .yaml files, I am not sure where they are located in Windows 11. I believe they may be in the installation folder of Dayon! which is completely hidden for a normal Admin (as it comes from MS Store). The only Dayon folder I could find on my machine is the .Dayon that contains the following files: image
RetGal commented 6 months ago
  1. Yes I, already added on in the meantime: https://github.com/RetGal/Dayon/tree/master/ext
  2. Yes, they can go either there or directly in your user folder. All the possible locations are also mentioned in the Readme)
lammel-hub commented 6 months ago

Excellent - thank you! Will see if I am able too, or if it is beyond me to get it up and running. Haven't set up a web server before...

lammel-hub commented 6 months ago

Please see the results of my test below. I am almost able to runt a local RVS, but something is missing for the last step to work.

Are you able to look at the below to see what might be the problem? Note: I fully respect if you tell me that it is not possible for you to help me get this running, so please just le me know if that is the case.

Web server with PHP and SQLite I am now running uwAmp as a portable web server. (Latest version 3.1.0)

Dayon configuration of web server

  1. Dayon's index.php is placed in the www folder of UwAmp
  2. dayon.db is placed in the same folder
  3. The web server has write rights to the database
  4. Assistant.yaml is placed in .dayon folder and the line is uncommented

Test: Specifying local IP

[    AWT-EventQueue-0] [ERROR] (12:57:15.946) Could not obtain token
javax.net.ssl.SSLHandshakeException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
    at java.base/sun.security.ssl.Alert.createSSLException(Unknown Source)
    at java.base/sun.security.ssl.TransportContext.fatal(Unknown Source)
    at java.base/sun.security.ssl.TransportContext.fatal(Unknown Source)
    at java.base/sun.security.ssl.TransportContext.fatal(Unknown Source)
    at java.base/sun.security.ssl.CertificateMessage$T12CertificateConsumer.checkServerCerts(Unknown Source)
    at java.base/sun.security.ssl.CertificateMessage$T12CertificateConsumer.onCertificate(Unknown Source)
    at java.base/sun.security.ssl.CertificateMessage$T12CertificateConsumer.consume(Unknown Source)
    at java.base/sun.security.ssl.SSLHandshake.consume(Unknown Source)
    at java.base/sun.security.ssl.HandshakeContext.dispatch(Unknown Source)
    at java.base/sun.security.ssl.HandshakeContext.dispatch(Unknown Source)
    at java.base/sun.security.ssl.TransportContext.dispatch(Unknown Source)
    at java.base/sun.security.ssl.SSLTransport.decode(Unknown Source)
    at java.base/sun.security.ssl.SSLSocketImpl.decode(Unknown Source)
    at java.base/sun.security.ssl.SSLSocketImpl.readHandshakeRecord(Unknown Source)
    at java.base/sun.security.ssl.SSLSocketImpl.startHandshake(Unknown Source)
    at java.base/sun.security.ssl.SSLSocketImpl.startHandshake(Unknown Source)
    at java.base/sun.net.www.protocol.https.HttpsClient.afterConnect(Unknown Source)
    at java.base/sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(Unknown Source)
    at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream0(Unknown Source)
    at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
    at java.base/sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(Unknown Source)
    at java.base/java.net.URL.openStream(Unknown Source)

Test: Specifying External IP

[ForkJoinPool.commonP] [ INFO] (13:04:37.335) UPnP is enabled
[    AWT-EventQueue-0] [ERROR] (13:04:59.720) Could not obtain token
java.net.ConnectException: Connection timed out: connect
    at java.base/java.net.PlainSocketImpl.connect0(Native Method)
    at java.base/java.net.PlainSocketImpl.socketConnect(Unknown Source)
    at java.base/java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
    at java.base/java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source)
    at java.base/java.net.AbstractPlainSocketImpl.connect(Unknown Source)
    at java.base/java.net.SocksSocketImpl.connect(Unknown Source)
    at java.base/java.net.Socket.connect(Unknown Source)
    at java.base/sun.security.ssl.SSLSocketImpl.connect(Unknown Source)
    at java.base/sun.security.ssl.BaseSSLSocketImpl.connect(Unknown Source)
    at java.base/sun.net.NetworkClient.doConnect(Unknown Source)
    at java.base/sun.net.www.http.HttpClient.openServer(Unknown Source)
    at java.base/sun.net.www.http.HttpClient.openServer(Unknown Source)
    at java.base/sun.net.www.protocol.https.HttpsClient.<init>(Unknown Source)
    at java.base/sun.net.www.protocol.https.HttpsClient.New(Unknown Source)
    at java.base/sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.getNewHttpClient(Unknown Source)
    at java.base/sun.net.www.protocol.http.HttpURLConnection.plainConnect0(Unknown Source)
    at java.base/sun.net.www.protocol.http.HttpURLConnection.plainConnect(Unknown Source)
    at java.base/sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(Unknown Source)
    at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream0(Unknown Source)
    at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
    at java.base/sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(Unknown Source)
    at java.base/java.net.URL.openStream(Unknown Source)
RetGal commented 6 months ago

Wow, that's cool! My guess is that the portable webserver just lacks the certificates for https. For testing purposes you could omit the 's' of https - so in your case probably tokenServerUrl: "http://127.0.0.1"

lammel-hub commented 6 months ago

thank you so much - that did the trick for internal IP...almost. See below the response in Dayon (but no error message, it seems to believe it is a usable Token) image This is soo close...

PS. I also tested with removing the dayon.db and the web server created it based on the Token request, as per your script, and returned the same result <br />

RetGal commented 6 months ago

hm, and if you open the URL in a browser? http://127.0.0.1?port=1234

lammel-hub commented 6 months ago

If i simply open the localhost it isa blank white page, but if I type exactly what you wrote above I get HTML-code visible that looks as follows:

<br />
<font size='1'><table class='xdebug-error xe-uncaught-exception' dir='ltr' border='1' cellspacing='0' cellpadding='1'>
<tr><th align='left' bgcolor='#f57900' colspan="5"><span style='background-color: #cc0000; color: #fce94f; font-size: x-large;'>( ! )</span> Fatal error: Uncaught exception 'Exception' with message 'DateTime::__construct(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone.' in [UserPath]\Dayon SE\UwAmp\www\index.php on line <i>73</i></th></tr>
<tr><th align='left' bgcolor='#f57900' colspan="5"><span style='background-color: #cc0000; color: #fce94f; font-size: x-large;'>( ! )</span> Exception: DateTime::__construct(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone. in [UserPath]\Dayon SE\UwAmp\www\index.php on line <i>73</i></th></tr>
<tr><th align='left' bgcolor='#e9b96e' colspan='5'>Call Stack</th></tr>
<tr><th align='center' bgcolor='#eeeeec'>#</th><th align='left' bgcolor='#eeeeec'>Time</th><th align='left' bgcolor='#eeeeec'>Memory</th><th align='left' bgcolor='#eeeeec'>Function</th><th align='left' bgcolor='#eeeeec'>Location</th></tr>
<tr><td bgcolor='#eeeeec' align='center'>1</td><td bgcolor='#eeeeec' align='center'>0.0018</td><td bgcolor='#eeeeec' align='right'>165896</td><td bgcolor='#eeeeec'>{main}(  )</td><td title='[UserPath]\Dayon SE\UwAmp\www\index.php' bgcolor='#eeeeec'>...\index.php<b>:</b>0</td></tr>
<tr><td bgcolor='#eeeeec' align='center'>2</td><td bgcolor='#eeeeec' align='center'>0.0031</td><td bgcolor='#eeeeec' align='right'>166632</td><td bgcolor='#eeeeec'>createToken(  )</td><td title='C:\Users\Lucas [UserPath]\Dayon SE\UwAmp\www\index.php' bgcolor='#eeeeec'>...\index.php<b>:</b>17</td></tr>
<tr><td bgcolor='#eeeeec' align='center'>3</td><td bgcolor='#eeeeec' align='center'>0.0033</td><td bgcolor='#eeeeec' align='right'>166920</td><td bgcolor='#eeeeec'>insertToken(  )</td><td title='[UserPath]\Dayon SE\UwAmp\www\index.php' bgcolor='#eeeeec'>...\index.php<b>:</b>47</td></tr>
<tr><td bgcolor='#eeeeec' align='center'>4</td><td bgcolor='#eeeeec' align='center'>0.0033</td><td bgcolor='#eeeeec' align='right'>167136</td><td bgcolor='#eeeeec'><a href='http://www.php.net/DateTime.construct' target='_new'>__construct</a>
(  )</td><td title='[UserPath]\Dayon SE\UwAmp\www\index.php' bgcolor='#eeeeec'>...\index.php<b>:</b>73</td></tr>
</table></font>
lammel-hub commented 6 months ago

I also found this log for the dayon.db in the web server: image and this image

lammel-hub commented 6 months ago

and the table is still empty after the <br /> is shown as Token in Dayon image

lammel-hub commented 6 months ago

just to make sure the db structure looks correct to you: image

RetGal commented 6 months ago

Great, the case was hidden in the source of the "white page". Your webserver seems missing a valid timezone configuration. I updated the script, so it doesn't rely on the timezone any more - this version should now finally work! index.php

lammel-hub commented 6 months ago

succes!! Great work - thanks!

lammel-hub commented 6 months ago

Will it still keep track of the 7 day token lifespan?

RetGal commented 6 months ago

Yes. The lifespan is defined in seconds - and a certain amount of seconds is always the same duration, no matter which timezone :)