Implement remote command support.

- Defaut port is 7643 (totally arbitrary)

- Using RemoteCommandDMRG, each network can be enabled or disabled (net1 .. net5, xlx):
    ~ $ RemoteCommandDMRG 7643 disable net2
    M: 2021-03-20 11:48:40.494 Command sent: "disable net2" to port: 7643
    M: 2021-03-20 11:48:40.545 OK

- Using RemoteCommandDMRG, a connection status can be retrieved:
    ~ $ RemoteCommandDMRG 7643 status
    M: 2021-03-20 11:49:13.513 Command sent: "status" to port: 7643
    M: 2021-03-20 11:49:13.563 xlx:conn net1:conn net2:n/a net3:n/a net4:conn net5:n/a

A returned string is expected from the socket connection, this is why I did not reuse the MMDVMHost's RemoteCommand (unless MMDVMHost RemoteControl is modified as well).

The exit value can be used in scripting (also 1 if we didn't get any reply).
This commit is contained in:
Daniel Caujolle-Bert 2021-03-20 13:03:19 +01:00
parent aff04fd6b1
commit 41a49d5785
14 changed files with 683 additions and 74 deletions

9
Conf.h
View file

@ -241,6 +241,11 @@ public:
bool getDynamicTGControlEnabled() const;
unsigned int getDynamicTGControlPort() const;
// The Remote Control section
bool getRemoteControlEnabled() const;
std::string getRemoteControlAddress() const;
unsigned int getRemoteControlPort() const;
private:
std::string m_file;
bool m_daemon;
@ -393,6 +398,10 @@ private:
bool m_dynamicTGControlEnabled;
unsigned int m_dynamicTGControlPort;
bool m_remoteControlEnabled;
std::string m_remoteControlAddress;
unsigned int m_remoteControlPort;
};
#endif