mirror of
https://github.com/g4klx/MMDVMHost.git
synced 2025-12-06 05:32:00 +01:00
add IPv6 support for RemoteControl
To specify IP(v4/v6) address for RemoteControl port, add Address parameter in [RemoteControl] section to MMDVM.ini. Different from other Address(es), the default IP address of RemoteControl is 127.0.0.1 for security.
This commit is contained in:
parent
88bbb0cd0f
commit
5df1fe551f
8
Conf.cpp
8
Conf.cpp
|
|
@ -250,6 +250,7 @@ m_mobileGPSEnabled(false),
|
|||
m_mobileGPSAddress(),
|
||||
m_mobileGPSPort(0U),
|
||||
m_remoteControlEnabled(false),
|
||||
m_remoteControlAddress("127.0.0.1"),
|
||||
m_remoteControlPort(0U)
|
||||
{
|
||||
}
|
||||
|
|
@ -838,6 +839,8 @@ bool CConf::read()
|
|||
} else if (section == SECTION_REMOTE_CONTROL) {
|
||||
if (::strcmp(key, "Enable") == 0)
|
||||
m_remoteControlEnabled = ::atoi(value) == 1;
|
||||
else if (::strcmp(key, "Address") == 0)
|
||||
m_remoteControlAddress = value;
|
||||
else if (::strcmp(key, "Port") == 0)
|
||||
m_remoteControlPort = (unsigned int)::atoi(value);
|
||||
}
|
||||
|
|
@ -1794,6 +1797,11 @@ bool CConf::getRemoteControlEnabled() const
|
|||
return m_remoteControlEnabled;
|
||||
}
|
||||
|
||||
std::string CConf::getRemoteControlAddress() const
|
||||
{
|
||||
return m_remoteControlAddress;
|
||||
}
|
||||
|
||||
unsigned int CConf::getRemoteControlPort() const
|
||||
{
|
||||
return m_remoteControlPort;
|
||||
|
|
|
|||
2
Conf.h
2
Conf.h
|
|
@ -276,6 +276,7 @@ public:
|
|||
|
||||
// The Remote Control section
|
||||
bool getRemoteControlEnabled() const;
|
||||
std::string getRemoteControlAddress() const;
|
||||
unsigned int getRemoteControlPort() const;
|
||||
|
||||
private:
|
||||
|
|
@ -497,6 +498,7 @@ private:
|
|||
unsigned int m_mobileGPSPort;
|
||||
|
||||
bool m_remoteControlEnabled;
|
||||
std::string m_remoteControlAddress;
|
||||
unsigned int m_remoteControlPort;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -257,4 +257,5 @@ Port=7834
|
|||
|
||||
[Remote Control]
|
||||
Enable=0
|
||||
Address=127.0.0.1
|
||||
Port=7642
|
||||
|
|
|
|||
|
|
@ -606,12 +606,14 @@ int CMMDVMHost::run()
|
|||
|
||||
bool remoteControlEnabled = m_conf.getRemoteControlEnabled();
|
||||
if (remoteControlEnabled) {
|
||||
std::string address = m_conf.getRemoteControlAddress();
|
||||
unsigned int port = m_conf.getRemoteControlPort();
|
||||
|
||||
LogInfo("Remote Control Parameters");
|
||||
LogInfo(" Address: %s", address.c_str());
|
||||
LogInfo(" Port: %u", port);
|
||||
|
||||
m_remoteControl = new CRemoteControl(port);
|
||||
m_remoteControl = new CRemoteControl(address, port);
|
||||
|
||||
ret = m_remoteControl->open();
|
||||
if (!ret) {
|
||||
|
|
|
|||
|
|
@ -29,8 +29,8 @@ const unsigned int PAGE_ARGS = 3U;
|
|||
|
||||
const unsigned int BUFFER_LENGTH = 100U;
|
||||
|
||||
CRemoteControl::CRemoteControl(unsigned int port) :
|
||||
m_socket(port),
|
||||
CRemoteControl::CRemoteControl(const std::string address, unsigned int port) :
|
||||
m_socket(address, port),
|
||||
m_command(RCD_NONE),
|
||||
m_args()
|
||||
{
|
||||
|
|
@ -43,7 +43,7 @@ CRemoteControl::~CRemoteControl()
|
|||
|
||||
bool CRemoteControl::open()
|
||||
{
|
||||
return m_socket.open(AF_INET); /* XXX IPv4 only */
|
||||
return m_socket.open();
|
||||
}
|
||||
|
||||
REMOTE_COMMAND CRemoteControl::getCommand()
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ enum REMOTE_COMMAND {
|
|||
|
||||
class CRemoteControl {
|
||||
public:
|
||||
CRemoteControl(unsigned int port);
|
||||
CRemoteControl(const std::string address, unsigned int port);
|
||||
~CRemoteControl();
|
||||
|
||||
bool open();
|
||||
|
|
|
|||
Loading…
Reference in a new issue