error = PCPStream::procAtom(patom,id,numc,numd,bcs);
if (error)
+ {
throw StreamException("PCP exception");
+ }
}
error = 0;
nsSwitchNum = 0;
pack.func = 255;
lastConnect = lastPing = lastPacket = 0;
- loginPassword[0] = 0;
- loginMount[0] = 0;
+ loginPassword.clear();
+ loginMount.clear();
bytesPerSecond = 0;
priorityConnect = false;
pushSock = NULL;
ThreadInfo thread;
- char loginPassword[64];
- char loginMount[64];
+ String loginPassword;
+ String loginMount;
bool priorityConnect;
bool addMetadata;
mount[-1] = 0; // password preceeds
break;
}
- strcpy(loginPassword,in+7);
+ loginPassword.set(in+7);
- LOG_DEBUG("ICY client: %s %s",loginPassword,mount?mount:"unknown");
+ LOG_DEBUG("ICY client: %s %s",loginPassword.cstr(),mount?mount:"unknown");
}
if (mount)
- strcpy(loginMount,mount);
+ loginMount.set(mount);
handshakeICY(Channel::SRC_ICECAST,isHTTP);
sock = NULL; // socket is taken over by channel, so don`t close it
if (!isAllowed(ALLOW_BROADCAST))
throw HTTPException(HTTP_SC_UNAVAILABLE,503);
- strcpy(loginPassword,servMgr->password); // pwd already checked
+ loginPassword.set(servMgr->password); // pwd already checked
sock->writeLine("OK2");
sock->writeLine("icy-caps:11");
while (http.nextHeader())
{
LOG_DEBUG("ICY %s",http.cmdLine);
- readICYHeader(http,info,loginPassword);
+ readICYHeader(http,info,loginPassword.cstr());
}
// check password before anything else, if needed
- if (strcmp(servMgr->password,loginPassword)!=0)
+ if (servMgr->password != loginPassword)
{
- if (!sock->host.isLocalhost() || strlen(loginPassword))
+ if (!sock->host.isLocalhost() || !loginPassword.isEmpty())
throw HTTPException(HTTP_SC_UNAUTHORIZED,401);
}
info.id = chanMgr->broadcastID;
- info.id.encode(NULL,info.name.cstr(),loginMount,info.bitrate);
+ info.id.encode(NULL,info.name.cstr(),loginMount.cstr(),info.bitrate);
LOG_DEBUG("Incoming source: %s : %s",info.name.cstr(),ChanInfo::getTypeStr(info.contentType));
info.comment = chanMgr->broadcastMsg;
info.bcID = chanMgr->broadcastID;
- c = chanMgr->createChannel(info,loginMount);
+ c = chanMgr->createChannel(info,loginMount.cstr());
if (!c)
throw HTTPException(HTTP_SC_UNAVAILABLE,503);
sprintf(buf,"%d",maxBitrateOut);
else if (var == "maxControlsIn")
sprintf(buf,"%d",maxControl);
+ else if (var == "maxServIn")
+ sprintf(buf,"%d",maxServIn);
else if (var == "numFilters")
sprintf(buf,"%d",numFilters+1);
else if (var == "maxPGNUIn")
}
bool operator == (const char *s) const {return isSame(s);}
+ bool operator != (const char *s) const {return !isSame(s);}
operator const char *() const {return data;}
static bool PCP_FORCE_YP = false;
#endif
// ------------------------------------------------
-static const int PCP_CLIENT_VERSION = 1217;
-static const int PCP_CLIENT_VERSION_VP = 23;
-static const int PCP_ROOT_VERSION = 1212;
+static const int PCP_CLIENT_VERSION = 1218;
+static const int PCP_CLIENT_VERSION_VP = 24;
+static const int PCP_ROOT_VERSION = 1218;
static const int PCP_CLIENT_MINVERSION = 1200;
-static const char *PCX_AGENT = "PeerCast/0.1217";
-static const char *PCX_AGENTJP = "PeerCast/0.1217-J";
-static const char *PCX_AGENTVP = "PeerCast/0.1217(VP0023)";
-static const char *PCX_VERSTRING = "v0.1217(VP0023)";
+static const char *PCX_AGENT = "PeerCast/0.1218";
+static const char *PCX_AGENTJP = "PeerCast/0.1218-J";
+static const char *PCX_AGENTVP = "PeerCast/0.1218(VP0024)";
+static const char *PCX_VERSTRING = "v0.1218(VP0024)";
#if 1 /* for VP extend version */
#define VERSION_EX 1
static const char *PCP_CLIENT_VERSION_EX_PREFIX = "IM"; // 2bytes only
static const int PCP_CLIENT_VERSION_EX_NUMBER = 7651;
-static const char *PCX_AGENTEX = "PeerCast/0.1217(IM7651)";
-static const char *PCX_VERSTRING_EX = "v0.1217(IM7651)";
+static const char *PCX_AGENTEX = "PeerCast/0.1218(IM7651)";
+static const char *PCX_VERSTRING_EX = "v0.1218(IM7651)";
#endif
// ------------------------------------------------
WSAClientSocket *cs = new WSAClientSocket();
cs->sockNum = conSock;
- cs->host.port = from.sin_port;
+ cs->host.port = (from.sin_port & 0xff) << 8 | ((from.sin_port >> 8) & 0xff);
cs->host.ip = from.sin_addr.S_un.S_un_b.s_b1<<24 |
from.sin_addr.S_un.S_un_b.s_b2<<16 |
from.sin_addr.S_un.S_un_b.s_b3<<8 |
error = PCPStream::procAtom(patom,id,numc,numd,bcs);
if (error)
+ {
throw StreamException("PCP exception");
+ }
}
error = 0;
nsSwitchNum = 0;
pack.func = 255;
lastConnect = lastPing = lastPacket = 0;
- loginPassword[0] = 0;
- loginMount[0] = 0;
+ loginPassword.clear();
+ loginMount.clear();
bytesPerSecond = 0;
priorityConnect = false;
pushSock = NULL;
ThreadInfo thread;
- char loginPassword[64];
- char loginMount[64];
+ String loginPassword;
+ String loginMount;
bool priorityConnect;
bool addMetadata;
mount[-1] = 0; // password preceeds
break;
}
- strcpy(loginPassword,in+7);
+ loginPassword.set(in+7);
- LOG_DEBUG("ICY client: %s %s",loginPassword,mount?mount:"unknown");
+ LOG_DEBUG("ICY client: %s %s",loginPassword.cstr(),mount?mount:"unknown");
}
if (mount)
- strcpy(loginMount,mount);
+ loginMount.set(mount);
handshakeICY(Channel::SRC_ICECAST,isHTTP);
sock = NULL; // socket is taken over by channel, so don`t close it
if (!isAllowed(ALLOW_BROADCAST))
throw HTTPException(HTTP_SC_UNAVAILABLE,503);
- strcpy(loginPassword,servMgr->password); // pwd already checked
+ loginPassword.set(servMgr->password); // pwd already checked
sock->writeLine("OK2");
sock->writeLine("icy-caps:11");
while (http.nextHeader())
{
LOG_DEBUG("ICY %s",http.cmdLine);
- readICYHeader(http,info,loginPassword);
+ readICYHeader(http,info,loginPassword.cstr());
}
// check password before anything else, if needed
- if (strcmp(servMgr->password,loginPassword)!=0)
+ if (servMgr->password != loginPassword)
{
- if (!sock->host.isLocalhost() || strlen(loginPassword))
+ if (!sock->host.isLocalhost() || !loginPassword.isEmpty())
throw HTTPException(HTTP_SC_UNAUTHORIZED,401);
}
info.id = chanMgr->broadcastID;
- info.id.encode(NULL,info.name.cstr(),loginMount,info.bitrate);
+ info.id.encode(NULL,info.name.cstr(),loginMount.cstr(),info.bitrate);
LOG_DEBUG("Incoming source: %s : %s",info.name.cstr(),ChanInfo::getTypeStr(info.contentType));
info.comment = chanMgr->broadcastMsg;
info.bcID = chanMgr->broadcastID;
- c = chanMgr->createChannel(info,loginMount);
+ c = chanMgr->createChannel(info,loginMount.cstr());
if (!c)
throw HTTPException(HTTP_SC_UNAVAILABLE,503);
sprintf(buf,"%d",maxBitrateOut);
else if (var == "maxControlsIn")
sprintf(buf,"%d",maxControl);
+ else if (var == "maxServIn")
+ sprintf(buf,"%d",maxServIn);
else if (var == "numFilters")
sprintf(buf,"%d",numFilters+1);
else if (var == "maxPGNUIn")
}
bool operator == (const char *s) const {return isSame(s);}
+ bool operator != (const char *s) const {return !isSame(s);}
operator const char *() const {return data;}
static bool PCP_FORCE_YP = false;
#endif
// ------------------------------------------------
-static const int PCP_CLIENT_VERSION = 1217;
-static const int PCP_CLIENT_VERSION_VP = 23;
-static const int PCP_ROOT_VERSION = 1212;
+static const int PCP_CLIENT_VERSION = 1218;
+static const int PCP_CLIENT_VERSION_VP = 24;
+static const int PCP_ROOT_VERSION = 1218;
static const int PCP_CLIENT_MINVERSION = 1200;
-static const char *PCX_AGENT = "PeerCast/0.1217";
-static const char *PCX_AGENTJP = "PeerCast/0.1217-J";
-static const char *PCX_AGENTVP = "PeerCast/0.1217(VP0023)";
-static const char *PCX_VERSTRING = "v0.1217(VP0023)";
+static const char *PCX_AGENT = "PeerCast/0.1218";
+static const char *PCX_AGENTJP = "PeerCast/0.1218-J";
+static const char *PCX_AGENTVP = "PeerCast/0.1218(VP0024)";
+static const char *PCX_VERSTRING = "v0.1218(VP0024)";
#if 1 /* for VP extend version */
#define VERSION_EX 1
static const char *PCP_CLIENT_VERSION_EX_PREFIX = "IM"; // 2bytes only
static const int PCP_CLIENT_VERSION_EX_NUMBER = 7651;
-static const char *PCX_AGENTEX = "PeerCast/0.1217(IM7651)";
-static const char *PCX_VERSTRING_EX = "v0.1217(IM7651)";
+static const char *PCX_AGENTEX = "PeerCast/0.1218(IM7651)";
+static const char *PCX_VERSTRING_EX = "v0.1218(IM7651)";
#endif
// ------------------------------------------------
WSAClientSocket *cs = new WSAClientSocket();
cs->sockNum = conSock;
- cs->host.port = from.sin_port;
+ cs->host.port = (from.sin_port & 0xff) << 8 | ((from.sin_port >> 8) & 0xff);
cs->host.ip = from.sin_addr.S_un.S_un_b.s_b1<<24 |
from.sin_addr.S_un.S_un_b.s_b2<<16 |
from.sin_addr.S_un.S_un_b.s_b3<<8 |