forked from Mirrors/openclonk
Kill netpuncher
Another piece of code that hasn't been tested in ages, gone. The default puncher address was still pointing to clonk.de, which I'm very certain isn't providing UDP hole punching services anymore. Instead of a bespoke hole punching implementation we should use a STUN lib.shapetextures
parent
9727a5d25d
commit
72002cc366
|
@ -5,7 +5,6 @@ autom4te.cache
|
|||
deps
|
||||
*.o
|
||||
/openclonk
|
||||
/netpuncher
|
||||
/c4group
|
||||
/c4script
|
||||
.dirstamp
|
||||
|
|
|
@ -956,10 +956,6 @@ add_executable(c4group
|
|||
src/c4group/C4GroupMain.cpp
|
||||
)
|
||||
|
||||
add_executable(netpuncher EXCLUDE_FROM_ALL
|
||||
src/netpuncher/main.cpp
|
||||
)
|
||||
|
||||
add_library(libmisc
|
||||
src/c4group/C4Group.cpp
|
||||
src/c4group/C4Group.h
|
||||
|
@ -1074,10 +1070,6 @@ if(TARGET mape)
|
|||
)
|
||||
endif()
|
||||
|
||||
target_link_libraries(netpuncher
|
||||
libmisc
|
||||
)
|
||||
|
||||
target_link_libraries(c4group
|
||||
libmisc
|
||||
)
|
||||
|
@ -1143,7 +1135,6 @@ if(MSVC)
|
|||
oc_set_target_names(openclonk)
|
||||
oc_set_target_names(c4group)
|
||||
oc_set_target_names(c4script)
|
||||
oc_set_target_names(netpuncher)
|
||||
|
||||
# cmake does not support embedding arbitrary manifests,
|
||||
# so we add it to the resource file ourselves and tell
|
||||
|
@ -1337,7 +1328,6 @@ if (WIN32)
|
|||
|
||||
target_link_libraries(openclonk ws2_32 winmm)
|
||||
target_link_libraries(c4group ws2_32)
|
||||
target_link_libraries(netpuncher ws2_32 winmm)
|
||||
target_link_libraries(c4script ws2_32 winmm)
|
||||
if(TARGET mape)
|
||||
target_link_libraries(mape winmm)
|
||||
|
|
|
@ -166,7 +166,6 @@ void C4ConfigNetwork::CompileFunc(StdCompiler *pComp)
|
|||
pComp->Value(mkNamingAdapt(PacketLogging, "PacketLogging", 0 ));
|
||||
|
||||
|
||||
pComp->Value(mkNamingAdapt(s(PuncherAddress), "PuncherAddress", "clonk.de:11115")); // maybe store default for this one?
|
||||
pComp->Value(mkNamingAdapt(mkParAdapt(LastLeagueServer, StdCompiler::RCT_All), "LastLeagueServer", "" ));
|
||||
pComp->Value(mkNamingAdapt(mkParAdapt(LastLeaguePlayerName, StdCompiler::RCT_All), "LastLeaguePlayerName", "" ));
|
||||
pComp->Value(mkNamingAdapt(mkParAdapt(LastLeagueAccount, StdCompiler::RCT_All), "LastLeagueAccount", "" ));
|
||||
|
|
|
@ -160,7 +160,6 @@ public:
|
|||
int32_t MaxLoadFileSize;
|
||||
char LastPassword[CFG_MaxString+1];
|
||||
char AlternateServerAddress[CFG_MaxString+1];
|
||||
char PuncherAddress[CFG_MaxString+1];
|
||||
StdCopyStrBuf LastLeagueServer, LastLeaguePlayerName, LastLeagueAccount, LastLeagueLoginToken;
|
||||
#ifdef WITH_AUTOMATIC_UPDATE
|
||||
char UpdateServerAddress[CFG_MaxString+1];
|
||||
|
|
|
@ -1,70 +0,0 @@
|
|||
/*
|
||||
* OpenClonk, http://www.openclonk.org
|
||||
*
|
||||
* Copyright (c) 2001-2009, RedWolf Design GmbH, http://www.clonk.de/
|
||||
* Copyright (c) 2010-2013, The OpenClonk Team and contributors
|
||||
*
|
||||
* Distributed under the terms of the ISC license; see accompanying file
|
||||
* "COPYING" for details.
|
||||
*
|
||||
* "Clonk" is a registered trademark of Matthes Bender, used with permission.
|
||||
* See accompanying file "TRADEMARK" for details.
|
||||
*
|
||||
* To redistribute this file separately, substitute the full license texts
|
||||
* for the above references.
|
||||
*/
|
||||
|
||||
#include <C4Include.h>
|
||||
#include "C4NetIO.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
const uint16_t C4PuncherPort = 11115;
|
||||
|
||||
extern bool fQuiet;
|
||||
|
||||
class C4PuncherServer : public C4NetIOUDP, private C4NetIO::CBClass
|
||||
{
|
||||
public:
|
||||
C4PuncherServer() { C4NetIOUDP::SetCallback(this); }
|
||||
private:
|
||||
// Event handlers
|
||||
virtual bool OnConn(const addr_t &AddrPeer, const addr_t &AddrConnect, const addr_t *OwnAddr, C4NetIO *pNetIO)
|
||||
{
|
||||
printf("Punched back at %s:%d...\n", inet_ntoa(AddrPeer.sin_addr), htons(AddrPeer.sin_port));
|
||||
return false;
|
||||
}
|
||||
virtual void OnPacket(const class C4NetIOPacket &rPacket, C4NetIO *pNetIO)
|
||||
{
|
||||
// Unused
|
||||
}
|
||||
} Puncher;
|
||||
|
||||
int main(int argc, char * argv[])
|
||||
{
|
||||
// Log
|
||||
printf("Starting puncher...\n");
|
||||
|
||||
// Get port
|
||||
uint16_t iPort = C4PuncherPort;
|
||||
if (argc)
|
||||
{
|
||||
iPort = atoi(*argv);
|
||||
if (!iPort) iPort = C4PuncherPort;
|
||||
}
|
||||
|
||||
// Initialize
|
||||
if (!Puncher.Init(iPort))
|
||||
{
|
||||
fprintf(stderr, "Could not initialize puncher: %s", Puncher.GetError());
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Log
|
||||
printf("Listening on port %d...\n", iPort);
|
||||
|
||||
// Execute forever
|
||||
Puncher.ExecuteUntil(-1);
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -1976,11 +1976,6 @@ bool C4Network2::LeagueStart(bool *pCancel)
|
|||
return false;
|
||||
}
|
||||
|
||||
// We have an internet connection, so let's punch the master server here in order to open an udp port
|
||||
C4NetIO::addr_t PuncherAddr;
|
||||
if (ResolveAddress(Config.Network.PuncherAddress, &PuncherAddr, C4NetStdPortPuncher))
|
||||
NetIO.Punch(PuncherAddr);
|
||||
|
||||
// Let's wait for response
|
||||
StdStrBuf Message = FormatString(LoadResStr("IDS_NET_LEAGUE_REGGAME"), pLeagueClient->getServerName());
|
||||
Log(Message.getData());
|
||||
|
|
|
@ -30,7 +30,6 @@ const int16_t C4NetStdPortTCP = 11112,
|
|||
C4NetStdPortUDP = 11113,
|
||||
C4NetStdPortDiscovery = 11114,
|
||||
C4NetStdPortRefServer = 11111,
|
||||
C4NetStdPortPuncher = 11115,
|
||||
C4NetStdPortHTTP = 80;
|
||||
|
||||
// resource retrieve wait timeout
|
||||
|
|
|
@ -56,7 +56,6 @@ C4Network2IO::C4Network2IO()
|
|||
iTCPIRate(0), iTCPORate(0), iTCPBCRate(0),
|
||||
iUDPIRate(0), iUDPORate(0), iUDPBCRate(0)
|
||||
{
|
||||
ZeroMem(&PuncherAddr, sizeof(PuncherAddr));
|
||||
}
|
||||
|
||||
C4Network2IO::~C4Network2IO()
|
||||
|
@ -455,30 +454,9 @@ bool C4Network2IO::BroadcastMsg(const C4NetIOPacket &rPkt) // by both
|
|||
return fSuccess;
|
||||
}
|
||||
|
||||
bool C4Network2IO::Punch(C4NetIO::addr_t nPuncherAddr)
|
||||
{
|
||||
// UDP must be initialized
|
||||
if (!pNetIO_UDP)
|
||||
return false;
|
||||
// save address
|
||||
PuncherAddr = nPuncherAddr;
|
||||
// let's punch
|
||||
return pNetIO_UDP->Connect(PuncherAddr);
|
||||
}
|
||||
|
||||
// C4NetIO interface
|
||||
bool C4Network2IO::OnConn(const C4NetIO::addr_t &PeerAddr, const C4NetIO::addr_t &ConnectAddr, const C4NetIO::addr_t *pOwnAddr, C4NetIO *pNetIO)
|
||||
{
|
||||
// puncher answer? We just make sure here a connection /can/ be established, so close it instantly.
|
||||
if (pNetIO == pNetIO_UDP)
|
||||
if (PuncherAddr.sin_addr.s_addr && AddrEqual(PuncherAddr, ConnectAddr))
|
||||
{
|
||||
// got an address?
|
||||
if (pOwnAddr)
|
||||
OnPunch(*pOwnAddr);
|
||||
// this is only a test connection - close it instantly
|
||||
return false;
|
||||
}
|
||||
#if(C4NET2IO_DUMP_LEVEL > 1)
|
||||
Application.InteractiveThread.ThreadLogS("OnConn: %s %s",
|
||||
C4TimeMilliseconds::Now().AsString().getData(),
|
||||
|
@ -526,13 +504,6 @@ bool C4Network2IO::OnConn(const C4NetIO::addr_t &PeerAddr, const C4NetIO::addr_t
|
|||
|
||||
void C4Network2IO::OnDisconn(const C4NetIO::addr_t &addr, C4NetIO *pNetIO, const char *szReason)
|
||||
{
|
||||
// punch?
|
||||
if (pNetIO == pNetIO_UDP)
|
||||
if (PuncherAddr.sin_addr.s_addr && AddrEqual(PuncherAddr, addr))
|
||||
{
|
||||
ZeroMem(&PuncherAddr, sizeof(PuncherAddr));
|
||||
return;
|
||||
}
|
||||
#if(C4NET2IO_DUMP_LEVEL > 1)
|
||||
Application.InteractiveThread.ThreadLogS("OnDisconn: %s %s",
|
||||
C4TimeMilliseconds::Now().AsString().getData(),
|
||||
|
@ -1237,20 +1208,6 @@ void C4Network2IO::SendConnPackets()
|
|||
|
||||
}
|
||||
|
||||
void C4Network2IO::OnPunch(C4NetIO::addr_t addr)
|
||||
{
|
||||
// Sanity check
|
||||
assert (addr.sin_family == AF_INET);
|
||||
if (addr.sin_family != AF_INET)
|
||||
return;
|
||||
ZeroMem(addr.sin_zero, sizeof(addr.sin_zero));
|
||||
// Add for local client
|
||||
C4Network2Client *pLocal = ::Network.Clients.GetLocal();
|
||||
if (pLocal)
|
||||
if (pLocal->AddAddr(C4Network2Address(addr, P_UDP), true))
|
||||
::Network.InvalidateReference();
|
||||
}
|
||||
|
||||
// *** C4Network2IOConnection
|
||||
|
||||
C4Network2IOConnection::C4Network2IOConnection()
|
||||
|
|
|
@ -95,9 +95,6 @@ protected:
|
|||
int iTCPIRate, iTCPORate, iTCPBCRate,
|
||||
iUDPIRate, iUDPORate, iUDPBCRate;
|
||||
|
||||
// punching
|
||||
C4NetIO::addr_t PuncherAddr;
|
||||
|
||||
public:
|
||||
|
||||
bool hasTCP() const { return !! pNetIO_TCP; }
|
||||
|
@ -134,9 +131,6 @@ public:
|
|||
bool SendMsgToClient(C4NetIOPacket &rPkt, int iClient); // by both
|
||||
bool BroadcastMsg(const C4NetIOPacket &rPkt); // by both
|
||||
|
||||
// punch
|
||||
bool Punch(C4NetIO::addr_t PuncherAddr); // by main thread
|
||||
|
||||
// stuff
|
||||
C4NetIO *getNetIO(C4Network2IOProtocol eProt); // by both
|
||||
const char *getNetIOName(C4NetIO *pNetIO);
|
||||
|
@ -192,9 +186,6 @@ protected:
|
|||
void GenerateStatistics(int iInterval);
|
||||
void SendConnPackets();
|
||||
|
||||
// puncher
|
||||
void OnPunch(C4NetIO::addr_t addr);
|
||||
|
||||
};
|
||||
|
||||
enum C4Network2IOConnStatus
|
||||
|
|
Loading…
Reference in New Issue