Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use instance ip as fallback domain name #2513

Merged
merged 1 commit into from
Sep 21, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -251,18 +251,24 @@ private String uri(final ServletContext context) {
* https://github.com/RestComm/Restcomm-Connect/issues/2085
* @param configuration
* @param storage
* @param sipUriHostAsFallbackDomain - if hostname is not provided in restcomm.xml then provided sipuri host will be used as domain.
*/
private boolean generateDefaultDomainName (final Configuration configuration, final DaoManager storage) {
private boolean generateDefaultDomainName (final Configuration configuration, final DaoManager storage, final SipURI sipUriHostAsFallbackDomain) {
try{
final Sid defaultOrganization = new Sid("ORafbe225ad37541eba518a74248f0ac4c");
final String hostname = configuration.getString("hostname");
String hostname = configuration.getString("hostname");

if(hostname != null && !hostname.trim().equals("")){
if(logger.isInfoEnabled())
logger.info("Generate Default Domain Name based on RC hostname: "+hostname);
}else{
logger.error("Unable to generateDefaultDomainName hostname property is null in restcomm.xml");
return false;
if(sipUriHostAsFallbackDomain != null){
logger.warn("Hostname property is null in restcomm.xml, will assign this host as domain: "+sipUriHostAsFallbackDomain.getHost());
hostname = sipUriHostAsFallbackDomain.getHost();
}else {
logger.error("Hostname property is null in restcomm.xml, As well restcomm outbound sipuri is NULL.");
return false;
}
}

Organization organization = storage.getOrganizationsDao().getOrganization(defaultOrganization);
Expand Down Expand Up @@ -396,8 +402,9 @@ public void servletInitialized(SipServletContextEvent event) {
Version.printVersion();
GenerateInstanceId generateInstanceId = null;
InstanceId instanceId = null;
SipURI sipURI = null;
try {
SipURI sipURI = outboundInterface(context,"udp");
sipURI = outboundInterface(context,"udp");
if (sipURI != null) {
generateInstanceId = new GenerateInstanceId(context, sipURI);
} else {
Expand All @@ -414,7 +421,7 @@ public void servletInitialized(SipServletContextEvent event) {
monitoring.tell(instanceId, null);
RestcommConfiguration.getInstance().getMain().setInstanceId(instanceId.getId().toString());

if(!generateDefaultDomainName(xml.subset("http-client"), storage)){
if(!generateDefaultDomainName(xml.subset("http-client"), storage, sipURI)){
logger.error("Unable to generate DefaultDomainName, Restcomm Akka system will exit now...");
system.shutdown();
system.awaitTermination();
Expand Down