mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-06-06 20:43:44 +02:00
Some tap interface changes and integration into main.cpp for *nix systems.
This commit is contained in:
parent
8a804b5257
commit
92d9ad4a7f
4 changed files with 55 additions and 3 deletions
37
main.cpp
37
main.cpp
|
@ -56,6 +56,7 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "node/Constants.hpp"
|
#include "node/Constants.hpp"
|
||||||
|
|
||||||
#include "node/Defaults.hpp"
|
#include "node/Defaults.hpp"
|
||||||
#include "node/Utils.hpp"
|
#include "node/Utils.hpp"
|
||||||
#include "node/Node.hpp"
|
#include "node/Node.hpp"
|
||||||
|
@ -63,6 +64,33 @@
|
||||||
#include "node/Identity.hpp"
|
#include "node/Identity.hpp"
|
||||||
#include "node/Thread.hpp"
|
#include "node/Thread.hpp"
|
||||||
#include "node/CertificateOfMembership.hpp"
|
#include "node/CertificateOfMembership.hpp"
|
||||||
|
#include "node/EthernetTapFactory.hpp"
|
||||||
|
#include "node/RoutingTable.hpp"
|
||||||
|
|
||||||
|
#ifdef __WINDOWS__
|
||||||
|
#include "osnet/WindowsEthernetTapFactory.hpp"
|
||||||
|
#include "osnet/WindowsRoutingTable.hpp"
|
||||||
|
#define ZTCreatePlatformEthernetTapFactory (new WindowsEthernetTapFactory(homeDir))
|
||||||
|
#define ZTCreatePlatformRoutingTable (new WindowsRoutingTable())
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __LINUX__
|
||||||
|
#include "osnet/LinuxEthernetTapFactory.hpp"
|
||||||
|
#include "osnet/LinuxRoutingTable.hpp"
|
||||||
|
#define ZTCreatePlatformEthernetTapFactory (new LinuxEthernetTapFactory())
|
||||||
|
#define ZTCreatePlatformRoutingTable (new LinuxRoutingTable())
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __APPLE__
|
||||||
|
#include "osnet/OSXEthernetTapFactory.hpp"
|
||||||
|
#include "osnet/BSDRoutingTable.hpp"
|
||||||
|
#define ZTCreatePlatformEthernetTapFactory (new OSXEthernetTapFactory(homeDir,"tap.kext"))
|
||||||
|
#define ZTCreatePlatformRoutingTable (new BSDRoutingTable())
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef ZTCreatePlatformEthernetTapFactory
|
||||||
|
#error Sorry, this platform has no osnet/ implementation yet. Fork me on GitHub and add one?
|
||||||
|
#endif
|
||||||
|
|
||||||
using namespace ZeroTier;
|
using namespace ZeroTier;
|
||||||
|
|
||||||
|
@ -649,7 +677,7 @@ int main(int argc,char **argv)
|
||||||
fclose(pf);
|
fclose(pf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif // __UNIX_LIKE__
|
||||||
|
|
||||||
#ifdef __WINDOWS__
|
#ifdef __WINDOWS__
|
||||||
if (winRunFromCommandLine) {
|
if (winRunFromCommandLine) {
|
||||||
|
@ -670,12 +698,15 @@ int main(int argc,char **argv)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif // __WINDOWS__
|
||||||
|
|
||||||
int exitCode = 0;
|
int exitCode = 0;
|
||||||
bool needsReset = false;
|
bool needsReset = false;
|
||||||
try {
|
try {
|
||||||
node = new Node(homeDir,udpPort,tcpPort,needsReset);
|
EthernetTapFactory *tapFactory = ZTCreatePlatformEthernetTapFactory;
|
||||||
|
RoutingTable *routingTable = ZTCreatePlatformRoutingTable;
|
||||||
|
|
||||||
|
node = new Node(homeDir,tapFactory,routingTable,udpPort,tcpPort,needsReset);
|
||||||
switch(node->run()) {
|
switch(node->run()) {
|
||||||
#ifdef __WINDOWS__
|
#ifdef __WINDOWS__
|
||||||
case Node::NODE_RESTART_FOR_UPGRADE: {
|
case Node::NODE_RESTART_FOR_UPGRADE: {
|
||||||
|
|
|
@ -196,6 +196,21 @@ public:
|
||||||
*/
|
*/
|
||||||
virtual bool updateMulticastGroups(std::set<MulticastGroup> &groups) = 0;
|
virtual bool updateMulticastGroups(std::set<MulticastGroup> &groups) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Should this tap device get a pseudo-default-route?
|
||||||
|
*
|
||||||
|
* Some platforms (cough Windows) want all "real" network devices to have a
|
||||||
|
* routing table entry for default, even if it's got a high metric and is
|
||||||
|
* never used and goes nowhere. If this returns true, the underlying node
|
||||||
|
* code will use RoutingTable to create one if no default route is
|
||||||
|
* otherwise defined.
|
||||||
|
*
|
||||||
|
* Base class default returns false. Override to return true if needed.
|
||||||
|
*
|
||||||
|
* @return True if pseudo-default-route should always exist
|
||||||
|
*/
|
||||||
|
virtual bool createPseudoDefaultRoute() const { return false; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
const char *_implName;
|
const char *_implName;
|
||||||
MAC _mac;
|
MAC _mac;
|
||||||
|
|
|
@ -516,6 +516,11 @@ bool WindowsEthernetTap::updateMulticastGroups(std::set<MulticastGroup> &groups)
|
||||||
return changed;
|
return changed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool WindowsEthernetTap::createPseudoDefaultRoute() const
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
void WindowsEthernetTap::threadMain()
|
void WindowsEthernetTap::threadMain()
|
||||||
throw()
|
throw()
|
||||||
{
|
{
|
||||||
|
|
|
@ -71,6 +71,7 @@ public:
|
||||||
virtual std::string deviceName() const;
|
virtual std::string deviceName() const;
|
||||||
virtual void setFriendlyName(const char *friendlyName);
|
virtual void setFriendlyName(const char *friendlyName);
|
||||||
virtual bool updateMulticastGroups(std::set<MulticastGroup> &groups);
|
virtual bool updateMulticastGroups(std::set<MulticastGroup> &groups);
|
||||||
|
virtual bool createPseudoDefaultRoute() const;
|
||||||
|
|
||||||
inline const NET_LUID &luid() const { return _deviceLuid; }
|
inline const NET_LUID &luid() const { return _deviceLuid; }
|
||||||
inline const GUID &guid() const { return _deviceGuid; }
|
inline const GUID &guid() const { return _deviceGuid; }
|
||||||
|
|
Loading…
Add table
Reference in a new issue