Murat Dogan vor 5 Jahren
Ursprung
Commit
56bd8c98b3
3 geänderte Dateien mit 30 neuen und 4 gelöschten Zeilen
  1. 1 1
      deps/libjuice
  2. 11 0
      include/rtc/configuration.hpp
  3. 18 3
      src/icetransport.cpp

+ 1 - 1
deps/libjuice

@@ -1 +1 @@
-Subproject commit 47d8cc263abb3f3ca2530ca5516f6a52de37c312
+Subproject commit dd3a5375b5fcc0e6122217dbf22af55bd6910ec3

+ 11 - 0
include/rtc/configuration.hpp

@@ -51,8 +51,19 @@ struct IceServer {
 	RelayType relayType;
 };
 
+struct ProxyServer {
+	enum class Type { None = 0, Socks5, Http, Last = Http };
+
+	Type type = Type::None;
+	string ip;
+	uint16_t  port;
+	string username;
+	string password;
+};
+
 struct Configuration {
 	std::vector<IceServer> iceServers;
+	ProxyServer proxyServer;
 	bool enableIceTcp = false;
 	uint16_t portRangeBegin = 1024;
 	uint16_t portRangeEnd = 65535;

+ 18 - 3
src/icetransport.cpp

@@ -319,6 +319,18 @@ IceTransport::IceTransport(const Configuration &config, Description::Role role,
 	g_object_set(G_OBJECT(mNiceAgent.get()), "upnp", FALSE, nullptr);
 	g_object_set(G_OBJECT(mNiceAgent.get()), "upnp-timeout", 200, nullptr);
 
+	// Proxy
+	if (config.proxyServer.type != ProxyServer::Type::None) {
+		g_object_set(G_OBJECT(mNiceAgent.get()), "proxy-type", config.proxyServer.type, nullptr);
+		g_object_set(G_OBJECT(mNiceAgent.get()), "proxy-ip", config.proxyServer.ip.c_str(),
+		             nullptr);
+		g_object_set(G_OBJECT(mNiceAgent.get()), "proxy-port", config.proxyServer.port, nullptr);
+		g_object_set(G_OBJECT(mNiceAgent.get()), "proxy-username",
+		             config.proxyServer.username.c_str(), nullptr);
+		g_object_set(G_OBJECT(mNiceAgent.get()), "proxy-password",
+		             config.proxyServer.password.c_str(), nullptr);
+	}
+
 	// Randomize order
 	std::vector<IceServer> servers = config.iceServers;
 	unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
@@ -673,13 +685,15 @@ bool IceTransport::getSelectedCandidatePair(CandidateInfo *localInfo, CandidateI
 	localInfo->address = std::string(ipaddr);
 	localInfo->port = nice_address_get_port(&local->addr);
 	localInfo->type = IceTransport::NiceTypeToCandidateType(local->type);
-	localInfo->transportType = IceTransport::NiceTransportTypeToCandidateTransportType(local->transport);
+	localInfo->transportType =
+	    IceTransport::NiceTransportTypeToCandidateTransportType(local->transport);
 
 	nice_address_to_string(&remote->addr, ipaddr);
 	remoteInfo->address = std::string(ipaddr);
 	remoteInfo->port = nice_address_get_port(&remote->addr);
 	remoteInfo->type = IceTransport::NiceTypeToCandidateType(remote->type);
-	remoteInfo->transportType = IceTransport::NiceTransportTypeToCandidateTransportType(remote->transport);
+	remoteInfo->transportType =
+	    IceTransport::NiceTransportTypeToCandidateTransportType(remote->transport);
 
 	return true;
 }
@@ -697,7 +711,8 @@ const CandidateType IceTransport::NiceTypeToCandidateType(NiceCandidateType type
 	}
 }
 
-const CandidateTransportType IceTransport::NiceTransportTypeToCandidateTransportType(NiceCandidateTransport type) {
+const CandidateTransportType
+IceTransport::NiceTransportTypeToCandidateTransportType(NiceCandidateTransport type) {
 	switch (type) {
 	case NiceCandidateTransport::NICE_CANDIDATE_TRANSPORT_TCP_ACTIVE:
 		return CandidateTransportType::TcpActive;