#define new DEBUG_NEW
#endif
+#include "win32/seh.h"
+
const int DIRECT_WRITE_TIMEOUT = 60;
}
chanID = chanInfo.id;
- serventHit.rhost[0].ip = getHost().ip;
- serventHit.rhost[0].port = listenPort;
- serventHit.host = serventHit.rhost[0];
+ serventHit.host.ip = getHost().ip;
+ serventHit.host.port = listenPort;
+ if (serventHit.host.globalIP())
+ serventHit.rhost[0] = serventHit.host;
+ else
+ serventHit.rhost[1] = serventHit.host;
serventHit.chanID = chanID;
canStreamLock.on();
chanReady = canStream(ch);
- if (/*0 && */!chanReady)
+ if (0 && !chanReady && ch->isPlaying())
{
- if (servMgr->numStreams(chanID, Servent::T_RELAY, false) == 0)
+ if (ch->info.getUptime() > 60
+ && servMgr->numStreams(chanID, Servent::T_RELAY, false) == 0)
{
sourceHit = &ch->sourceHost; // send source host info
- if (listenPort && ch->info.getUptime() > 60) // if stable
+ if (listenPort)
{
// connect "this" host later
chanMgr->addHit(serventHit);
int error = PCP_ERROR_QUIT+PCP_ERROR_UNAVAILABLE;
+ if (sourceHit) {
+ sourceHit->writeAtoms(atom2,chanInfo.id);
+ char tmp[50];
+ sourceHit->host.toStr(tmp);
+ LOG_DEBUG("relay info(sourceHit): %s", tmp);
+ }
+
chanMgr->hitlistlock.on();
chl = chanMgr->findHitList(chanInfo);
- if (chl)
+ if (chl && !sourceHit)
{
ChanHit best;
cnt++;
}
- if (sourceHit) {
- char tmp[50];
- sourceHit->writeAtoms(atom2, chanInfo.id);
- sourceHit->host.toStr(tmp);
- LOG_DEBUG("relay info(sourceHit): %s", tmp);
- best.host.ip = sourceHit->host.ip;
- }
-
if (!best.host.ip){
char tmp[50];
// chanMgr->hitlistlock.on();
- int cnt = chs.getRelayHost(servMgr->serverHost, rhost, remoteID, chl);
+ int rhcnt = chs.getRelayHost(servMgr->serverHost, rhost, remoteID, chl);
// chanMgr->hitlistlock.off();
- for (int i = 0; i < cnt; i++){
+ for (int i = 0; i < rhcnt; i++){
chs.best[i].writeAtoms(atom2, chanInfo.id);
chs.best[i].host.toStr(tmp);
LOG_DEBUG("relay info: %s hops = %d", tmp, chs.best[i].numHops);
best.host.ip = chs.best[i].host.ip;
}
+ cnt += rhcnt;
}
if (cnt)
{
handshakeIncomingPCP(atom,rhost,remoteID,agent);
atom.writeInt(PCP_OK,0);
+ if (rhost.globalIP())
+ serventHit.rhost[0] = rhost;
+ else
+ serventHit.rhost[1] = rhost;
+ serventHit.sessionID = remoteID;
+ serventHit.numHops = 1;
+ chanMgr->addHit(serventHit);
}
}
}
// -----------------------------------
-int Servent::givProc(ThreadInfo *thread)
+int Servent::givProcMain(ThreadInfo *thread)
{
// thread->lock();
Servent *sv = (Servent*)thread->data;
}
// -----------------------------------
+int Servent::givProc(ThreadInfo *thread)
+{
+ SEH_THREAD(givProcMain, Servent::givProc);
+}
+
+// -----------------------------------
void Servent::handshakeOutgoingPCP(AtomStream &atom, Host &rhost, GnuID &rid, String &agent, bool isTrusted)
{
}
// -----------------------------------
-int Servent::outgoingProc(ThreadInfo *thread)
+int Servent::outgoingProcMain(ThreadInfo *thread)
{
// thread->lock();
LOG_DEBUG("COUT started");
return 0;
}
// -----------------------------------
-int Servent::incomingProc(ThreadInfo *thread)
+int Servent::outgoingProc(ThreadInfo *thread)
+{
+ SEH_THREAD(outgoingProcMain, Servent::outgoingProc);
+}
+// -----------------------------------
+int Servent::incomingProcMain(ThreadInfo *thread)
{
// thread->lock();
return 0;
}
// -----------------------------------
+int Servent::incomingProc(ThreadInfo *thread)
+{
+ SEH_THREAD(incomingProcMain, Servent::incomingProc);
+}
+// -----------------------------------
void Servent::processServent()
{
setStatus(S_HANDSHAKE);
}
// -----------------------------------
-int Servent::serverProc(ThreadInfo *thread)
+int Servent::serverProcMain(ThreadInfo *thread)
{
// thread->lock();
if (servMgr->numActiveOnPort(sv->sock->host.port) < servMgr->maxServIn)
{
ClientSocket *cs = sv->sock->accept();
+
+ // \95s\90³\82È\83\\81[\83X\83A\83h\83\8c\83X(IPv4\83}\83\8b\83`\83L\83\83\83X\83g)\82ð\8f\9c\8aO
+ if (cs && (((cs->host.ip >> 24) & 0xF0) == 0xE0))
+ {
+ char ip[64];
+ cs->host.toStr(ip);
+ cs->close();
+ LOG_ERROR("reject incoming multicast address: %s", ip);
+ peercastApp->notifyMessage(ServMgr::NT_PEERCAST, "reject multicast address");
+ } else
if (cs)
{
LOG_DEBUG("accepted incoming");
sys->endThread(thread);
return 0;
}
+
+// -----------------------------------
+int Servent::serverProc(ThreadInfo *thread)
+{
+ SEH_THREAD(serverProcMain, Servent::serverProc);
+}
// -----------------------------------
bool Servent::writeVariable(Stream &s, const String &var)
}
strcat(buf,h_ip);
char h_name[128];
- if (ClientSocket::getHostname(h_name,h.ip))
+ if (ClientSocket::getHostname(h_name,sizeof(h_name),h.ip)) //JP-MOD(BOF\91Î\8dô)
{
strcat(buf,"[");
strcat(buf,h_name);