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

How can I implement enable and disable in the Echo Example #14

Open
Light-Wizzard opened this issue May 24, 2020 · 0 comments
Open

How can I implement enable and disable in the Echo Example #14

Light-Wizzard opened this issue May 24, 2020 · 0 comments

Comments

@Light-Wizzard
Copy link

Light-Wizzard commented May 24, 2020

Update: I set up an example project here https://github.com/Light-Wizzard/EchoReloadedService

What all do I need to implement, this is what I have so far if its even close, I was hoping you had an example that showed how to implement ServiceControl, what I was going to try is this:

# Header of Echo Server
#include <QtService/ServiceControl>
CommandResult onEnable();
CommandResult onDisable();
QtService::ServiceControl *myServerControl = nullptr;

# Echo Server cpp
EchoReloadedService::EchoReloadedService(int &argc, char **argv) : Service(argc, argv), myServerControl(nullptr)
{
    myServerControl->setParent(this);
}
QtService::Service::CommandResult EchoService:: onEnable()
{
    qDebug() << Q_FUNC_INFO;
    if (!myServerControl->isAutostartEnabled())
    {
        myServerControl->enableAutostart();
    }
    return CommandResult::Completed;
}
QtService::Service::CommandResult EchoService:: onDisable()
{
    qDebug() << Q_FUNC_INFO;
    if (myServerControl->isAutostartEnabled())
    {
        myServerControl->disableAutostart();
    }
    return CommandResult::Completed;
}

What I am trying to accomplish is simple, I want to create a Travis and AppVeyor installation app for a modified version of Echo Server and Controller, and I want the ability to use the enable/disable feature, and I am pretty sure in Unix its just a link that gets created and deleted, in Windows its a registry change, and my guess is that is what these functions do, but not so sure how to use them.

My goal here is to create an App the End Users can Fork or copy, which allows them to install and test this example, in a real-world application, so the Qt Installer Framework Installer will install the Echo Server, and the Echo Controller, fill filling the Name with the Default installation path and name, so the end-user only needs to hit the load button, I can enable the service in the installers script file.

This is all part of that Tututural I am working on, and where I am stuck at, I want to show the whole process for using QtService, from development to deployment, so it really needs this feature to be complete.

I need a way to connect this to arguments passed in to Qt main, passed through into QtServer, not sure how you do that yet, such that it takes --enable and --disable for --backend systemd diable and --backend systemd enable, how is this accomplished?

Its normal for me to get lost in new projects, and ask a lot of questions, and even mix stuff between them different projects you might have, and even in your case, the other project for a similar project for Windows exists, so it gets confusing, not sure why, PTSD, TBI, or just old age (60ish), but what really got my curiosity is your QtHttpServer Repo, having been a long time Wt, Cute user, I am wondering if they will include this ability, if so, what are your thoughts?

I have read your comments about Cute, if he has integrated it, I have no clue where to start looking, I did revisit his site today and I did not get deep into it for a few reasons, so I never finished my project with them, and why is simple, I could not find a nice way to ensure the client was not cut off, and I tried using HaProxy, in hope of keeping the old server up long enough for them to finish, thinking on a new request I would give them an updated server, but on a reboot, that just did not work out, and why I needed to find a better solution, and I am hoping to find out if QtHttpServer will provide this support, but even if it does, I still need my own implementation of it, to pull this off.

If I remember right, both Apache and NGINX use a thin c wrapper around script, that actually just kills the pid, and why I could never get my app to work with either, and why I say if I remember right, its been a while, and things might have changed, but last I looked, it did not have the ability to negotiate with clients, for example, I need to reboot, so I want to send out a command to all Clients to go into an offline mode in so many seconds, or auto offline will kick in automatically unless you want to reschedule this now, and wait for time out, then if no reply, make all online clients offline, and after reboot, mark them online again, so this is also a feature that Echo Server should have.

What I want to do is write an expanded version of Echo, maybe change the name, and start a new project, so this does not get confusing, I Forked QtServer, so to keep it simple, we can call it "Echo Reloaded" since that is the main feature I am adding, the ability to ask the Client if its ok to reload, or reboot the server, and even add a scheduler, that can push cron events in Unix, and Scheduled Task in Windows, so it can be a useful example, even a template for other apps to be based on.

WeBookServer will use this app for its template, so I need the ability to run QtHttpServer, so I can use this feature, to control it, and that is what the tutorial there is all about.

WeBookClient needs to connect to WeBookServer, and since it cannot connect like Echo Client, and really I only want the Admin to have the ability to reload or reboot the server, and I still want to use a Qt c++ app, as such, my WeBookClient needs to talk directly to WeBookServer, and negotiate and verify AES encrypted traffic, so that the Client can Authenticate with the Server, without the need or use of User Name and Password, the reason why should be self-evident, if you follow my train of thought, and out of High School I was an Air Brake Machanic on Trains, so this is a long train ride, and we have a lot of clients to serve, so I want to be able to control access to only clients that were built using my Travis or AppVeyor account, so I can verify the checksum or some metadata I can compile into it, using a backside Environment variable for security, to ensure the Client and Server are both writen and compiled by the same GitHub/Travis/AppVeyor account, if you are following this train, you see the trail of Trust, now SSL is fine, but that comes at a cost, as does using GitHub/Travis/AppVeyor Private accounts, but SSL has issues, and User Name and Password is just Crazy, now SSH is one option is you can get it to work using a key, that is another train of thought, but easy enought to test, I have a VPS account that is keyed, but end users need more options, not everyone can get a VPS account with a keyed access, so I am looking for options that have SSL and User Name/Password, as the last option, if you know what I mean.

I will finish as much as possible, the Tutorials for WeBookServer and WeBookClient, but the Client is not like Echo Controller, the concept is that your first option is a VPS account, you create a key, and key it the first time you log in, this will be in the Tutorial, still need to verify this works, before moving on to the next option, which gets more limiting as you go along.

Now my question is this, can I, meaning should I, connect with the TCP server like Echo Controller, and this gets back to if you can do this over a keyed ssh connection, or the next type of authentication level that works. The end goal is easy, I use Qt-AES for Encryption, I could have picked an approved method, but did not need it the way I implement this, as such, only the Server and Client know the keys, or have the keys, and without them, the communication is just gibberish, so I do not really need SSL, my method uses a random authentication method, so it does not repeat the same authentication twice, preventing the middle man attacks, and you could enhance this with SSL even if its self-signed, so you need to test all your options and make them features. Most of the Tutorial for WeBook is already started, but I needed a better foundation to start with for the Server.

WeBook itself is a Qt c++ Rich Text Editor that saves to HTML, it manages it like a Web-Book, and making that one-word as in webbook, did not work for me, it manages it like a book, with chapters, and sub-chapters, and the Server just routes it to its destination, with Navigation built-in, so the end-user controls the web site via the Tree View it creates, so QtHttpServer is a match for what it needs to do out of the box, and all the app does is manage the books, contacts, calendar, and files, for collaboration via the WeBookClient, as such, they form a Domain Controller Group and have a Central Login Manager built-in, and it manages SSH keys, it can generate them, issue them, verify them, and revoke them.

I want to make WeBookClient have both Admin abilities to log into and control their own Domain, but also the ability to join others as just a Client.

WeBook also handles file synchronization, and chat, text, video, as well as file exchange, with all collaborators, so it also needs to run clamscan and maldetect on all these types of communications, so I need a way to communicate with the Server as an Admin, so I can manage this account, using this software, so the tutorial is going to be broken down into sections to cover all the aspects of it, but I imagine I can push the boundaries of what it can do.

That is the road-map this train is going away, one step at a time, with tones of questions in between, joking, I hope to keep it to as few as possible, I just wanted to give you enough details to understand where this Tutorial is going and ask you if Echo example will work with the modifications I need, or if there is a better road to take.

I have not posted any code for WeBookServer yet, but I am working on the Wiki:

https://github.com/Light-Wizzard/WeBookServer/wiki/System.d

Thanks for any help, Flesh

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

No branches or pull requests

1 participant