mirror of https://github.com/PurpleI2P/i2pd.git
I2P: End-to-End encrypted and anonymous Internet
https://i2pd.website/
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
80 lines
1.6 KiB
80 lines
1.6 KiB
![]()
10 years ago
|
#ifndef __UPNP_H__
|
||
|
#define __UPNP_H__
|
||
|
|
||
|
#ifdef USE_UPNP
|
||
|
#include <string>
|
||
|
#include <thread>
|
||
![]()
8 years ago
|
#include <condition_variable>
|
||
|
#include <mutex>
|
||
![]()
8 years ago
|
#include <memory>
|
||
![]()
10 years ago
|
|
||
|
#include <miniupnpc/miniwget.h>
|
||
|
#include <miniupnpc/miniupnpc.h>
|
||
|
#include <miniupnpc/upnpcommands.h>
|
||
|
#include <miniupnpc/upnperrors.h>
|
||
![]()
11 years ago
|
|
||
|
#include <boost/asio.hpp>
|
||
|
|
||
|
namespace i2p
|
||
|
{
|
||
![]()
9 years ago
|
namespace transport
|
||
![]()
10 years ago
|
{
|
||
![]()
11 years ago
|
class UPnP
|
||
|
{
|
||
![]()
10 years ago
|
public:
|
||
|
|
||
|
UPnP ();
|
||
|
~UPnP ();
|
||
|
void Close ();
|
||
|
|
||
|
void Start ();
|
||
|
void Stop ();
|
||
|
|
||
|
private:
|
||
![]()
8 years ago
|
|
||
|
void Discover ();
|
||
|
void PortMapping ();
|
||
|
void TryPortMapping (std::shared_ptr<i2p::data::RouterInfo::Address> address);
|
||
|
void CloseMapping ();
|
||
|
void CloseMapping (std::shared_ptr<i2p::data::RouterInfo::Address> address);
|
||
|
|
||
![]()
10 years ago
|
void Run ();
|
||
![]()
8 years ago
|
std::string GetProto (std::shared_ptr<i2p::data::RouterInfo::Address> address);
|
||
![]()
10 years ago
|
|
||
![]()
8 years ago
|
private:
|
||
|
|
||
|
bool m_IsRunning;
|
||
|
std::unique_ptr<std::thread> m_Thread;
|
||
![]()
8 years ago
|
std::condition_variable m_Started;
|
||
|
std::mutex m_StartedMutex;
|
||
![]()
8 years ago
|
boost::asio::io_service m_Service;
|
||
![]()
8 years ago
|
boost::asio::deadline_timer m_Timer;
|
||
![]()
10 years ago
|
struct UPNPUrls m_upnpUrls;
|
||
|
struct IGDdatas m_upnpData;
|
||
|
|
||
|
// For miniupnpc
|
||
|
char * m_MulticastIf = 0;
|
||
|
char * m_Minissdpdpath = 0;
|
||
|
struct UPNPDev * m_Devlist = 0;
|
||
|
char m_NetworkAddr[64];
|
||
|
char m_externalIPAddress[40];
|
||
|
};
|
||
![]()
11 years ago
|
}
|
||
![]()
10 years ago
|
}
|
||
|
|
||
![]()
8 years ago
|
#else // USE_UPNP
|
||
|
namespace i2p {
|
||
|
namespace transport {
|
||
|
/* class stub */
|
||
|
class UPnP {
|
||
|
public:
|
||
|
UPnP () {};
|
||
|
~UPnP () {};
|
||
|
void Start () { LogPrint(eLogWarning, "UPnP: this module was disabled at compile-time"); }
|
||
|
void Stop () {};
|
||
|
};
|
||
|
}
|
||
|
}
|
||
![]()
9 years ago
|
#endif // USE_UPNP
|
||
|
#endif // __UPNP_H__
|