public Hashtable RegionConfigHTTPHandler(Hashtable request) { Hashtable response = new Hashtable(); response["content_type"] = "text/json"; response["keepalive"] = false; response["int_response_code"] = 200; response["str_response_string"] = m_FreeswitchService.GetJsonConfig(); return(response); }
public void Initialise(IConfigSource config) { m_Config = config.Configs["FreeSwitchVoice"]; if (m_Config == null) return; if (!m_Config.GetBoolean("Enabled", false)) return; try { string serviceDll = m_Config.GetString("LocalServiceModule", String.Empty); if (serviceDll == String.Empty) { m_log.Error("[FreeSwitchVoice]: No LocalServiceModule named in section FreeSwitchVoice. Not starting."); return; } Object[] args = new Object[] { config }; m_FreeswitchService = ServerUtils.LoadPlugin<IFreeswitchService>(serviceDll, args); string jsonConfig = m_FreeswitchService.GetJsonConfig(); //m_log.Debug("[FreeSwitchVoice]: Configuration string: " + jsonConfig); OSDMap map = (OSDMap)OSDParser.DeserializeJson(jsonConfig); m_freeSwitchAPIPrefix = map["APIPrefix"].AsString(); m_freeSwitchRealm = map["Realm"].AsString(); m_freeSwitchSIPProxy = map["SIPProxy"].AsString(); m_freeSwitchAttemptUseSTUN = map["AttemptUseSTUN"].AsBoolean(); m_freeSwitchEchoServer = map["EchoServer"].AsString(); m_freeSwitchEchoPort = map["EchoPort"].AsInteger(); m_freeSwitchDefaultWellKnownIP = map["DefaultWellKnownIP"].AsString(); m_freeSwitchDefaultTimeout = map["DefaultTimeout"].AsInteger(); m_freeSwitchUrlResetPassword = String.Empty; // m_freeSwitchContext = map["Context"].AsString(); if (String.IsNullOrEmpty(m_freeSwitchRealm) || String.IsNullOrEmpty(m_freeSwitchAPIPrefix)) { m_log.Error("[FreeSwitchVoice]: Freeswitch service mis-configured. Not starting."); return; } // set up http request handlers for // - prelogin: viv_get_prelogin.php // - signin: viv_signin.php // - buddies: viv_buddy.php // - ???: viv_watcher.php // - signout: viv_signout.php MainServer.Instance.AddHTTPHandler(String.Format("{0}/viv_get_prelogin.php", m_freeSwitchAPIPrefix), FreeSwitchSLVoiceGetPreloginHTTPHandler); MainServer.Instance.AddHTTPHandler(String.Format("{0}/freeswitch-config", m_freeSwitchAPIPrefix), FreeSwitchConfigHTTPHandler); // RestStreamHandler h = new // RestStreamHandler("GET", // String.Format("{0}/viv_get_prelogin.php", m_freeSwitchAPIPrefix), FreeSwitchSLVoiceGetPreloginHTTPHandler); // MainServer.Instance.AddStreamHandler(h); MainServer.Instance.AddHTTPHandler(String.Format("{0}/viv_signin.php", m_freeSwitchAPIPrefix), FreeSwitchSLVoiceSigninHTTPHandler); MainServer.Instance.AddHTTPHandler(String.Format("{0}/viv_buddy.php", m_freeSwitchAPIPrefix), FreeSwitchSLVoiceBuddyHTTPHandler); MainServer.Instance.AddHTTPHandler(String.Format("{0}/viv_watcher.php", m_freeSwitchAPIPrefix), FreeSwitchSLVoiceWatcherHTTPHandler); m_log.InfoFormat("[FreeSwitchVoice]: using FreeSwitch server {0}", m_freeSwitchRealm); m_Enabled = true; m_log.Info("[FreeSwitchVoice]: plugin enabled"); } catch (Exception e) { m_log.ErrorFormat("[FreeSwitchVoice]: plugin initialization failed: {0} {1}", e.Message, e.StackTrace); return; } // This here is a region module trying to make a global setting. // Not really a good idea but it's Windows only, so I can't test. try { ServicePointManager.ServerCertificateValidationCallback += CustomCertificateValidation; } catch (NotImplementedException) { try { #pragma warning disable 0612, 0618 // Mono does not implement the ServicePointManager.ServerCertificateValidationCallback yet! Don't remove this! ServicePointManager.CertificatePolicy = new MonoCert(); #pragma warning restore 0612, 0618 } catch (Exception) { // COmmented multiline spam log message //m_log.Error("[FreeSwitchVoice]: Certificate validation handler change not supported. You may get ssl certificate validation errors teleporting from your region to some SSL regions."); } } }
public void Initialise(IConfigSource config) { m_Config = config.Configs["FreeSwitchVoice"]; if (m_Config == null) { return; } if (!m_Config.GetBoolean("Enabled", false)) { return; } try { string serviceDll = m_Config.GetString("LocalServiceModule", String.Empty); if (serviceDll == String.Empty) { m_log.Error("[FreeSwitchVoice]: No LocalServiceModule named in section FreeSwitchVoice. Not starting."); return; } Object[] args = new Object[] { config }; m_FreeswitchService = ServerUtils.LoadPlugin <IFreeswitchService>(serviceDll, args); string jsonConfig = m_FreeswitchService.GetJsonConfig(); //m_log.Debug("[FreeSwitchVoice]: Configuration string: " + jsonConfig); OSDMap map = (OSDMap)OSDParser.DeserializeJson(jsonConfig); m_freeSwitchAPIPrefix = map["APIPrefix"].AsString(); m_freeSwitchRealm = map["Realm"].AsString(); m_freeSwitchSIPProxy = map["SIPProxy"].AsString(); m_freeSwitchAttemptUseSTUN = map["AttemptUseSTUN"].AsBoolean(); m_freeSwitchEchoServer = map["EchoServer"].AsString(); m_freeSwitchEchoPort = map["EchoPort"].AsInteger(); m_freeSwitchDefaultWellKnownIP = map["DefaultWellKnownIP"].AsString(); m_freeSwitchDefaultTimeout = map["DefaultTimeout"].AsInteger(); m_freeSwitchUrlResetPassword = String.Empty; // m_freeSwitchContext = map["Context"].AsString(); if (String.IsNullOrEmpty(m_freeSwitchRealm) || String.IsNullOrEmpty(m_freeSwitchAPIPrefix)) { m_log.Error("[FreeSwitchVoice]: Freeswitch service mis-configured. Not starting."); return; } // set up http request handlers for // - prelogin: viv_get_prelogin.php // - signin: viv_signin.php // - buddies: viv_buddy.php // - ???: viv_watcher.php // - signout: viv_signout.php MainServer.Instance.AddHTTPHandler(String.Format("{0}/viv_get_prelogin.php", m_freeSwitchAPIPrefix), FreeSwitchSLVoiceGetPreloginHTTPHandler); MainServer.Instance.AddHTTPHandler(String.Format("{0}/freeswitch-config", m_freeSwitchAPIPrefix), FreeSwitchConfigHTTPHandler); // RestStreamHandler h = new // RestStreamHandler("GET", // String.Format("{0}/viv_get_prelogin.php", m_freeSwitchAPIPrefix), FreeSwitchSLVoiceGetPreloginHTTPHandler); // MainServer.Instance.AddStreamHandler(h); MainServer.Instance.AddHTTPHandler(String.Format("{0}/viv_signin.php", m_freeSwitchAPIPrefix), FreeSwitchSLVoiceSigninHTTPHandler); MainServer.Instance.AddHTTPHandler(String.Format("{0}/viv_buddy.php", m_freeSwitchAPIPrefix), FreeSwitchSLVoiceBuddyHTTPHandler); MainServer.Instance.AddHTTPHandler(String.Format("{0}/viv_watcher.php", m_freeSwitchAPIPrefix), FreeSwitchSLVoiceWatcherHTTPHandler); m_log.InfoFormat("[FreeSwitchVoice]: using FreeSwitch server {0}", m_freeSwitchRealm); m_Enabled = true; m_log.Info("[FreeSwitchVoice]: plugin enabled"); } catch (Exception e) { m_log.ErrorFormat("[FreeSwitchVoice]: plugin initialization failed: {0} {1}", e.Message, e.StackTrace); return; } }
public void AddRegion(Scene scene) { // We generate these like this: The region's external host name // as defined in Regions.ini is a good address to use. It's a // dotted quad (or should be!) and it can reach this host from // a client. The port is grabbed from the region's HTTP server. m_openSimWellKnownHTTPAddress = scene.RegionInfo.ExternalHostName; m_freeSwitchServicePort = MainServer.Instance.Port; if (m_Enabled) { m_FreeswitchService = scene.RequestModuleInterface <IFreeswitchService>(); try { string jsonConfig = m_FreeswitchService.GetJsonConfig(); m_log.Debug("[FreeSwitchVoice]: Configuration string: " + jsonConfig); OSDMap map = (OSDMap)OSDParser.DeserializeJson(jsonConfig); m_freeSwitchAPIPrefix = map["APIPrefix"].AsString(); m_freeSwitchRealm = map["Realm"].AsString(); m_freeSwitchSIPProxy = map["SIPProxy"].AsString(); m_freeSwitchAttemptUseSTUN = map["AttemptUseSTUN"].AsBoolean(); m_freeSwitchEchoServer = map["EchoServer"].AsString(); m_freeSwitchEchoPort = map["EchoPort"].AsInteger(); m_freeSwitchDefaultWellKnownIP = map["DefaultWellKnownIP"].AsString(); m_freeSwitchDefaultTimeout = map["DefaultTimeout"].AsInteger(); m_freeSwitchUrlResetPassword = String.Empty; //m_freeSwitchContext = map["Context"].AsString (); if (String.IsNullOrEmpty(m_freeSwitchRealm) || String.IsNullOrEmpty(m_freeSwitchAPIPrefix)) { m_log.Error("[FreeSwitchVoice] plugin mis-configured"); m_log.Info("[FreeSwitchVoice] plugin disabled: incomplete configuration"); return; } // set up http request handlers for // - prelogin: viv_get_prelogin.php // - signin: viv_signin.php // - buddies: viv_buddy.php // - ???: viv_watcher.php // - signout: viv_signout.php MainServer.Instance.AddHTTPHandler(String.Format("{0}/viv_get_prelogin.php", m_freeSwitchAPIPrefix), FreeSwitchSLVoiceGetPreloginHTTPHandler); MainServer.Instance.AddHTTPHandler(String.Format("{0}/freeswitch-config", m_freeSwitchAPIPrefix), FreeSwitchConfigHTTPHandler); // RestStreamHandler h = new // RestStreamHandler("GET", // String.Format("{0}/viv_get_prelogin.php", m_freeSwitchAPIPrefix), FreeSwitchSLVoiceGetPreloginHTTPHandler); // MainServer.Instance.AddStreamHandler(h); MainServer.Instance.AddHTTPHandler(String.Format("{0}/viv_signin.php", m_freeSwitchAPIPrefix), FreeSwitchSLVoiceSigninHTTPHandler); MainServer.Instance.AddHTTPHandler(String.Format("{0}/viv_buddy.php", m_freeSwitchAPIPrefix), FreeSwitchSLVoiceBuddyHTTPHandler); m_log.InfoFormat("[FreeSwitchVoice] using FreeSwitch server {0}", m_freeSwitchRealm); m_log.Info("[FreeSwitchVoice] plugin enabled"); } catch (Exception e) { m_log.ErrorFormat("[FreeSwitchVoice] plugin initialization failed: {0}", e.Message); m_log.DebugFormat("[FreeSwitchVoice] plugin initialization failed: {0}", e.ToString()); return; } // This here is a region module trying to make a global setting. // Not really a good idea but it's Windows only, so I can't test. try { ServicePointManager.ServerCertificateValidationCallback += CustomCertificateValidation; } catch (NotImplementedException) { try { #pragma warning disable 0612, 0618 // Mono does not implement the ServicePointManager.ServerCertificateValidationCallback yet! Don't remove this! ServicePointManager.CertificatePolicy = new MonoCert(); #pragma warning restore 0612, 0618 } catch (Exception) { // COmmented multiline spam log message //m_log.Error("[FreeSwitchVoice]: Certificate validation handler change not supported. You may get ssl certificate validation errors teleporting from your region to some SSL regions."); } } // we need to capture scene in an anonymous method // here as we need it later in the callbacks scene.EventManager.OnRegisterCaps += delegate(UUID agentID, IHttpServer server) { return(OnRegisterCaps(scene, agentID, server)); }; //Add this to the OpenRegionSettings module so we can inform the client about it IOpenRegionSettingsModule ORSM = scene.RequestModuleInterface <IOpenRegionSettingsModule>(); if (ORSM != null) { ORSM.RegisterGenericValue("Voice", "SLVoice"); } } }
public void Initialise(IConfigSource config) { m_Config = config.Configs["FreeSwitchVoice"]; if (m_Config == null) { return; } if (!m_Config.GetBoolean("Enabled", false)) { return; } try { string serviceDll = m_Config.GetString("LocalServiceModule", String.Empty); if (serviceDll == String.Empty) { m_log.Error("[FreeSwitchVoice]: No LocalServiceModule named in section FreeSwitchVoice. Not starting."); return; } Object[] args = new Object[] { config }; m_FreeswitchService = ServerUtils.LoadPlugin <IFreeswitchService>(serviceDll, args); string jsonConfig = m_FreeswitchService.GetJsonConfig(); //m_log.Debug("[FreeSwitchVoice]: Configuration string: " + jsonConfig); OSDMap map = (OSDMap)OSDParser.DeserializeJson(jsonConfig); m_freeSwitchAPIPrefix = map["APIPrefix"].AsString(); m_freeSwitchRealm = map["Realm"].AsString(); m_freeSwitchSIPProxy = map["SIPProxy"].AsString(); m_freeSwitchAttemptUseSTUN = map["AttemptUseSTUN"].AsBoolean(); m_freeSwitchEchoServer = map["EchoServer"].AsString(); m_freeSwitchEchoPort = map["EchoPort"].AsInteger(); m_freeSwitchDefaultWellKnownIP = map["DefaultWellKnownIP"].AsString(); m_freeSwitchDefaultTimeout = map["DefaultTimeout"].AsInteger(); m_freeSwitchUrlResetPassword = String.Empty; // m_freeSwitchContext = map["Context"].AsString(); if (String.IsNullOrEmpty(m_freeSwitchRealm) || String.IsNullOrEmpty(m_freeSwitchAPIPrefix)) { m_log.Error("[FreeSwitchVoice]: Freeswitch service mis-configured. Not starting."); return; } // set up http request handlers for // - prelogin: viv_get_prelogin.php // - signin: viv_signin.php // - buddies: viv_buddy.php // - ???: viv_watcher.php // - signout: viv_signout.php MainServer.Instance.AddHTTPHandler(String.Format("{0}/viv_get_prelogin.php", m_freeSwitchAPIPrefix), FreeSwitchSLVoiceGetPreloginHTTPHandler); MainServer.Instance.AddHTTPHandler(String.Format("{0}/freeswitch-config", m_freeSwitchAPIPrefix), FreeSwitchConfigHTTPHandler); // RestStreamHandler h = new // RestStreamHandler("GET", // String.Format("{0}/viv_get_prelogin.php", m_freeSwitchAPIPrefix), FreeSwitchSLVoiceGetPreloginHTTPHandler); // MainServer.Instance.AddStreamHandler(h); MainServer.Instance.AddHTTPHandler(String.Format("{0}/viv_signin.php", m_freeSwitchAPIPrefix), FreeSwitchSLVoiceSigninHTTPHandler); MainServer.Instance.AddHTTPHandler(String.Format("{0}/viv_buddy.php", m_freeSwitchAPIPrefix), FreeSwitchSLVoiceBuddyHTTPHandler); MainServer.Instance.AddHTTPHandler(String.Format("{0}/viv_watcher.php", m_freeSwitchAPIPrefix), FreeSwitchSLVoiceWatcherHTTPHandler); m_log.InfoFormat("[FreeSwitchVoice]: using FreeSwitch server {0}", m_freeSwitchRealm); m_Enabled = true; m_log.Info("[FreeSwitchVoice]: plugin enabled"); } catch (Exception e) { m_log.ErrorFormat("[FreeSwitchVoice]: plugin initialization failed: {0} {1}", e.Message, e.StackTrace); return; } // This here is a region module trying to make a global setting. // Not really a good idea but it's Windows only, so I can't test. try { ServicePointManager.ServerCertificateValidationCallback += CustomCertificateValidation; } catch (NotImplementedException) { try { #pragma warning disable 0612, 0618 // Mono does not implement the ServicePointManager.ServerCertificateValidationCallback yet! Don't remove this! ServicePointManager.CertificatePolicy = new MonoCert(); #pragma warning restore 0612, 0618 } catch (Exception) { // COmmented multiline spam log message //m_log.Error("[FreeSwitchVoice]: Certificate validation handler change not supported. You may get ssl certificate validation errors teleporting from your region to some SSL regions."); } } }
public void AddRegion(IScene scene) { // We generate these like this: The region's external host name // as defined in Regions.ini is a good address to use. It's a // dotted quad (or should be!) and it can reach this host from // a client. The port is grabbed from the region's HTTP server. m_openSimWellKnownHTTPAddress = MainServer.Instance.HostName; m_freeSwitchServicePort = MainServer.Instance.Port; if (m_Enabled) { m_FreeswitchService = scene.RequestModuleInterface<IFreeswitchService>(); try { string jsonConfig = m_FreeswitchService.GetJsonConfig (); m_log.Debug ("[FreeSwitchVoice]: Configuration string: " + jsonConfig); OSDMap map = (OSDMap)OSDParser.DeserializeJson (jsonConfig); m_freeSwitchAPIPrefix = map["APIPrefix"].AsString (); m_freeSwitchRealm = map["Realm"].AsString (); m_freeSwitchSIPProxy = map["SIPProxy"].AsString (); m_freeSwitchAttemptUseSTUN = map["AttemptUseSTUN"].AsBoolean (); m_freeSwitchEchoServer = map["EchoServer"].AsString (); m_freeSwitchEchoPort = map["EchoPort"].AsInteger (); m_freeSwitchDefaultWellKnownIP = map["DefaultWellKnownIP"].AsString (); m_freeSwitchDefaultTimeout = map["DefaultTimeout"].AsInteger (); m_freeSwitchUrlResetPassword = String.Empty; //m_freeSwitchContext = map["Context"].AsString (); if (String.IsNullOrEmpty (m_freeSwitchRealm) || String.IsNullOrEmpty (m_freeSwitchAPIPrefix)) { m_log.Error ("[FreeSwitchVoice] plugin mis-configured"); m_log.Info ("[FreeSwitchVoice] plugin disabled: incomplete configuration"); return; } // set up http request handlers for // - prelogin: viv_get_prelogin.php // - signin: viv_signin.php // - buddies: viv_buddy.php // - ???: viv_watcher.php // - signout: viv_signout.php MainServer.Instance.AddHTTPHandler (String.Format ("{0}/viv_get_prelogin.php", m_freeSwitchAPIPrefix), FreeSwitchSLVoiceGetPreloginHTTPHandler); MainServer.Instance.AddHTTPHandler (String.Format ("{0}/freeswitch-config", m_freeSwitchAPIPrefix), FreeSwitchConfigHTTPHandler); // RestStreamHandler h = new // RestStreamHandler("GET", // String.Format("{0}/viv_get_prelogin.php", m_freeSwitchAPIPrefix), FreeSwitchSLVoiceGetPreloginHTTPHandler); // MainServer.Instance.AddStreamHandler(h); MainServer.Instance.AddHTTPHandler (String.Format ("{0}/viv_signin.php", m_freeSwitchAPIPrefix), FreeSwitchSLVoiceSigninHTTPHandler); MainServer.Instance.AddHTTPHandler (String.Format ("{0}/viv_buddy.php", m_freeSwitchAPIPrefix), FreeSwitchSLVoiceBuddyHTTPHandler); MainServer.Instance.AddHTTPHandler(String.Format("{0}/viv_watcher.php", m_freeSwitchAPIPrefix), FreeSwitchSLVoiceWatcherHTTPHandler); m_log.InfoFormat ("[FreeSwitchVoice] using FreeSwitch server {0}", m_freeSwitchRealm); m_log.Info ("[FreeSwitchVoice] plugin enabled"); } catch (Exception e) { m_log.ErrorFormat ("[FreeSwitchVoice] plugin initialization failed: {0}", e.Message); m_log.DebugFormat ("[FreeSwitchVoice] plugin initialization failed: {0}", e.ToString ()); return; } // This here is a region module trying to make a global setting. // Not really a good idea but it's Windows only, so I can't test. try { ServicePointManager.ServerCertificateValidationCallback += CustomCertificateValidation; } catch (NotImplementedException) { try { #pragma warning disable 0612, 0618 // Mono does not implement the ServicePointManager.ServerCertificateValidationCallback yet! Don't remove this! ServicePointManager.CertificatePolicy = new MonoCert (); #pragma warning restore 0612, 0618 } catch (Exception) { // COmmented multiline spam log message //m_log.Error("[FreeSwitchVoice]: Certificate validation handler change not supported. You may get ssl certificate validation errors teleporting from your region to some SSL regions."); } } // we need to capture scene in an anonymous method // here as we need it later in the callbacks scene.EventManager.OnRegisterCaps += delegate(UUID agentID, IHttpServer server) { return OnRegisterCaps(scene, agentID, server); }; //Add this to the OpenRegionSettings module so we can inform the client about it IOpenRegionSettingsModule ORSM = scene.RequestModuleInterface<IOpenRegionSettingsModule>(); if (ORSM != null) ORSM.RegisterGenericValue("Voice", "SLVoice"); } }