📄 rogateway.h
字号:
#ifndef ROGATEWAY_H
#define ROGATEWAY_H
#pragma once
#include "Global.h"
#include "Localization.h"
#include "rores/resource.h"
#include "teamviewerinfo.h"
#define ROGATEWAY_REGISTRYKEY "SOFTWARE\\DynGate\\Router"
// The minimum DynGate-Version required
#define MINIMUM_DYNGATE_REQUIRED "2.42a"
// auf 2.42 erh鰄t wegen Updatehandling zu TV 3
// auf 2.35 erh鰄t wegen wichtigem Fix in DynGate
// auf 2.31 erh鰄t wegen Timeout-Verbindungsproblem
// Von 2.01 auf 2.10 erh鰄t wegen wichtigem Bugfix UDP
/*
CroGatway is mainly used for communication with roGatway (Dyngate).
*/
// Tell DynGate our reason to logout
#define LOGOUT_NO_CONNECT "TV_NO_CONNECT"
#define LOGOUT_TV_CONN_OUT "TV_CONN_OUT"
#define LOGOUT_TV_CONN_IN "TV_CONN_IN"
#define LOGOUT_GATEWAY_CLOSED "TV_GATEWAY_CLOSED"
#define TV_URL_JAVA "/java/"
#define TV_URL_DOWNLOAD "/download"
#define MESSAGETYPE_REQUESTSETTINGS -2000
#define MESSAGETYPE_SEND -2001
#define MESSAGETYPE_CONNECT -2002
#define MESSAGETYPE_LOGOUT -2003
#define MESSAGETYPE_DIALOG -2004
#define MESSAGETYPE_LOGIN -2005
#define CLIENTID "ClientID"
#define NUMERICID "NumericID"
#define GATEWAYNAME "Gatewayname"
#define VERSION "Version"
#define LICENSETYPE "LicenseType"
#define VNCCONNECTPORT "VNCConnectPort"
#define LICENSENAME "LicenseName"
#define HOSTMODE "HostMode"
// The Command structure to communicate with DynGate
struct _roGatewayData
{
int MessageType;
int ParamLength;
};
class CroGateway
{
public:
~CroGateway();
static CroGateway* Instance() // singleton
{
if(mInstance == NULL)
mInstance = new CroGateway;
return mInstance;
}
//returns true if a gateway is installed (but does not have to run)
bool GatewayInstalled() { return m_installed; }
//returns true if dyngate is running
bool GatewayRunning();
//returns the local Client ID
const char *ClientID() { return m_Variables[CLIENTID].data(); }
// The (local) number part of ID
long NumericID() { return atoi(m_Variables[NUMERICID].data()); }
// Gatewayname
const char *Gatewayname() { return m_Variables[GATEWAYNAME].data(); }
//checks if id is a correct one
bool isClientID(char *clientid);
//returns the gatway listen port (loaded from the registry at the beginning)
int GatewayListenPort() { return m_gwlistenport; }
//returns the the ip of dyngate - should be same pc
char *GatewayListenHost() { return "127.0.0.1"; }
//If DynGate is not found on the system it may be downloaded and installed automatically
bool DownloadDynGate(HWND hwnd);
bool InstallDynGate(HWND hwnd);
// If automatic download/install fails start download in browser
bool DownloadDynGateFallback(HWND hwnd);
// Checks if the given file is large enough to be a valid DynGate executable
bool IsValidExe(const char *path);
// Is the running DynGate a server version?
bool IsServer() { return m_Variables[VERSION].find(" S") != string::npos; }
// Is DynGate a VPN version?
bool IsVPN() { return m_Variables[VERSION].find(" VPN") != string::npos; }
// Close DynGate
void Shutdown();
bool Licensed();
bool QueryClientID();
std::string getLicenseName();
/*creates a connection using a masterserver
destClient contains a hostname/IP-address
First ConnectOverGateway tries to connect to the master server to
then it connects to the (local) gateway and sends the destination ip.
returns INVALID_SOCKET if something went wrong, otherwise
it sets this::m_sock to INVALID_SOCKET and returns a copy of this::m_sock.
*/
SOCKET ConnectOverGateway(char *destClient);
/*BeginWaitAtMaster tries to connecto to the (local) dyngate gateway.
It does nothing if m_waitingatmaster is already true.
A new socket in this::m_sock will be created or reused.
If connection succeeded it returns true and sets m_waitingatmaster true.
Otherwise (due to connection failure) it returns false.
*/
bool BeginWaitAtMaster(bool internet);
// Open and return a new socket
SOCKET NewSocket();
/*
EndWaitAtMaster closes down a connection to the dyngate gateway - opened with BeginWaitAtMaster
*/
void EndWaitAtMaster(char *lor = NULL);
bool InstallInquired() { return m_installinquired; };
void set_InstallInquired(bool param) { m_installinquired = param; };
bool ReadDyngateRegistry();
void ShowFreeUpgradeDialog();
static void PostServiceHelperMessage(long processId);
// Display DynGate Dialogs
void ShowOptions();
void ShowActivateLicense();
void ShowConnectivity();
bool PollDynGate();
void Reconnect();
bool SendCommand(int msgtype, string param, SOCKET sock = INVALID_SOCKET);
// Tell DynGate if HostMode is active
void HostMode(bool hostmode);
// Safely shut down
void Terminate();
void KillGateway(bool noRestart = false);
protected:
static CroGateway *mInstance;
map<string, string> m_Variables;
CroGateway(); // protected constructor -> use Instance() to get singleton object
// Start and Stop Gateway
void StartGateway();
bool m_installed; //is dyngate is installed - got from registry
int m_gwlistenport; //listen port of dyngate - got from registry
SOCKET m_sock; //socket to (local) dyngate - contains INVALID_SOCKET if no connection exists
bool m_waitingatmaster; //true if a connection to (local) dyngate exists, otherwise false
char m_installpath[256]; // Path to the DynGate.exe
bool m_installinquired; // allows to remember if install Messagebox was already shown
int m_connected; // 1: Dyngate activated
bool m_connecting; // StartGateway() l鋟ft
bool m_destroying; // Shutdown eingeleitet
bool m_polling;
bool m_noRestart;
};
#endif //#ifndef ROGATEWAY_H
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -