From 85d213f7c11b6f55cead77b739a0d3e45b6288b5 Mon Sep 17 00:00:00 2001 From: eru Date: Wed, 19 Dec 2007 04:22:32 +0000 Subject: [PATCH] =?utf8?q?VP24=E3=83=9E=E3=83=BC=E3=82=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- PeerCast.root/PeerCast/core/common/pcp.cpp | 2 ++ PeerCast.root/PeerCast/core/common/servent.cpp | 4 ++-- PeerCast.root/PeerCast/core/common/servent.h | 4 ++-- PeerCast.root/PeerCast/core/common/servhs.cpp | 18 +++++++++--------- PeerCast.root/PeerCast/core/common/servmgr.cpp | 2 ++ PeerCast.root/PeerCast/core/common/sys.h | 1 + PeerCast.root/PeerCast/core/common/version2.h | 18 +++++++++--------- PeerCast.root/PeerCast/core/win32/wsocket.cpp | 2 +- c:/Git/PeerCast.root/PeerCast/core/common/pcp.cpp | 2 ++ c:/Git/PeerCast.root/PeerCast/core/common/servent.cpp | 4 ++-- c:/Git/PeerCast.root/PeerCast/core/common/servent.h | 4 ++-- c:/Git/PeerCast.root/PeerCast/core/common/servhs.cpp | 18 +++++++++--------- c:/Git/PeerCast.root/PeerCast/core/common/servmgr.cpp | 2 ++ c:/Git/PeerCast.root/PeerCast/core/common/sys.h | 1 + c:/Git/PeerCast.root/PeerCast/core/common/version2.h | 18 +++++++++--------- c:/Git/PeerCast.root/PeerCast/core/win32/wsocket.cpp | 2 +- 16 files changed, 56 insertions(+), 46 deletions(-) diff --git a/PeerCast.root/PeerCast/core/common/pcp.cpp b/PeerCast.root/PeerCast/core/common/pcp.cpp index 37514ed..fdf5d8b 100644 --- a/PeerCast.root/PeerCast/core/common/pcp.cpp +++ b/PeerCast.root/PeerCast/core/common/pcp.cpp @@ -149,7 +149,9 @@ int PCPStream::readPacket(Stream &in,BroadcastState &bcs) error = PCPStream::procAtom(patom,id,numc,numd,bcs); if (error) + { throw StreamException("PCP exception"); + } } error = 0; diff --git a/PeerCast.root/PeerCast/core/common/servent.cpp b/PeerCast.root/PeerCast/core/common/servent.cpp index 1ce8a26..bb12277 100644 --- a/PeerCast.root/PeerCast/core/common/servent.cpp +++ b/PeerCast.root/PeerCast/core/common/servent.cpp @@ -230,8 +230,8 @@ void Servent::reset() 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; diff --git a/PeerCast.root/PeerCast/core/common/servent.h b/PeerCast.root/PeerCast/core/common/servent.h index b1c2241..e257e82 100644 --- a/PeerCast.root/PeerCast/core/common/servent.h +++ b/PeerCast.root/PeerCast/core/common/servent.h @@ -254,8 +254,8 @@ public: ThreadInfo thread; - char loginPassword[64]; - char loginMount[64]; + String loginPassword; + String loginMount; bool priorityConnect; bool addMetadata; diff --git a/PeerCast.root/PeerCast/core/common/servhs.cpp b/PeerCast.root/PeerCast/core/common/servhs.cpp index 8e352bf..aa7cc55 100644 --- a/PeerCast.root/PeerCast/core/common/servhs.cpp +++ b/PeerCast.root/PeerCast/core/common/servhs.cpp @@ -371,13 +371,13 @@ void Servent::handshakeHTTP(HTTP &http, bool isHTTP) 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 @@ -387,7 +387,7 @@ void Servent::handshakeHTTP(HTTP &http, bool isHTTP) 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"); @@ -1778,15 +1778,15 @@ void Servent::handshakeICY(Channel::SRC_TYPE type, bool isHTTP) 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); } @@ -1800,7 +1800,7 @@ void Servent::handshakeICY(Channel::SRC_TYPE type, bool isHTTP) 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)); @@ -1821,7 +1821,7 @@ void Servent::handshakeICY(Channel::SRC_TYPE type, bool isHTTP) 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); diff --git a/PeerCast.root/PeerCast/core/common/servmgr.cpp b/PeerCast.root/PeerCast/core/common/servmgr.cpp index 7f72944..05ca133 100644 --- a/PeerCast.root/PeerCast/core/common/servmgr.cpp +++ b/PeerCast.root/PeerCast/core/common/servmgr.cpp @@ -2354,6 +2354,8 @@ bool ServMgr::writeVariable(Stream &out, const String &var) 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") diff --git a/PeerCast.root/PeerCast/core/common/sys.h b/PeerCast.root/PeerCast/core/common/sys.h index 5583a9d..3cb5696 100644 --- a/PeerCast.root/PeerCast/core/common/sys.h +++ b/PeerCast.root/PeerCast/core/common/sys.h @@ -158,6 +158,7 @@ public: } bool operator == (const char *s) const {return isSame(s);} + bool operator != (const char *s) const {return !isSame(s);} operator const char *() const {return data;} diff --git a/PeerCast.root/PeerCast/core/common/version2.h b/PeerCast.root/PeerCast/core/common/version2.h index 24a45ce..95c5150 100644 --- a/PeerCast.root/PeerCast/core/common/version2.h +++ b/PeerCast.root/PeerCast/core/common/version2.h @@ -28,23 +28,23 @@ static const char PCP_BROADCAST_FLAGS = 0x00; 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 // ------------------------------------------------ diff --git a/PeerCast.root/PeerCast/core/win32/wsocket.cpp b/PeerCast.root/PeerCast/core/win32/wsocket.cpp index 5b03e4c..372f1c5 100644 --- a/PeerCast.root/PeerCast/core/win32/wsocket.cpp +++ b/PeerCast.root/PeerCast/core/win32/wsocket.cpp @@ -613,7 +613,7 @@ ClientSocket *WSAClientSocket::accept() 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 | diff --git a/c:/Git/PeerCast.root/PeerCast/core/common/pcp.cpp b/c:/Git/PeerCast.root/PeerCast/core/common/pcp.cpp index 37514ed..fdf5d8b 100644 --- a/c:/Git/PeerCast.root/PeerCast/core/common/pcp.cpp +++ b/c:/Git/PeerCast.root/PeerCast/core/common/pcp.cpp @@ -149,7 +149,9 @@ int PCPStream::readPacket(Stream &in,BroadcastState &bcs) error = PCPStream::procAtom(patom,id,numc,numd,bcs); if (error) + { throw StreamException("PCP exception"); + } } error = 0; diff --git a/c:/Git/PeerCast.root/PeerCast/core/common/servent.cpp b/c:/Git/PeerCast.root/PeerCast/core/common/servent.cpp index 1ce8a26..bb12277 100644 --- a/c:/Git/PeerCast.root/PeerCast/core/common/servent.cpp +++ b/c:/Git/PeerCast.root/PeerCast/core/common/servent.cpp @@ -230,8 +230,8 @@ void Servent::reset() 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; diff --git a/c:/Git/PeerCast.root/PeerCast/core/common/servent.h b/c:/Git/PeerCast.root/PeerCast/core/common/servent.h index b1c2241..e257e82 100644 --- a/c:/Git/PeerCast.root/PeerCast/core/common/servent.h +++ b/c:/Git/PeerCast.root/PeerCast/core/common/servent.h @@ -254,8 +254,8 @@ public: ThreadInfo thread; - char loginPassword[64]; - char loginMount[64]; + String loginPassword; + String loginMount; bool priorityConnect; bool addMetadata; diff --git a/c:/Git/PeerCast.root/PeerCast/core/common/servhs.cpp b/c:/Git/PeerCast.root/PeerCast/core/common/servhs.cpp index 8e352bf..aa7cc55 100644 --- a/c:/Git/PeerCast.root/PeerCast/core/common/servhs.cpp +++ b/c:/Git/PeerCast.root/PeerCast/core/common/servhs.cpp @@ -371,13 +371,13 @@ void Servent::handshakeHTTP(HTTP &http, bool isHTTP) 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 @@ -387,7 +387,7 @@ void Servent::handshakeHTTP(HTTP &http, bool isHTTP) 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"); @@ -1778,15 +1778,15 @@ void Servent::handshakeICY(Channel::SRC_TYPE type, bool isHTTP) 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); } @@ -1800,7 +1800,7 @@ void Servent::handshakeICY(Channel::SRC_TYPE type, bool isHTTP) 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)); @@ -1821,7 +1821,7 @@ void Servent::handshakeICY(Channel::SRC_TYPE type, bool isHTTP) 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); diff --git a/c:/Git/PeerCast.root/PeerCast/core/common/servmgr.cpp b/c:/Git/PeerCast.root/PeerCast/core/common/servmgr.cpp index 7f72944..05ca133 100644 --- a/c:/Git/PeerCast.root/PeerCast/core/common/servmgr.cpp +++ b/c:/Git/PeerCast.root/PeerCast/core/common/servmgr.cpp @@ -2354,6 +2354,8 @@ bool ServMgr::writeVariable(Stream &out, const String &var) 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") diff --git a/c:/Git/PeerCast.root/PeerCast/core/common/sys.h b/c:/Git/PeerCast.root/PeerCast/core/common/sys.h index 5583a9d..3cb5696 100644 --- a/c:/Git/PeerCast.root/PeerCast/core/common/sys.h +++ b/c:/Git/PeerCast.root/PeerCast/core/common/sys.h @@ -158,6 +158,7 @@ public: } bool operator == (const char *s) const {return isSame(s);} + bool operator != (const char *s) const {return !isSame(s);} operator const char *() const {return data;} diff --git a/c:/Git/PeerCast.root/PeerCast/core/common/version2.h b/c:/Git/PeerCast.root/PeerCast/core/common/version2.h index 24a45ce..95c5150 100644 --- a/c:/Git/PeerCast.root/PeerCast/core/common/version2.h +++ b/c:/Git/PeerCast.root/PeerCast/core/common/version2.h @@ -28,23 +28,23 @@ static const char PCP_BROADCAST_FLAGS = 0x00; 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 // ------------------------------------------------ diff --git a/c:/Git/PeerCast.root/PeerCast/core/win32/wsocket.cpp b/c:/Git/PeerCast.root/PeerCast/core/win32/wsocket.cpp index 5b03e4c..372f1c5 100644 --- a/c:/Git/PeerCast.root/PeerCast/core/win32/wsocket.cpp +++ b/c:/Git/PeerCast.root/PeerCast/core/win32/wsocket.cpp @@ -613,7 +613,7 @@ ClientSocket *WSAClientSocket::accept() 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 | -- 2.11.0