diff options
Diffstat (limited to 'src/common/servlist.c')
-rw-r--r-- | src/common/servlist.c | 331 |
1 files changed, 71 insertions, 260 deletions
diff --git a/src/common/servlist.c b/src/common/servlist.c index 7de77596..6f9f9ed2 100644 --- a/src/common/servlist.c +++ b/src/common/servlist.c @@ -45,6 +45,7 @@ struct defaultserver char *charset; int loginmode; /* default authentication type */ char *connectcmd; /* default connect command - should only be used for rare login types, paired with LOGIN_CUSTOM */ + gboolean ssl; }; static const struct defaultserver def[] = @@ -59,20 +60,11 @@ static const struct defaultserver def[] = {"AccessIRC", 0}, {0, "irc.accessirc.net"}, - {0, "eu.accessirc.net"}, {"AfterNET", 0}, {0, "irc.afternet.org"}, - {0, "us.afternet.org"}, - {0, "eu.afternet.org"}, {"Aitvaras", 0}, -#ifdef USE_IPV6 -#ifdef USE_OPENSSL - {0, "irc6.ktu.lt/+7668"}, -#endif - {0, "irc6.ktu.lt/7666"}, -#endif #ifdef USE_OPENSSL {0, "irc.data.lt/+6668"}, {0, "irc.omnitel.net/+6668"}, @@ -86,52 +78,25 @@ static const struct defaultserver def[] = {0, "irc.kis.lt"}, {0, "irc.vub.lt"}, - {"AlphaChat", 0, 0, 0, LOGIN_SASL}, - {0, "irc.alphachat.net"}, - {0, "na.alphachat.net"}, - {0, "eu.alphachat.net"}, - {0, "au.alphachat.net"}, - {0, "za.alphachat.net"}, - - {"Anthrochat", 0}, -#ifdef USE_OPENSSL - {0, "irc.anthrochat.net/+6697"}, -#endif + {"Anthrochat", 0, 0, 0, 0, 0, TRUE}, {0, "irc.anthrochat.net"}, {"ARCNet", 0}, - {0, "se1.arcnet.vapor.com"}, - {0, "us1.arcnet.vapor.com"}, - {0, "us2.arcnet.vapor.com"}, - {0, "us3.arcnet.vapor.com"}, - {0, "ca1.arcnet.vapor.com"}, - {0, "de1.arcnet.vapor.com"}, - {0, "de3.arcnet.vapor.com"}, - {0, "ch1.arcnet.vapor.com"}, - {0, "be1.arcnet.vapor.com"}, - {0, "nl3.arcnet.vapor.com"}, - {0, "uk1.arcnet.vapor.com"}, - {0, "uk2.arcnet.vapor.com"}, - {0, "fr1.arcnet.vapor.com"}, + {0, "arcnet-irc.org"}, + + {"AthemeNet", 0, 0, 0, LOGIN_SASL, 0, TRUE}, + {0, "irc.atheme.org"}, {"AustNet", 0}, - {0, "au.austnet.org"}, - {0, "us.austnet.org"}, + {0, "irc.austnet.org"}, {"AzzurraNet", 0}, {0, "irc.azzurra.org"}, - {0, "crypto.azzurra.org"}, - {"Canternet", 0, 0, 0, LOGIN_SASL}, -#ifdef USE_OPENSSL - {0, "irc.canternet.org/+6697"}, -#endif + {"Canternet", 0, 0, 0, LOGIN_SASL, 0, TRUE}, {0, "irc.canternet.org"}, - {"Chat4all", 0}, -#ifdef USE_OPENSSL - {0, "irc.chat4all.org/+7001"}, -#endif + {"Chat4all", 0, 0, 0, 0, 0, TRUE}, {0, "irc.chat4all.org"}, {"ChattingAway", 0}, @@ -139,26 +104,21 @@ static const struct defaultserver def[] = {"ChatJunkies", 0}, {0, "irc.chatjunkies.org"}, - {0, "nl.chatjunkies.org"}, {"ChatNet", 0}, - {0, "US.ChatNet.Org"}, + {0, "irc.chatnet.org"}, {"ChatSpike", 0}, {0, "irc.chatspike.net"}, {"Criten", 0}, {0, "irc.criten.net"}, - {0, "irc.eu.criten.net"}, {"DALnet", 0}, {0, "irc.dal.net"}, - {0, "irc.eu.dal.net"}, {"Dark-Tou-Net", 0}, {0, "irc.d-t-net.de"}, - {0, "bw.d-t-net.de"}, - {0, "nc.d-t-net.de"}, {"DarkMyst", 0, 0, 0, LOGIN_SASL}, {0, "irc.darkmyst.org"}, @@ -177,66 +137,36 @@ static const struct defaultserver def[] = {0, "irc.lightning.net"}, {0, "irc.servercentral.net"}, - {"ElectroCode", 0}, -#ifdef USE_OPENSSL - - {0, "irc.electrocode.net/+6697"}, -#endif + {"ElectroCode", 0, 0, 0, 0, 0, TRUE}, {0, "irc.electrocode.net"}, {"EnterTheGame", 0}, - {0, "IRC.EnterTheGame.Com"}, + {0, "irc.enterthegame.com"}, - {"EntropyNet", 0, 0, 0, LOGIN_SASL}, -#ifdef USE_OPENSSL - {0, "irc.entropynet.net/+6697"}, -#endif + {"EntropyNet", 0, 0, 0, LOGIN_SASL, 0, TRUE}, {0, "irc.entropynet.net"}, -#ifdef USE_IPV6 -#ifdef USE_OPENSSL - {0, "irc6.entropynet.net/+6697"}, -#endif - {0, "irc6.entropynet.net"}, -#endif - {"EsperNet", 0, 0, 0, LOGIN_SASL}, -#ifdef USE_OPENSSL - {0, "irc.esper.net/+6697"}, -#endif + {"EsperNet", 0, 0, 0, LOGIN_SASL, 0, TRUE}, {0, "irc.esper.net"}, {"EUIrc", 0}, {0, "irc.euirc.net"}, - {0, "irc.ham.de.euirc.net"}, - {0, "irc.ber.de.euirc.net"}, - {0, "irc.ffm.de.euirc.net"}, - {0, "irc.bre.de.euirc.net"}, - {0, "irc.hes.de.euirc.net"}, - {0, "irc.inn.at.euirc.net"}, - {0, "irc.bas.ch.euirc.net"}, {"EuropNet", 0}, {0, "irc.europnet.org"}, {"FDFNet", 0}, {0, "irc.fdfnet.net"}, - {0, "irc.eu.fdfnet.net"}, {"FEFNet", 0, 0, 0, LOGIN_SASL}, {0, "irc.fef.net"}, - {"freenode", 0, 0, 0, LOGIN_SASL}, -#ifdef USE_OPENSSL - {0, "chat.freenode.net/+6697"}, -#endif + {"freenode", 0, 0, 0, LOGIN_SASL, 0, TRUE}, {0, "chat.freenode.net"}, /* irc. points to chat. but many users and urls still reference it */ {0, "irc.freenode.net"}, - {"Furnet", 0}, -#ifdef USE_OPENSSL - {0, "irc.furnet.org/+6697"}, -#endif + {"Furnet", 0, 0, 0, 0, 0, TRUE}, {0, "irc.furnet.org"}, {"GalaxyNet", 0}, @@ -245,18 +175,14 @@ static const struct defaultserver def[] = {"GameSurge", 0}, {0, "irc.gamesurge.net"}, - {"GeeksIRC", 0, 0, 0, LOGIN_SASL}, -#ifdef USE_OPENSSL - {0, "irc.geeksirc.net/+6697"}, -#endif + {"GeeksIRC", 0, 0, 0, LOGIN_SASL, 0, TRUE}, {0, "irc.geeksirc.net"}, {"GeekShed", 0}, {0, "irc.geekshed.net"}, {"German-Elite", 0}, - {0, "dominion.german-elite.net"}, - {0, "komatu.german-elite.net"}, + {0, "irc.german-elite.net"}, {"GIMPNet", 0}, {0, "irc.gimp.org"}, @@ -268,22 +194,13 @@ static const struct defaultserver def[] = {"IdleMonkeys", 0}, {0, "irc.idlemonkeys.net"}, - {"IndirectIRC", 0}, -#ifdef USE_OPENSSL - {0, "irc.indirectirc.com/+6697"}, -#endif + {"IndirectIRC", 0, 0, 0, 0, 0, TRUE}, {0, "irc.indirectirc.com"}, - {"Interlinked", 0, 0, 0, LOGIN_SASL}, -#ifdef USE_OPENSSL - {0, "irc.interlinked.me/+6697"}, -#endif + {"Interlinked", 0, 0, 0, LOGIN_SASL, 0, TRUE}, {0, "irc.interlinked.me"}, - {"IRC4Fun", 0, 0, 0, LOGIN_SASL}, -#ifdef USE_OPENSSL - {0, "irc.irc4fun.net/+6697"}, -#endif + {"IRC4Fun", 0, 0, 0, LOGIN_SASL, 0, TRUE}, {0, "irc.irc4fun.net"}, {"IRCHighWay", 0}, @@ -294,28 +211,15 @@ static const struct defaultserver def[] = {"IrcLink", 0}, {0, "irc.irclink.net"}, - {0, "Alesund.no.eu.irclink.net"}, - {0, "Oslo.no.eu.irclink.net"}, - {0, "frogn.no.eu.irclink.net"}, - {0, "tonsberg.no.eu.irclink.net"}, {"IRCNet", 0}, {0, "open.ircnet.net"}, - {0, "irc.de.ircnet.net"}, - - {"IRCNode", 0, 0, 0, LOGIN_SASL}, -#ifdef USE_OPENSSL - {0, "irc.ircnode.org/+6697"}, -#endif - {0, "irc.ircnode.org"}, {"Irctoo.net", 0}, {0, "irc.irctoo.net"}, {"iZ-smart.net", 0}, - {0, "irc.iZ-smart.net/6666"}, - {0, "irc.iZ-smart.net/6667"}, - {0, "irc.iZ-smart.net/6668"}, + {0, "irc.iz-smart.net"}, {"Krstarica", 0}, {0, "irc.krstarica.com"}, @@ -323,12 +227,6 @@ static const struct defaultserver def[] = #ifdef USE_OPENSSL {"LinkNet", 0}, {0, "irc.link-net.org/+7000"}, - {0, "as.link-net.org/+7000"}, - {0, "eu.link-net.org/+7000"}, - {0, "us.link-net.org/+7000"}, -#ifdef USE_IPV6 - {0, "irc6.link-net.org/+7000"}, -#endif #endif {"MindForge", 0}, @@ -358,31 +256,14 @@ static const struct defaultserver def[] = {"PIRC.PL", 0}, {0, "irc.pirc.pl"}, - {"PonyChat", 0, 0, 0, LOGIN_SASL}, -#ifdef USE_OPENSSL - {0, "irc.ponychat.net/+6697"}, -#endif + {"PonyChat", 0, 0, 0, LOGIN_SASL, 0, TRUE}, {0, "irc.ponychat.net"}, {"PTNet.org", 0}, - {0, "irc.PTNet.org"}, - {0, "world.PTnet.org"}, - {0, "netvisao.PTnet.org"}, - {0, "uevora.PTnet.org"}, - {0, "vianetworks.PTnet.org"}, - {0, "uc.PTnet.org"}, - {0, "nfsi.ptnet.org"}, - {0, "fctunl.ptnet.org"}, + {0, "irc.ptnet.org"}, {"QuakeNet", 0, 0, 0, LOGIN_CHALLENGEAUTH}, {0, "irc.quakenet.org"}, - {0, "irc.se.quakenet.org"}, - {0, "irc.dk.quakenet.org"}, - {0, "irc.no.quakenet.org"}, - {0, "irc.fi.quakenet.org"}, - {0, "irc.be.quakenet.org"}, - {0, "irc.uk.quakenet.org"}, - {0, "irc.it.quakenet.org"}, {"Rizon", 0}, {0, "irc.rizon.net"}, @@ -395,37 +276,21 @@ static const struct defaultserver def[] = {"SceneNet", 0}, {0, "irc.scene.org"}, - {0, "irc.eu.scene.org"}, - {0, "irc.us.scene.org"}, {"SeilEn.de", 0}, {0, "irc.seilen.de"}, - {"SeionIRC", 0, 0, 0, LOGIN_SASL}, -#ifdef USE_OPENSSL - {0, "irc.seion.us/+6697"}, -#endif - {0, "irc.seion.us"}, - {"Serenity-IRC", 0}, {0, "irc.serenity-irc.net"}, - {0, "eu.serenity-irc.net"}, - {0, "us.serenity-irc.net"}, {"SlashNET", 0}, {0, "irc.slashnet.org"}, - {0, "area51.slashnet.org"}, - {0, "moo.slashnet.org"}, - {0, "radon.slashnet.org"}, - {"Snoonet", 0, 0, 0, LOGIN_SASL}, -#ifdef USE_OPENSSL - {0, "irc.snoonet.org/+6697"}, -#endif - {0, "irc.snoonet.org/6667"}, + {"Snoonet", 0, 0, 0, LOGIN_SASL, 0, TRUE}, + {0, "irc.snoonet.org"}, {"Snyde", 0}, - {0, "irc.snyde.net/6667"}, + {0, "irc.snyde.net"}, {"Sohbet.Net", 0}, {0, "irc.sohbet.net"}, @@ -434,57 +299,28 @@ static const struct defaultserver def[] = {0, "irc.solidirc.com"}, {"SorceryNet", 0, 0, 0, LOGIN_SASL}, - {0, "irc.sorcery.net/9000"}, - {0, "irc.us.sorcery.net/9000"}, - {0, "irc.eu.sorcery.net/9000"}, + {0, "irc.sorcery.net"}, - {"SpotChat", 0, 0, 0, LOGIN_SASL}, -#ifdef USE_OPENSSL - {0, "irc.spotchat.org/+6697"}, -#endif - {0, "irc.spotchat.org/6667"}, + {"SpotChat", 0, 0, 0, LOGIN_SASL, 0, TRUE}, + {0, "irc.spotchat.org"}, {"StarChat", 0}, {0, "irc.starchat.net"}, - {0, "gainesville.starchat.net"}, - {0, "freebsd.starchat.net"}, - {0, "sunset.starchat.net"}, - {0, "revenge.starchat.net"}, - {0, "tahoma.starchat.net"}, - {0, "neo.starchat.net"}, - {"StaticBox", 0, 0, 0, LOGIN_SASL}, - {0, "irc.staticbox.net"}, - - {"Station51", 0}, -#ifdef USE_OPENSSL - {0, "irc.station51.net/+6697"}, -#endif + {"Station51", 0, 0, 0, 0, 0, TRUE}, {0, "irc.station51.net"}, - {"StormBit", 0, 0, 0, LOGIN_SASL}, -#ifdef USE_OPENSSL - {0, "irc.stormbit.net/+6697"}, -#endif + {"StormBit", 0, 0, 0, LOGIN_SASL, 0, TRUE}, {0, "irc.stormbit.net"}, - {"SwiftIRC", 0}, -#ifdef USE_OPENSSL - {0, "irc.swiftirc.net/+6697"}, -#endif - {0, "irc.swiftirc.net/6667"}, + {"SwiftIRC", 0, 0, 0, 0, 0, TRUE}, + {0, "irc.swiftirc.net"}, - {"synIRC", 0}, -#ifdef USE_OPENSSL - {0, "irc.synirc.net/+6697"}, -#endif - {0, "irc.synirc.net/6667"}, + {"synIRC", 0, 0, 0, 0, 0, TRUE}, + {0, "irc.synirc.net"}, - {"Techman's World IRC", 0, 0, 0, LOGIN_SASL}, -#ifdef USE_OPENSSL - {0, "irc.techmansworld.com/+6697"}, -#endif - {0, "irc.techmansworld.com/6667"}, + {"Techtronix", 0, 0, 0, LOGIN_SASL, 0, TRUE}, + {0, "irc.techtronix.net"}, {"TinyCrab", 0, 0, 0, LOGIN_SASL}, {0, "irc.tinycrab.net"}, @@ -508,16 +344,10 @@ static const struct defaultserver def[] = {"Worldnet", 0}, {0, "irc.worldnet.net"}, - {"Windfyre", 0}, -#ifdef USE_OPENSSL - {0, "irc.windfyre.net/+6697"}, -#endif + {"Windfyre", 0, 0, 0, 0, 0, TRUE}, {0, "irc.windfyre.net"}, - {"Xertion", 0, 0, 0, LOGIN_SASL}, -#ifdef USE_OPENSSL - {0, "irc.xertion.org/+6697"}, -#endif + {"Xertion", 0, 0, 0, LOGIN_SASL, 0, TRUE}, {0, "irc.xertion.org"}, {0,0} @@ -566,9 +396,7 @@ servlist_favchan_copy (favchannel *fav) { favchannel *newfav; - newfav = malloc (sizeof (favchannel)); - memset (newfav, 0, sizeof (favchannel)); - + newfav = g_new (favchannel, 1); newfav->name = g_strdup (fav->name); newfav->key = g_strdup (fav->key); /* g_strdup() can handle NULLs so no need to check it */ @@ -924,9 +752,8 @@ servlist_server_add (ircnet *net, char *name) { ircserver *serv; - serv = malloc (sizeof (ircserver)); - memset (serv, 0, sizeof (ircserver)); - serv->hostname = strdup (name); + serv = g_new (ircserver, 1); + serv->hostname = g_strdup (name); net->servlist = g_slist_append (net->servlist, serv); @@ -938,9 +765,8 @@ servlist_command_add (ircnet *net, char *cmd) { commandentry *entry; - entry = malloc (sizeof (commandentry)); - memset (entry, 0, sizeof (commandentry)); - entry->command = strdup (cmd); + entry = g_new (commandentry, 1); + entry->command = g_strdup (cmd); net->commandlist = g_slist_append (net->commandlist, entry); @@ -952,9 +778,7 @@ servlist_favchan_listadd (GSList *chanlist, char *channel, char *key) { favchannel *chan; - chan = malloc (sizeof (favchannel)); - memset (chan, 0, sizeof (favchannel)); - + chan = g_new (favchannel, 1); chan->name = g_strdup (channel); chan->key = g_strdup (key); chanlist = g_slist_append (chanlist, chan); @@ -990,8 +814,8 @@ servlist_favchan_add (ircnet *net, char *channel) void servlist_server_remove (ircnet *net, ircserver *serv) { - free (serv->hostname); - free (serv); + g_free (serv->hostname); + g_free (serv); net->servlist = g_slist_remove (net->servlist, serv); } @@ -1044,7 +868,7 @@ free_and_clear (char *str) char *orig = str; while (*str) *str++ = 0; - free (orig); + g_free (orig); } } @@ -1072,25 +896,18 @@ servlist_net_remove (ircnet *net) servlist_server_remove_all (net); network_list = g_slist_remove (network_list, net); - if (net->nick) - free (net->nick); - if (net->nick2) - free (net->nick2); - if (net->user) - free (net->user); - if (net->real) - free (net->real); + g_free (net->nick); + g_free (net->nick2); + g_free (net->user); + g_free (net->real); free_and_clear (net->pass); if (net->favchanlist) g_slist_free_full (net->favchanlist, (GDestroyNotify) servlist_favchan_free); if (net->commandlist) g_slist_free_full (net->commandlist, (GDestroyNotify) servlist_command_free); - if (net->comment) - free (net->comment); - if (net->encoding) - free (net->encoding); - free (net->name); - free (net); + g_free (net->encoding); + g_free (net->name); + g_free (net); /* for safety */ list = serv_list; @@ -1110,10 +927,8 @@ servlist_net_add (char *name, char *comment, int prepend) { ircnet *net; - net = malloc (sizeof (ircnet)); - memset (net, 0, sizeof (ircnet)); - net->name = strdup (name); -/* net->comment = strdup (comment);*/ + net = g_new0 (ircnet, 1); + net->name = g_strdup (name); net->flags = FLAG_CYCLE | FLAG_USE_GLOBAL | FLAG_USE_PROXY; if (prepend) @@ -1156,6 +971,10 @@ servlist_load_defaults (void) { servlist_command_add (net, def[i].connectcmd); } + if (def[i].ssl) + { + net->flags |= FLAG_USE_SSL; + } if (g_str_hash (def[i].network) == def_hash) { @@ -1210,25 +1029,25 @@ servlist_load (void) switch (buf[0]) { case 'I': - net->nick = strdup (buf + 2); + net->nick = g_strdup (buf + 2); break; case 'i': - net->nick2 = strdup (buf + 2); + net->nick2 = g_strdup (buf + 2); break; case 'U': - net->user = strdup (buf + 2); + net->user = g_strdup (buf + 2); break; case 'R': - net->real = strdup (buf + 2); + net->real = g_strdup (buf + 2); break; case 'P': - net->pass = strdup (buf + 2); + net->pass = g_strdup (buf + 2); break; case 'L': net->logintype = atoi (buf + 2); break; case 'E': - net->encoding = strdup (buf + 2); + net->encoding = servlist_check_encoding (buf + 2) ? g_strdup (buf + 2) : g_strdup ("UTF-8"); break; case 'F': net->flags = atoi (buf + 2); @@ -1258,7 +1077,7 @@ servlist_load (void) case 'A': if (!net->pass) { - net->pass = strdup (buf + 2); + net->pass = g_strdup (buf + 2); if (!net->logintype) { net->logintype = LOGIN_SASL; @@ -1267,7 +1086,7 @@ servlist_load (void) case 'B': if (!net->pass) { - net->pass = strdup (buf + 2); + net->pass = g_strdup (buf + 2); if (!net->logintype) { net->logintype = LOGIN_NICKSERV; @@ -1302,13 +1121,6 @@ servlist_check_encoding (char *charset) if (c) c[0] = 0; - if (!g_ascii_strcasecmp (charset, "IRC")) /* special case */ - { - if (c) - c[0] = ' '; - return TRUE; - } - gic = g_iconv_open (charset, "UTF-8"); if (c) @@ -1379,8 +1191,7 @@ servlist_save (void) fprintf (fp, "P=%s\n", net->pass); if (net->logintype) fprintf (fp, "L=%d\n", net->logintype); - if (net->encoding && g_ascii_strcasecmp (net->encoding, "System") && - g_ascii_strcasecmp (net->encoding, "System default")) + if (net->encoding) { fprintf (fp, "E=%s\n", net->encoding); if (!servlist_check_encoding (net->encoding)) |