58 lines
1.1 KiB
C++
58 lines
1.1 KiB
C++
#include "VStarCam/Finder.h"
|
|
#include <INIReader.h>
|
|
#include <Logging.h>
|
|
#include <sstream>
|
|
#include <string>
|
|
|
|
|
|
int main(int argc, char** argv)
|
|
{
|
|
try
|
|
{
|
|
Logging::OpenLog();
|
|
Logging::SetLogMask(Logging::Severity::Info);
|
|
|
|
if (argc != 2)
|
|
{
|
|
std::stringstream ss;
|
|
ss << "Usage: " << argv[0] << " <ipaddress>";
|
|
Logging::Log(Logging::Severity::Error, ss.str());
|
|
return 1;
|
|
}
|
|
|
|
INIReader iniReader("VStarCamFinder.ini");
|
|
if (iniReader.ParseError() != 0)
|
|
{
|
|
Logging::Log(Logging::Severity::Error, "Can't read VStarCamFinder.ini");
|
|
return 1;
|
|
}
|
|
|
|
std::string ipAddress(argv[1]);
|
|
std::string listenAddress = iniReader.Get("VStarCamFinder", "ListenAddress", "0.0.0.0");
|
|
|
|
int port = 0;
|
|
|
|
VStarCam::Finder finder(listenAddress);
|
|
port = finder.GetPort(ipAddress);
|
|
|
|
if (port != 0)
|
|
{
|
|
std::stringstream ss;
|
|
ss << port;
|
|
Logging::Log(Logging::Severity::Error, ss.str());
|
|
return 0;
|
|
}
|
|
|
|
return 1;
|
|
}
|
|
catch (const std::exception& e)
|
|
{
|
|
std::stringstream ss;
|
|
ss << "ERROR: " << e.what() << std::endl;
|
|
|
|
Logging::Log(Logging::Severity::Error, ss.str());
|
|
|
|
return 1;
|
|
}
|
|
}
|