winlin

fix the forward loop detect bug. change to 0.9.34

@@ -97,17 +97,27 @@ int SrsForwarder::on_publish(SrsRequest* req, std::string forward_server) @@ -97,17 +97,27 @@ int SrsForwarder::on_publish(SrsRequest* req, std::string forward_server)
97 tc_url += req->app; 97 tc_url += req->app;
98 98
99 // dead loop check 99 // dead loop check
100 - std::string source_ep = req->vhost; 100 + std::string source_ep = "rtmp://";
  101 + source_ep += req->host;
101 source_ep += ":"; 102 source_ep += ":";
102 source_ep += req->port; 103 source_ep += req->port;
103 -  
104 - std::string dest_ep = vhost; 104 + source_ep += "?vhost=";
  105 + source_ep += req->vhost;
  106 +
  107 + std::string dest_ep = "rtmp://";
  108 + if (forward_server == "127.0.0.1") {
  109 + dest_ep += req->host;
  110 + } else {
  111 + dest_ep += forward_server;
  112 + }
105 dest_ep += ":"; 113 dest_ep += ":";
106 dest_ep += s_port; 114 dest_ep += s_port;
  115 + dest_ep += "?vhost=";
  116 + dest_ep += vhost;
107 117
108 if (source_ep == dest_ep) { 118 if (source_ep == dest_ep) {
109 ret = ERROR_SYSTEM_FORWARD_LOOP; 119 ret = ERROR_SYSTEM_FORWARD_LOOP;
110 - srs_warn("farder loop detected. src=%s, dest=%s, ret=%d", 120 + srs_warn("forward loop detected. src=%s, dest=%s, ret=%d",
111 source_ep.c_str(), dest_ep.c_str(), ret); 121 source_ep.c_str(), dest_ep.c_str(), ret);
112 return ret; 122 return ret;
113 } 123 }
@@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. @@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
31 // current release version 31 // current release version
32 #define VERSION_MAJOR "0" 32 #define VERSION_MAJOR "0"
33 #define VERSION_MINOR "9" 33 #define VERSION_MINOR "9"
34 -#define VERSION_REVISION "33" 34 +#define VERSION_REVISION "34"
35 #define RTMP_SIG_SRS_VERSION VERSION_MAJOR"."VERSION_MINOR"."VERSION_REVISION 35 #define RTMP_SIG_SRS_VERSION VERSION_MAJOR"."VERSION_MINOR"."VERSION_REVISION
36 // server info. 36 // server info.
37 #define RTMP_SIG_SRS_KEY "srs" 37 #define RTMP_SIG_SRS_KEY "srs"
@@ -87,6 +87,7 @@ SrsRequest* SrsRequest::copy() @@ -87,6 +87,7 @@ SrsRequest* SrsRequest::copy()
87 cp->app = app; 87 cp->app = app;
88 cp->objectEncoding = objectEncoding; 88 cp->objectEncoding = objectEncoding;
89 cp->pageUrl = pageUrl; 89 cp->pageUrl = pageUrl;
  90 + cp->host = host;
90 cp->port = port; 91 cp->port = port;
91 cp->schema = schema; 92 cp->schema = schema;
92 cp->stream = stream; 93 cp->stream = stream;
@@ -111,19 +112,20 @@ int SrsRequest::discovery_app() @@ -111,19 +112,20 @@ int SrsRequest::discovery_app()
111 } 112 }
112 113
113 if ((pos = url.find("/")) != std::string::npos) { 114 if ((pos = url.find("/")) != std::string::npos) {
114 - vhost = url.substr(0, pos);  
115 - url = url.substr(vhost.length() + 1);  
116 - srs_verbose("discovery vhost=%s", vhost.c_str()); 115 + host = url.substr(0, pos);
  116 + url = url.substr(host.length() + 1);
  117 + srs_verbose("discovery host=%s", host.c_str());
117 } 118 }
118 119
119 port = RTMP_DEFAULT_PORT; 120 port = RTMP_DEFAULT_PORT;
120 - if ((pos = vhost.find(":")) != std::string::npos) {  
121 - port = vhost.substr(pos + 1);  
122 - vhost = vhost.substr(0, pos);  
123 - srs_verbose("discovery vhost=%s, port=%s", vhost.c_str(), port.c_str()); 121 + if ((pos = host.find(":")) != std::string::npos) {
  122 + port = host.substr(pos + 1);
  123 + host = host.substr(0, pos);
  124 + srs_verbose("discovery host=%s, port=%s", host.c_str(), port.c_str());
124 } 125 }
125 126
126 app = url; 127 app = url;
  128 + vhost = host;
127 srs_vhost_resolve(vhost, app); 129 srs_vhost_resolve(vhost, app);
128 strip(); 130 strip();
129 131
@@ -46,8 +46,9 @@ class SrsPlayPacket; @@ -46,8 +46,9 @@ class SrsPlayPacket;
46 /** 46 /**
47 * the original request from client. 47 * the original request from client.
48 */ 48 */
49 -struct SrsRequest 49 +class SrsRequest
50 { 50 {
  51 +public:
51 /** 52 /**
52 * tcUrl: rtmp://request_vhost:port/app/stream 53 * tcUrl: rtmp://request_vhost:port/app/stream
53 * support pass vhost in query string, such as: 54 * support pass vhost in query string, such as:
@@ -61,6 +62,7 @@ struct SrsRequest @@ -61,6 +62,7 @@ struct SrsRequest
61 62
62 std::string schema; 63 std::string schema;
63 std::string vhost; 64 std::string vhost;
  65 + std::string host;
64 std::string port; 66 std::string port;
65 std::string app; 67 std::string app;
66 std::string stream; 68 std::string stream;