mirror of
https://github.com/g4klx/MMDVMHost
synced 2025-12-22 08:05:49 +08: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:
8
Conf.cpp
8
Conf.cpp
@@ -250,6 +250,7 @@ m_mobileGPSEnabled(false),
|
|||||||
m_mobileGPSAddress(),
|
m_mobileGPSAddress(),
|
||||||
m_mobileGPSPort(0U),
|
m_mobileGPSPort(0U),
|
||||||
m_remoteControlEnabled(false),
|
m_remoteControlEnabled(false),
|
||||||
|
m_remoteControlAddress("127.0.0.1"),
|
||||||
m_remoteControlPort(0U)
|
m_remoteControlPort(0U)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -838,6 +839,8 @@ bool CConf::read()
|
|||||||
} else if (section == SECTION_REMOTE_CONTROL) {
|
} else if (section == SECTION_REMOTE_CONTROL) {
|
||||||
if (::strcmp(key, "Enable") == 0)
|
if (::strcmp(key, "Enable") == 0)
|
||||||
m_remoteControlEnabled = ::atoi(value) == 1;
|
m_remoteControlEnabled = ::atoi(value) == 1;
|
||||||
|
else if (::strcmp(key, "Address") == 0)
|
||||||
|
m_remoteControlAddress = value;
|
||||||
else if (::strcmp(key, "Port") == 0)
|
else if (::strcmp(key, "Port") == 0)
|
||||||
m_remoteControlPort = (unsigned int)::atoi(value);
|
m_remoteControlPort = (unsigned int)::atoi(value);
|
||||||
}
|
}
|
||||||
@@ -1794,6 +1797,11 @@ bool CConf::getRemoteControlEnabled() const
|
|||||||
return m_remoteControlEnabled;
|
return m_remoteControlEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string CConf::getRemoteControlAddress() const
|
||||||
|
{
|
||||||
|
return m_remoteControlAddress;
|
||||||
|
}
|
||||||
|
|
||||||
unsigned int CConf::getRemoteControlPort() const
|
unsigned int CConf::getRemoteControlPort() const
|
||||||
{
|
{
|
||||||
return m_remoteControlPort;
|
return m_remoteControlPort;
|
||||||
|
|||||||
2
Conf.h
2
Conf.h
@@ -276,6 +276,7 @@ public:
|
|||||||
|
|
||||||
// The Remote Control section
|
// The Remote Control section
|
||||||
bool getRemoteControlEnabled() const;
|
bool getRemoteControlEnabled() const;
|
||||||
|
std::string getRemoteControlAddress() const;
|
||||||
unsigned int getRemoteControlPort() const;
|
unsigned int getRemoteControlPort() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -497,6 +498,7 @@ private:
|
|||||||
unsigned int m_mobileGPSPort;
|
unsigned int m_mobileGPSPort;
|
||||||
|
|
||||||
bool m_remoteControlEnabled;
|
bool m_remoteControlEnabled;
|
||||||
|
std::string m_remoteControlAddress;
|
||||||
unsigned int m_remoteControlPort;
|
unsigned int m_remoteControlPort;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -257,4 +257,5 @@ Port=7834
|
|||||||
|
|
||||||
[Remote Control]
|
[Remote Control]
|
||||||
Enable=0
|
Enable=0
|
||||||
|
Address=127.0.0.1
|
||||||
Port=7642
|
Port=7642
|
||||||
|
|||||||
@@ -606,12 +606,14 @@ int CMMDVMHost::run()
|
|||||||
|
|
||||||
bool remoteControlEnabled = m_conf.getRemoteControlEnabled();
|
bool remoteControlEnabled = m_conf.getRemoteControlEnabled();
|
||||||
if (remoteControlEnabled) {
|
if (remoteControlEnabled) {
|
||||||
|
std::string address = m_conf.getRemoteControlAddress();
|
||||||
unsigned int port = m_conf.getRemoteControlPort();
|
unsigned int port = m_conf.getRemoteControlPort();
|
||||||
|
|
||||||
LogInfo("Remote Control Parameters");
|
LogInfo("Remote Control Parameters");
|
||||||
|
LogInfo(" Address: %s", address.c_str());
|
||||||
LogInfo(" Port: %u", port);
|
LogInfo(" Port: %u", port);
|
||||||
|
|
||||||
m_remoteControl = new CRemoteControl(port);
|
m_remoteControl = new CRemoteControl(address, port);
|
||||||
|
|
||||||
ret = m_remoteControl->open();
|
ret = m_remoteControl->open();
|
||||||
if (!ret) {
|
if (!ret) {
|
||||||
|
|||||||
@@ -29,8 +29,8 @@ const unsigned int PAGE_ARGS = 3U;
|
|||||||
|
|
||||||
const unsigned int BUFFER_LENGTH = 100U;
|
const unsigned int BUFFER_LENGTH = 100U;
|
||||||
|
|
||||||
CRemoteControl::CRemoteControl(unsigned int port) :
|
CRemoteControl::CRemoteControl(const std::string address, unsigned int port) :
|
||||||
m_socket(port),
|
m_socket(address, port),
|
||||||
m_command(RCD_NONE),
|
m_command(RCD_NONE),
|
||||||
m_args()
|
m_args()
|
||||||
{
|
{
|
||||||
@@ -43,7 +43,7 @@ CRemoteControl::~CRemoteControl()
|
|||||||
|
|
||||||
bool CRemoteControl::open()
|
bool CRemoteControl::open()
|
||||||
{
|
{
|
||||||
return m_socket.open(AF_INET); /* XXX IPv4 only */
|
return m_socket.open();
|
||||||
}
|
}
|
||||||
|
|
||||||
REMOTE_COMMAND CRemoteControl::getCommand()
|
REMOTE_COMMAND CRemoteControl::getCommand()
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ enum REMOTE_COMMAND {
|
|||||||
|
|
||||||
class CRemoteControl {
|
class CRemoteControl {
|
||||||
public:
|
public:
|
||||||
CRemoteControl(unsigned int port);
|
CRemoteControl(const std::string address, unsigned int port);
|
||||||
~CRemoteControl();
|
~CRemoteControl();
|
||||||
|
|
||||||
bool open();
|
bool open();
|
||||||
|
|||||||
Reference in New Issue
Block a user