Merge pull request #425 from paullouisageneau/bind-address

Add bind address in configuration
This commit is contained in:
Paul-Louis Ageneau
2021-05-17 15:32:12 +02:00
committed by GitHub
5 changed files with 18 additions and 8 deletions

2
deps/libjuice vendored

View File

@ -74,6 +74,7 @@ struct RTC_CPP_EXPORT Configuration {
// ICE settings
std::vector<IceServer> iceServers;
optional<ProxyServer> proxyServer; // libnice only
optional<string> bindAddress; // libjuice only, default any
// Options
CertificateType certificateType = CertificateType::Default;

View File

@ -150,11 +150,12 @@ RTC_EXPORT void *rtcGetUserPointer(int i);
typedef struct {
const char **iceServers;
int iceServersCount;
const char *bindAddress; // libjuice only, NULL means any
rtcCertificateType certificateType;
bool enableIceTcp;
bool disableAutoNegotiation;
uint16_t portRangeBegin;
uint16_t portRangeEnd;
uint16_t portRangeBegin; // 0 means automatic
uint16_t portRangeEnd; // 0 means automatic
int mtu; // <= 0 means automatic
int maxMessageSize; // <= 0 means default
} rtcConfiguration;

View File

@ -290,15 +290,18 @@ int rtcCreatePeerConnection(const rtcConfiguration *config) {
for (int i = 0; i < config->iceServersCount; ++i)
c.iceServers.emplace_back(string(config->iceServers[i]));
c.certificateType = static_cast<CertificateType>(config->certificateType);
c.enableIceTcp = config->enableIceTcp;
c.disableAutoNegotiation = config->disableAutoNegotiation;
if (config->bindAddress)
c.bindAddress = string(config->bindAddress);
if (config->portRangeBegin > 0 || config->portRangeEnd > 0) {
c.portRangeBegin = config->portRangeBegin;
c.portRangeEnd = config->portRangeEnd;
}
c.certificateType = static_cast<CertificateType>(config->certificateType);
c.enableIceTcp = config->enableIceTcp;
c.disableAutoNegotiation = config->disableAutoNegotiation;
if (config->mtu > 0)
c.mtu = size_t(config->mtu);

View File

@ -131,6 +131,11 @@ IceTransport::IceTransport(const Configuration &config, candidate_callback candi
jconfig.turn_servers = k > 0 ? turn_servers : nullptr;
jconfig.turn_servers_count = k;
// Bind address
if (config.bindAddress) {
jconfig.bind_address = config.bindAddress->c_str();
}
// Port range
if (config.portRangeBegin > 1024 ||
(config.portRangeEnd != 0 && config.portRangeEnd != 65535)) {