OSDN Git Service

VP24マージ VP24
authoreru <eru01@users.sourceforge.jp>
Wed, 19 Dec 2007 04:22:32 +0000 (04:22 +0000)
committereru <eru01@users.sourceforge.jp>
Wed, 19 Dec 2007 04:22:32 +0000 (04:22 +0000)
16 files changed:
PeerCast.root/PeerCast/core/common/pcp.cpp
PeerCast.root/PeerCast/core/common/servent.cpp
PeerCast.root/PeerCast/core/common/servent.h
PeerCast.root/PeerCast/core/common/servhs.cpp
PeerCast.root/PeerCast/core/common/servmgr.cpp
PeerCast.root/PeerCast/core/common/sys.h
PeerCast.root/PeerCast/core/common/version2.h
PeerCast.root/PeerCast/core/win32/wsocket.cpp
c:/Git/PeerCast.root/PeerCast/core/common/pcp.cpp
c:/Git/PeerCast.root/PeerCast/core/common/servent.cpp
c:/Git/PeerCast.root/PeerCast/core/common/servent.h
c:/Git/PeerCast.root/PeerCast/core/common/servhs.cpp
c:/Git/PeerCast.root/PeerCast/core/common/servmgr.cpp
c:/Git/PeerCast.root/PeerCast/core/common/sys.h
c:/Git/PeerCast.root/PeerCast/core/common/version2.h
c:/Git/PeerCast.root/PeerCast/core/win32/wsocket.cpp

index 37514ed..fdf5d8b 100644 (file)
@@ -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;
index 1ce8a26..bb12277 100644 (file)
@@ -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;
index b1c2241..e257e82 100644 (file)
@@ -254,8 +254,8 @@ public:
        ThreadInfo      thread;
 
 
-       char    loginPassword[64];
-       char    loginMount[64];
+       String  loginPassword;
+       String  loginMount;
 
        bool    priorityConnect;
        bool    addMetadata;
index 8e352bf..aa7cc55 100644 (file)
@@ -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);
 
index 7f72944..05ca133 100644 (file)
@@ -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")
index 5583a9d..3cb5696 100644 (file)
@@ -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;}
 
index 24a45ce..95c5150 100644 (file)
@@ -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
 
 // ------------------------------------------------
index 5b03e4c..372f1c5 100644 (file)
@@ -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 |
index 37514ed..fdf5d8b 100644 (file)
@@ -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;
index 1ce8a26..bb12277 100644 (file)
@@ -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;
index b1c2241..e257e82 100644 (file)
@@ -254,8 +254,8 @@ public:
        ThreadInfo      thread;
 
 
-       char    loginPassword[64];
-       char    loginMount[64];
+       String  loginPassword;
+       String  loginMount;
 
        bool    priorityConnect;
        bool    addMetadata;
index 8e352bf..aa7cc55 100644 (file)
@@ -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);
 
index 7f72944..05ca133 100644 (file)
@@ -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")
index 5583a9d..3cb5696 100644 (file)
@@ -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;}
 
index 24a45ce..95c5150 100644 (file)
@@ -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
 
 // ------------------------------------------------
index 5b03e4c..372f1c5 100644 (file)
@@ -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 |