From 920a58fbb389a7405bf73d27ea76acd043682882 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?N=C3=ADcolas=20Lazarte=20Kaqui?= Date: Tue, 20 Sep 2011 09:13:42 -0300 Subject: [PATCH 1/5] Use password to access channel on IRC --- SparkleLib/SparkleListenerBase.cs | 12 ++++++++++-- SparkleLib/SparkleListenerIrc.cs | 6 +++++- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/SparkleLib/SparkleListenerBase.cs b/SparkleLib/SparkleListenerBase.cs index b9293841..e212c919 100644 --- a/SparkleLib/SparkleListenerBase.cs +++ b/SparkleLib/SparkleListenerBase.cs @@ -43,6 +43,10 @@ namespace SparkleLib { { string uri = SparkleConfig.DefaultConfig.GetFolderOptionalAttribute ( folder_name, "announcements_url"); + + string key = SparkleConfig.DefaultConfig.GetFolderOptionalAttribute ( + folder_name, "key"); + if (uri == null) { // This is SparkleShare's centralized notification service. @@ -53,6 +57,10 @@ namespace SparkleLib { uri = "irc://204.62.14.135/"; } + if (key == null) { + key = "12345"; + } + Uri announce_uri = new Uri (uri); // We use only one listener per server to keep @@ -74,10 +82,10 @@ namespace SparkleLib { listeners.Add (new SparkleListenerTcp (announce_uri, folder_identifier)); break; case "irc": - listeners.Add (new SparkleListenerIrc (announce_uri, folder_identifier)); + listeners.Add (new SparkleListenerIrc (announce_uri, folder_identifier, key)); break; default: - listeners.Add (new SparkleListenerIrc (announce_uri, folder_identifier)); + listeners.Add (new SparkleListenerIrc (announce_uri, folder_identifier, key)); break; } diff --git a/SparkleLib/SparkleListenerIrc.cs b/SparkleLib/SparkleListenerIrc.cs index c7c102bf..79027646 100644 --- a/SparkleLib/SparkleListenerIrc.cs +++ b/SparkleLib/SparkleListenerIrc.cs @@ -29,9 +29,10 @@ namespace SparkleLib { private Thread thread; private IrcClient client; private string nick; + private string key; - public SparkleListenerIrc (Uri server, string folder_identifier) : + public SparkleListenerIrc (Uri server, string folder_identifier, string key) : base (server, folder_identifier) { // Try to get a uniqueish nickname @@ -41,6 +42,8 @@ namespace SparkleLib { // with a number, so prefix an alphabetic character this.nick = "s" + this.nick.Substring (0, 7); + this.key = key; + base.channels.Add ("#" + folder_identifier); this.client = new IrcClient () { @@ -110,6 +113,7 @@ namespace SparkleLib { SparkleHelpers.DebugInfo ("ListenerIrc", "Joining channel " + channel); this.client.RfcJoin (channel); this.client.RfcMode (channel, "+s"); + this.client.RfcMode (channel, "+k " + key); } // List to the channel, this blocks the thread From 876c331d8490c3e4e422e022a128fada7e453f15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?N=C3=ADcolas=20Lazarte=20Kaqui?= Date: Tue, 20 Sep 2011 13:20:05 -0300 Subject: [PATCH 2/5] Fixing wrong commit --- SparkleLib/SparkleListenerIrc.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/SparkleLib/SparkleListenerIrc.cs b/SparkleLib/SparkleListenerIrc.cs index 79027646..5b65f725 100644 --- a/SparkleLib/SparkleListenerIrc.cs +++ b/SparkleLib/SparkleListenerIrc.cs @@ -142,6 +142,7 @@ namespace SparkleLib { SparkleHelpers.DebugInfo ("ListenerIrc", "Joining channel " + channel); this.client.RfcJoin (channel); this.client.RfcMode (channel, "+s"); + this.client.RfcMode (channel, "+k " + key); } } } From c869a07bd607249f604ca6e6c2f2823dd9a6d4d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?N=C3=ADcolas=20Lazarte=20Kaqui?= Date: Tue, 20 Sep 2011 15:11:38 -0300 Subject: [PATCH 3/5] When not set the key user try to join no key --- SparkleLib/SparkleListenerBase.cs | 4 ---- SparkleLib/SparkleListenerIrc.cs | 18 ++++++++++++++---- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/SparkleLib/SparkleListenerBase.cs b/SparkleLib/SparkleListenerBase.cs index e212c919..f865ffed 100644 --- a/SparkleLib/SparkleListenerBase.cs +++ b/SparkleLib/SparkleListenerBase.cs @@ -57,10 +57,6 @@ namespace SparkleLib { uri = "irc://204.62.14.135/"; } - if (key == null) { - key = "12345"; - } - Uri announce_uri = new Uri (uri); // We use only one listener per server to keep diff --git a/SparkleLib/SparkleListenerIrc.cs b/SparkleLib/SparkleListenerIrc.cs index 5b65f725..ab7a03ed 100644 --- a/SparkleLib/SparkleListenerIrc.cs +++ b/SparkleLib/SparkleListenerIrc.cs @@ -111,9 +111,14 @@ namespace SparkleLib { foreach (string channel in base.channels) { SparkleHelpers.DebugInfo ("ListenerIrc", "Joining channel " + channel); - this.client.RfcJoin (channel); + if (key != null) { + SparkleHelpers.DebugInfo ("ListenerIrc", "Ussing key"); + this.client.RfcJoin (channel, key); + this.client.RfcMode (channel, "+k " + key); + } else { + this.client.RfcJoin (channel); + } this.client.RfcMode (channel, "+s"); - this.client.RfcMode (channel, "+k " + key); } // List to the channel, this blocks the thread @@ -140,9 +145,14 @@ namespace SparkleLib { if (IsConnected) { SparkleHelpers.DebugInfo ("ListenerIrc", "Joining channel " + channel); - this.client.RfcJoin (channel); + if (key != null) { + SparkleHelpers.DebugInfo ("ListenerIrc", "Ussing key"); + this.client.RfcJoin (channel, key); + this.client.RfcMode (channel, "+k " + key); + } else { + this.client.RfcJoin (channel); + } this.client.RfcMode (channel, "+s"); - this.client.RfcMode (channel, "+k " + key); } } } From 9a1a7f462680e10d6d146158595b2ca1d5b742b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?N=C3=ADcolas=20Lazarte=20Kaqui?= Date: Tue, 11 Oct 2011 12:11:12 -0300 Subject: [PATCH 4/5] included setting to allow or disallow access to key channels without --- SparkleLib/SparkleListenerBase.cs | 19 +++++++++++++++---- SparkleLib/SparkleListenerIrc.cs | 27 +++++++++++++++++++++------ 2 files changed, 36 insertions(+), 10 deletions(-) diff --git a/SparkleLib/SparkleListenerBase.cs b/SparkleLib/SparkleListenerBase.cs index f865ffed..93cf1dae 100644 --- a/SparkleLib/SparkleListenerBase.cs +++ b/SparkleLib/SparkleListenerBase.cs @@ -43,10 +43,14 @@ namespace SparkleLib { { string uri = SparkleConfig.DefaultConfig.GetFolderOptionalAttribute ( folder_name, "announcements_url"); - + + // Key to turn the channel access more safely. string key = SparkleConfig.DefaultConfig.GetFolderOptionalAttribute ( folder_name, "key"); - + + // Identifier to define access in IRC channel when no key is defined + string dangerous_access = SparkleConfig.DefaultConfig.GetFolderOptionalAttribute ( + folder_name, "dangerous_access"); if (uri == null) { // This is SparkleShare's centralized notification service. @@ -57,6 +61,13 @@ namespace SparkleLib { uri = "irc://204.62.14.135/"; } + // This action ensures that the Sparkleshare function normally when the key is not defined. + // It is recommended that the user asked a question to see whether or not to allow access + // to the channel without a key. + if (dangerous_access == null) { + dangerous_access = "yes"; + } + Uri announce_uri = new Uri (uri); // We use only one listener per server to keep @@ -78,10 +89,10 @@ namespace SparkleLib { listeners.Add (new SparkleListenerTcp (announce_uri, folder_identifier)); break; case "irc": - listeners.Add (new SparkleListenerIrc (announce_uri, folder_identifier, key)); + listeners.Add (new SparkleListenerIrc (announce_uri, folder_identifier, key, dangerous_access)); break; default: - listeners.Add (new SparkleListenerIrc (announce_uri, folder_identifier, key)); + listeners.Add (new SparkleListenerIrc (announce_uri, folder_identifier, key, dangerous_access)); break; } diff --git a/SparkleLib/SparkleListenerIrc.cs b/SparkleLib/SparkleListenerIrc.cs index ab7a03ed..91e4cc40 100644 --- a/SparkleLib/SparkleListenerIrc.cs +++ b/SparkleLib/SparkleListenerIrc.cs @@ -30,9 +30,10 @@ namespace SparkleLib { private IrcClient client; private string nick; private string key; + private string dangerous_access; - public SparkleListenerIrc (Uri server, string folder_identifier, string key) : + public SparkleListenerIrc (Uri server, string folder_identifier, string key, string dangerous_access) : base (server, folder_identifier) { // Try to get a uniqueish nickname @@ -42,8 +43,12 @@ namespace SparkleLib { // with a number, so prefix an alphabetic character this.nick = "s" + this.nick.Substring (0, 7); + // Key to access the channel this.key = key; + // Allow access to the channel + this.dangerous_access = dangerous_access; + base.channels.Add ("#" + folder_identifier); this.client = new IrcClient () { @@ -112,11 +117,16 @@ namespace SparkleLib { foreach (string channel in base.channels) { SparkleHelpers.DebugInfo ("ListenerIrc", "Joining channel " + channel); if (key != null) { - SparkleHelpers.DebugInfo ("ListenerIrc", "Ussing key"); + SparkleHelpers.DebugInfo ("ListenerIrc", "Key set to access the channel"); this.client.RfcJoin (channel, key); this.client.RfcMode (channel, "+k " + key); } else { - this.client.RfcJoin (channel); + if (dangerous_access == "yes") { + SparkleHelpers.DebugInfo ("ListenerIrc", "Accessing a dangerous channel change the setting to not access"); + this.client.RfcJoin (channel); + } else { + SparkleHelpers.DebugInfo ("ListenerIrc", "Dangerous channel change the setting to access"); + } } this.client.RfcMode (channel, "+s"); } @@ -146,14 +156,19 @@ namespace SparkleLib { if (IsConnected) { SparkleHelpers.DebugInfo ("ListenerIrc", "Joining channel " + channel); if (key != null) { - SparkleHelpers.DebugInfo ("ListenerIrc", "Ussing key"); + SparkleHelpers.DebugInfo ("ListenerIrc", "Key set to access the channel"); this.client.RfcJoin (channel, key); this.client.RfcMode (channel, "+k " + key); } else { - this.client.RfcJoin (channel); + if (dangerous_access == "yes") { + SparkleHelpers.DebugInfo ("ListenerIrc", "Accessing a dangerous channel change the setting to not access"); + this.client.RfcJoin (channel); + } else { + SparkleHelpers.DebugInfo ("ListenerIrc", "Dangerous channel change the setting to access"); + } } - this.client.RfcMode (channel, "+s"); } + this.client.RfcMode (channel, "+s"); } } From a3426e5ca551ec6f7a59852f5226c62ee3b478e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?N=C3=ADcolas=20Lazarte=20Kaqui?= Date: Sun, 16 Oct 2011 16:46:37 -0200 Subject: [PATCH 5/5] =?UTF-8?q?accepting=20the=20suggestions=20made=20?= =?UTF-8?q?=E2=80=8B=E2=80=8Bby=20hbons?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SparkleLib/SparkleListenerBase.cs | 19 ++---------- SparkleLib/SparkleListenerIrc.cs | 49 ++++++++++++++++++------------- 2 files changed, 31 insertions(+), 37 deletions(-) diff --git a/SparkleLib/SparkleListenerBase.cs b/SparkleLib/SparkleListenerBase.cs index 93cf1dae..b9293841 100644 --- a/SparkleLib/SparkleListenerBase.cs +++ b/SparkleLib/SparkleListenerBase.cs @@ -44,14 +44,6 @@ namespace SparkleLib { string uri = SparkleConfig.DefaultConfig.GetFolderOptionalAttribute ( folder_name, "announcements_url"); - // Key to turn the channel access more safely. - string key = SparkleConfig.DefaultConfig.GetFolderOptionalAttribute ( - folder_name, "key"); - - // Identifier to define access in IRC channel when no key is defined - string dangerous_access = SparkleConfig.DefaultConfig.GetFolderOptionalAttribute ( - folder_name, "dangerous_access"); - if (uri == null) { // This is SparkleShare's centralized notification service. // Don't worry, we only use this server as a backup if you @@ -61,13 +53,6 @@ namespace SparkleLib { uri = "irc://204.62.14.135/"; } - // This action ensures that the Sparkleshare function normally when the key is not defined. - // It is recommended that the user asked a question to see whether or not to allow access - // to the channel without a key. - if (dangerous_access == null) { - dangerous_access = "yes"; - } - Uri announce_uri = new Uri (uri); // We use only one listener per server to keep @@ -89,10 +74,10 @@ namespace SparkleLib { listeners.Add (new SparkleListenerTcp (announce_uri, folder_identifier)); break; case "irc": - listeners.Add (new SparkleListenerIrc (announce_uri, folder_identifier, key, dangerous_access)); + listeners.Add (new SparkleListenerIrc (announce_uri, folder_identifier)); break; default: - listeners.Add (new SparkleListenerIrc (announce_uri, folder_identifier, key, dangerous_access)); + listeners.Add (new SparkleListenerIrc (announce_uri, folder_identifier)); break; } diff --git a/SparkleLib/SparkleListenerIrc.cs b/SparkleLib/SparkleListenerIrc.cs index 91e4cc40..e3235a54 100644 --- a/SparkleLib/SparkleListenerIrc.cs +++ b/SparkleLib/SparkleListenerIrc.cs @@ -29,11 +29,11 @@ namespace SparkleLib { private Thread thread; private IrcClient client; private string nick; - private string key; - private string dangerous_access; + private string announcements_password; + private bool allow_passwordless_join; - public SparkleListenerIrc (Uri server, string folder_identifier, string key, string dangerous_access) : + public SparkleListenerIrc (Uri server, string folder_identifier) : base (server, folder_identifier) { // Try to get a uniqueish nickname @@ -43,11 +43,20 @@ namespace SparkleLib { // with a number, so prefix an alphabetic character this.nick = "s" + this.nick.Substring (0, 7); - // Key to access the channel - this.key = key; + // Key to turn the channel access more safely. + this.announcements_password = + SparkleConfig.DefaultConfig.GetConfigOption ("announcements_password"); - // Allow access to the channel - this.dangerous_access = dangerous_access; + // Identifier to define access in IRC channel when no key is defined + this.allow_passwordless_join = + SparkleConfig.DefaultConfig.GetConfigOption ("allow_passwordless_join"); + + // This action ensures that the Sparkleshare function normally when the key is not defined. + // It is recommended that the user asked a question to see whether or not to allow access + // to the channel without a key. + if (this.allow_passwordless_join == null) { + this.allow_passwordless_join = true + } base.channels.Add ("#" + folder_identifier); @@ -116,16 +125,16 @@ namespace SparkleLib { foreach (string channel in base.channels) { SparkleHelpers.DebugInfo ("ListenerIrc", "Joining channel " + channel); - if (key != null) { - SparkleHelpers.DebugInfo ("ListenerIrc", "Key set to access the channel"); - this.client.RfcJoin (channel, key); - this.client.RfcMode (channel, "+k " + key); + if (this.announcements_password != null) { + SparkleHelpers.DebugInfo ("ListenerIrc", "Password set to access the channel"); + this.client.RfcJoin (channel, this.announcements_password); + this.client.RfcMode (channel, "+k " + this.announcements_password); } else { - if (dangerous_access == "yes") { + if (allow_passwordless_join) { SparkleHelpers.DebugInfo ("ListenerIrc", "Accessing a dangerous channel change the setting to not access"); this.client.RfcJoin (channel); } else { - SparkleHelpers.DebugInfo ("ListenerIrc", "Dangerous channel change the setting to access"); + SparkleHelpers.DebugInfo ("ListenerIrc", "Dangerous channel, change the setting to access"); } } this.client.RfcMode (channel, "+s"); @@ -155,20 +164,20 @@ namespace SparkleLib { if (IsConnected) { SparkleHelpers.DebugInfo ("ListenerIrc", "Joining channel " + channel); - if (key != null) { - SparkleHelpers.DebugInfo ("ListenerIrc", "Key set to access the channel"); - this.client.RfcJoin (channel, key); - this.client.RfcMode (channel, "+k " + key); + if (this.announcements_password != null) { + SparkleHelpers.DebugInfo ("ListenerIrc", "Password set to access the channel"); + this.client.RfcJoin (channel, this.announcements_password); + this.client.RfcMode (channel, "+k " + this.announcements_password); } else { - if (dangerous_access == "yes") { + if (allow_passwordless_join) { SparkleHelpers.DebugInfo ("ListenerIrc", "Accessing a dangerous channel change the setting to not access"); this.client.RfcJoin (channel); } else { - SparkleHelpers.DebugInfo ("ListenerIrc", "Dangerous channel change the setting to access"); + SparkleHelpers.DebugInfo ("ListenerIrc", "Dangerous channel, change the setting to access"); } } + this.client.RfcMode (channel, "+s"); } - this.client.RfcMode (channel, "+s"); } }