aboutsummaryrefslogtreecommitdiffstats
path: root/jetting-proxy/main.cpp
blob: 0e1405446da3e38934b474565d28c805774751fe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/**
 * @file   main.cpp
 * @brief  Jetting proxy — relay between one controller and N clients.
 */
#include "JettingProxy.h"

#include <QCommandLineParser>
#include <QCoreApplication>

int
main (int argc, char *argv[])
{
  qSetMessagePattern ("Proxy      [%{time HH:mm:ss.zzz}] %{message}");

  QCoreApplication app (argc, argv);

  QCommandLineParser parser;
  parser.addOption ({ "wire-debug", "Log forwarded frames to dev log" });
  parser.addOption ({ "controller-port",
                      "Base port for controller side (default 9110)", "port",
                      "9110" });
  parser.addOption ({ "client-port",
                      "Base port for client side (default 9210)", "port",
                      "9210" });
  parser.addHelpOption ();
  parser.process (app);

  if (parser.isSet ("wire-debug"))
    JettingProxy::enableWireDebug ();

  quint16 controllerPort = parser.value ("controller-port").toUShort ();
  quint16 clientPort = parser.value ("client-port").toUShort ();

  new JettingProxy (controllerPort, clientPort, &app);

  return app.exec ();
}