public class Access extends Command
{
private static final Logger log = Logger.getLogger(Access.class.getName());
-
+
public Access()
{
super(1, 4);
|| flags.contains("SRA")
|| flags.indexOf('X') != -1);
}
-
+
private static void updateFlags(final String user, final String flags)
{
User u = User.findUser(user);
if (u != null)
u.setFlags(flags);
}
-
+
private static boolean isValidCertFP(final String certfp)
{
if (certfp.length() != 40)
return false;
-
+
for (char c : certfp.toLowerCase().toCharArray())
/* Not using the Character.* functions because we don't need weird
* locales making weird characters "legal"
*/
if (c < '0' || c > '9' && (c < 'a' || c > 'f'))
return false;
-
+
return true;
}
-
+
/**
* Adds a certfp to the access entry. This function will add a certfp and
* notice the user about it. No effect if the target user has no certfp.
return false;
if (u.getSU().isEmpty()) // redundant with Acidictive; not with access add!
return false;
-
+
try
{
PreparedStatement ps = Acidictive.acidcore_sql.prepare("SELECT `certfp` FROM `access` WHERE `user` = ?");
ps.setString(1, u.getCertFP());
ps.setString(2, u.getSU());
ps.executeUpdate();
-
+
if (notice)
Acidictive.notice(u, "CertFP " + u.getCertFP() + " has been added to your access list.");
}
{
log.log(ex);
}
-
+
return true;
}
-
+
@Override
public void Run(User x, AcidUser to, Channel c, final String[] args)
{
reply(x, to, c, "Invalid arguments: access changecertfp <certfp>\n");
return;
}
-
+
if (!isValidCertFP(args[1]))
{
reply(x, to, c, args[1] + " is an invalid certfp.");
return;
}
-
+
try
{
PreparedStatement stmt = Acidictive.acidcore_sql.prepare("UPDATE `access` SET `certfp` = ? WHERE `user` = ?");
}
reply(x, to, c, "Updated your certfp to \"" + args[1] + "\"");
}
-
+
// add
else if (args[0].equalsIgnoreCase("add"))
{
reply(x, to, c, "Invalid arguments: access add <user> <flag> [certfp]");
return;
}
-
+
if (args.length > 3 && !isValidCertFP(args[3]))
{
reply(x, to, c, args[3] + " is an invalid certfp.");
return;
}
-
+
boolean addedcertfp = (args.length > 3);
User u = User.findUser(args[1]);
String target;
target = u.getSU();
else
target = args[1];
-
+
try
{
PreparedStatement stmt = Acidictive.acidcore_sql.prepare("SELECT * FROM `access` WHERE `user` = ?");
+ (target.equals(args[1]) ? " (as " + rs.getString("user") + ")" : "") + ".");
return;
}
-
+
if (!x.hasFlags("SRA"))
{
reply(x, to, c, "You do not have access to assign +" + args[3] + " access.");
return;
}
-
+
stmt = Acidictive.acidcore_sql.prepare("INSERT INTO `access`(`user`, `flags`, `certfp`) VALUES (?, ?, ?)");
stmt.setString(1, target);
stmt.setString(2, args[2]);
log.log(e);
return;
}
-
+
if (u != null)
addedcertfp = addedcertfp || addCertFP(u, false);
-
+
updateFlags(args[1], args[2]);
reply(x, to, c, "Added \"" + target + "\" with flags "
+ args[2] + (addedcertfp ? " and certfp " + u.getCertFP() : ""));
}
-
+
// del
else if (args[0].equalsIgnoreCase("del"))
{
PreparedStatement stmt = Acidictive.acidcore_sql.prepare("SELECT `flags` FROM `access` WHERE `user` = ?");
stmt.setString(1, args[1]);
ResultSet rs = Acidictive.acidcore_sql.executeQuery(stmt);
-
+
if (!rs.next())
{
reply(x, to, c, "\"" + args[1] + "\" is not on the access list.");
return;
}
-
+
String flags = rs.getString("flags");
-
+
/* Yes, SRAs somehow can't be removed at all. Brilliant, eh?
* Someone slap whoever came up with +1 for me, thanks.
*/
+ "\" because you are not higher than them.");
return;
}
-
+
stmt = Acidictive.acidcore_sql.prepare("DELETE FROM `access` WHERE `user` = ?");
stmt.setString(1, args[1]);
Acidictive.acidcore_sql.executeThread(stmt);
log.log(e);
return;
}
-
+
updateFlags(args[1], "");
reply(x, to, c, "Removed \"" + args[1] + "\" from the access list.");
}
-
+
// list
else if (args[0].equalsIgnoreCase("list"))
{
reply(x, to, c, "This command requires SRA");
return;
}
-
+
try
{
PreparedStatement stmt = Acidictive.acidcore_sql.prepare("SELECT `user`,`certfp`,`flags` FROM `access` ORDER BY `user`");
log.log(e);
}
}
-
+
// setflags
else if (args[0].equalsIgnoreCase("setflags"))
{
reply(x, to, c, "Invalid arguments: access setflags <user> <flags>\n");
return;
}
-
+
String oldflags;
try
{
reply(x, to, c, "The user \"" + args[1] + "\" does not exist.");
return;
}
-
+
oldflags = rs.getString("flags");
-
+
if (isSRA(oldflags))
{
reply(x, to, c, "You do not have access to change the flags for a SRA user.");
return;
}
-
+
stmt = Acidictive.acidcore_sql.prepare("UPDATE `access` SET `flags` = ? WHERE `user` = ?");
stmt.setString(1, args[2]);
stmt.setString(2, args[1]);
log.log(e);
return;
}
-
+
updateFlags(args[1], args[2]);
reply(x, to, c, "Updated flags for \"" + args[1] + "\" from "
+ oldflags + " to " + args[2] + "");
}
-
+
// setcertfp
else if (args[0].equalsIgnoreCase("setcertfp"))
{
reply(x, to, c, "Invalid arguments: access setcertfp <user> <certfp>\n");
return;
}
-
+
if (!isValidCertFP(args[2]))
{
reply(x, to, c, args[2] + " is an invalid certfp.");
return;
}
-
+
try
{
PreparedStatement stmt = Acidictive.acidcore_sql.prepare("SELECT * FROM `access` WHERE `user` = ?");
reply(x, to, c, "The user \"" + args[1] + "\" does not exist.");
return;
}
-
+
String flags = rs.getString("flags"), oldcertfp = rs.getString("certfp");
if (isSRA(flags))
reply(x, to, c, "You can not change the certfp for a SRA user.");
return;
}
-
+
stmt = Acidictive.acidcore_sql.prepare("UPDATE `access` SET `certfp` = ? WHERE `user` = ?");
stmt.setString(1, args[2]);
stmt.setString(2, args[1]);
Acidictive.reply(u, to, c, "\2access setflags <user> <flags>\2 / Change the level of a user beneath you.");
Acidictive.reply(u, to, c, "\2access setcertfp <user> <certfp>\2 / Change the certfp of another user.");
}
-
+
@Override
public boolean onHelpCommand(User u, AcidUser to, Channel c)
{
Acidictive.reply(u, to, c, "in order to do so.");
Acidictive.reply(u, to, c, " ");
Acidictive.reply(u, to, c, "Only SRAs may use the access add and access list commands.");
-
+
return true;
}
}
System.gc();
Acidictive.reply(x, to, c, "Ran gc().");
}
-
+
@Override
public void onHelp(User u, AcidUser to, Channel c)
{
Acidictive.reply(u, to, c, "\2gc\2 / Runs the garbage collector");
}
-
+
@Override
public boolean onHelpCommand(User u, AcidUser to, Channel c)
{
Acidictive.reply(u, to, c, " ");
Acidictive.reply(u, to, c, "This command calls the Java System.gc() function. This will force running");
Acidictive.reply(u, to, c, "the garbage collector and usually free up some memory.");
-
+
return true;
}
}
{
super(0, 1);
}
-
+
@Override
public void Run(User x, AcidUser to, Channel c, final String[] args)
{
Acidictive.reply(x, to, c, "All commands begin with " + Message.BOLD + "/msg " + to.getNick() + Message.BOLD);
Acidictive.reply(x, to, c, "Key: [] indicates an optional field. <> indicates a type " +
"of user input, otherwise it is as stated.");
-
+
int total = 0;
for (net.rizon.acid.conf.Command confCmd : to.getConfCommands())
{
ex.printStackTrace();//XXX
continue;
}
-
+
if (confCmd.privilege == null || !x.hasFlags(confCmd.privilege))
continue;
-
+
++total;
-
+
String cmdName = confCmd.name;
String notice = "\2--== " + cmdName.toUpperCase() + " [" + confCmd.privilege + "] ==--\2";
-
+
if (args.length == 0)
{
Acidictive.reply(x, to, c, notice);
cmd.onHelp(x, to, c);
continue;
}
-
+
if (cmdName.equalsIgnoreCase(args[0]))
{
Acidictive.reply(x, to, c, notice);
return;
}
}
-
+
// If we have an argument and are STILL here, bail.
if (args.length > 0)
{
Acidictive.reply(x, to, c, "Command " + Message.BOLD + args[0] + Message.BOLD + " not found.");
return;
}
-
+
if (total > 0)
Acidictive.reply(x, to, c, "End of help. [" + Message.BOLD + total + Message.BOLD + " commands displayed]");
else
Acidictive.reply(x, to, c, "You do not have access to any commands.");
}
-
+
@Override
public boolean onHelpCommand(User u, AcidUser to, Channel c)
{
Acidictive.reply(u, to, c, " ");
Acidictive.reply(u, to, c, "If a command is given, more verbose information about it will be shown. Note");
Acidictive.reply(u, to, c, "that only commands that are not bound to a channel have help entries.");
-
+
return true;
}
}
Acidictive.reply(u, to, c, p.getName() + " is already loaded.");
return;
}
-
+
try
{
p = Plugin.loadPlugin(args[1]);
{
AcidCore.log.log(Level.WARNING, "Unable to load plugin " + args[1], ex);
Acidictive.reply(u, to, c, "Unable to load plugin " + args[1] + ": " + ex.getMessage());
- }
+ }
}
else if (args[0].equalsIgnoreCase("UNLOAD") && args.length == 2)
{
Acidictive.reply(u, to, c, p.getName() + " is permanent and can not be unloaded.");
return;
}
-
+
p.remove();
-
+
Acidictive.reply(u, to, c, "Unloaded plugin " + p.getName());
AcidCore.log.log(Level.INFO, "PLUGINS UNLOAD for " + p.getName() + " from " + u.getNick());
}
Acidictive.reply(u, to, c, p.getName() + " is permanent and can not be unloaded.");
return;
}
-
+
p.remove();
-
+
try
{
p = Plugin.loadPlugin(args[1]);
{
AcidCore.log.log(Level.WARNING, "Unable to reload plugin " + args[1], ex);
Acidictive.reply(u, to, c, "Unable to reload plugin " + args[1] + ": " + ex.getMessage());
- }
+ }
}
else
Acidictive.reply(u, to, c, "Use LOAD, UNLOAD, RELOAD, or LIST");
}
-
+
@Override
public void onHelp(User u, AcidUser to, Channel c)
{
Acidictive.reply(u, to, c, "\2plugin reload <plugin>\2 / Reloads a plugin");
Acidictive.reply(u, to, c, "\2plugin unload <plugin>\2 / Unloads a plugin");
}
-
+
@Override
public boolean onHelpCommand(User u, AcidUser to, Channel c)
{
{
super(0, 1);
}
-
+
@Override
public void Run(User x, AcidUser to, Channel ch, final String[] args)
- {
+ {
try
{
if (args.length > 0)
p.reload();
return;
}
-
+
Config c = (Config) Config.load("acidictive.yml", Config.class);
c.validate();
Acidictive.conf.rehash(c);
-
+
Acidictive.conf = c;
Acidictive.loadClients(null, c.clients);
Acidictive.loader = new ClassLoader(Acidictive.loaderBase);
"Error reloading configuration: " + e.getMessage());
return;
}
-
+
Acidictive.reply(x, to, ch, "Reloaded configuration");
}
-
+
@Override
public void onHelp(User u, AcidUser to, Channel c)
{
Acidictive.reply(u, to, c, "\2reload\2 / Reloads the configuration");
}
-
+
@Override
public boolean onHelpCommand(User u, AcidUser to, Channel c)
{
User target = User.findUser(args[0]);
if (target == null || !(target instanceof AcidUser) || target == to)
return;
-
+
String reason = args.length > 1 ? args[1] : "";
((AcidUser) target).quit(reason);
}
-
+
@Override
public void onHelp(User u, AcidUser to, Channel c)
{
Acidictive.reply(u, to, c, "\2removeclient <nick> [reason]\2");
}
-
+
@Override
public boolean onHelpCommand(User u, AcidUser to, Channel c)
{
import net.rizon.acid.core.Logger;
import net.rizon.acid.core.Protocol;
import net.rizon.acid.core.User;
-import net.rizon.acid.sql.SQL;
/**
* Shuts acid4 down gracefully.
public class Shutdown extends Command
{
private static final Logger log = Logger.getLogger(Shutdown.class.getName());
-
+
public Shutdown()
{
super(0, 0);
}
-
+
@Override
public void Run(User x, AcidUser to, Channel c, final String[] args)
{
*/
Acidictive.privmsg(Acidictive.conf.getChannelNamed("cmdlogchan"), x.getNick() + "->" + to.getNick() + ": " + "shutdown");
Protocol.wallop(to.getUID(), "SHUTDOWN command from " + x.getNick());
-
+
/* Given DB changes are always written when they occur, all we need to
* flush are our SQL and socket buffers.
*/
Acidictive.acidcore_sql.shutdown();
-
+
for (Iterator<String> it = User.getUsers().iterator(); it.hasNext();)
{
User u = User.findUser(it.next());
if (u == null || u.getServer() != AcidCore.me)
continue;
-
+
/* Fake quit because we can't AcidUser.quit due to concurrent
* modification exceptions.
*/
Protocol.quit(u, "");
}
-
+
// SQUIT our uplink or it won't be all that graceful of a shutdown
Protocol.squit(AcidCore.me, "SHUTDOWN command from " + x.getNick());
-
+
try
{
AcidCore.out.flush();
log.log(e);
System.exit(1);
}
-
+
System.exit(0);
}
-
+
@Override
public void onHelp(User u, AcidUser to, Channel c)
{
Acidictive.reply(u, to, c, "\2shutdown\2 / Shuts everything down");
}
-
+
@Override
public boolean onHelpCommand(User u, AcidUser to, Channel c)
{
{
super(0, 0);
}
-
+
@Override
public void Run(User x, AcidUser to, Channel c, final String[] args)
{
reply(x, to, c, "Current Users: " + User.userCount() + " Identified: " +
UserList.identedNicks() + "; Servers: " + Server.serverCount());
}
-
+
@Override
public void onHelp(User u, AcidUser to, Channel c)
{
Acidictive.reply(u, to, c, "\2stats\2 / Shows miscellaneous info about " + to.getNick());
}
-
+
@Override
public boolean onHelpCommand(User u, AcidUser to, Channel c)
{
{
public String name, channel;
public String blowfish;
-
+
@Override
public void validate() throws ConfigException
{
public String nick, user, host, vhost, name, nspass, modes, version;
public List<String> channels;
public List<Command> commands;
-
+
public Command findCommand(String name)
{
for (Command c : commands)
public String name, privilege;
public List<String> channels;
public String clazz;
-
+
public boolean allowsChannel(String channel)
{
if (channels != null)
return true;
return false;
}
-
+
@Override
public void validate() throws ConfigException
{
package net.rizon.acid.conf;
-import org.yaml.snakeyaml.Yaml;
-import org.yaml.snakeyaml.constructor.CustomClassLoaderConstructor;
-
import java.io.FileInputStream;
import java.io.InputStream;
import java.util.List;
+import org.yaml.snakeyaml.Yaml;
+import org.yaml.snakeyaml.constructor.CustomClassLoaderConstructor;
+
public class Config extends Configuration
{
public boolean debug, protocol_debug;
public List<Channel> channel;
public List<String> plugins;
public List<AccessPreset> access_preset;
-
+
@Override
public void validate() throws ConfigException
{
Validator.validateNotNull("serverinfo", serverinfo);
Validator.validateNotNull("uplink", uplink);
Validator.validateNotNull("general", general);
-
+
serverinfo.validate();
uplink.validate();
general.validate();
-
+
Validator.validateList(database);
Validator.validateList(clients);
Validator.validateList(channel);
}
-
+
public void rehash(Config other)
{
// Rehashing, other = newer config
-
+
other.serverinfo = this.serverinfo;
}
-
+
public String getChannelNamed(String name)
{
for (Channel c : channel)
return name;
return "#a";
}
-
+
public String getCryptoPass(String ch)
{
for (Channel c : channel)
public String command_prefix, email_from, email_smtp, email_securityemail;
public String control;
public String akillserv;
-
+
@Override
public void validate() throws ConfigException
{
public String host, pass;
public int port;
public boolean ssl;
-
+
@Override
public void validate() throws ConfigException
{
for (T t : list)
t.validate();
}
-
+
public static <T> void validateNotNull(String name, T obj) throws ConfigException
{
if (obj == null)
throw new ConfigException(name + " must be defined");
}
-
+
public static void validateNotEmpty(String name, String obj) throws ConfigException
{
validateNotNull(name, obj);
if (obj.isEmpty())
throw new ConfigException(name + " must not be empty");
}
-
+
public static <T extends Collection<?>> void validateNotEmpty(String name, T obj) throws ConfigException
{
validateNotNull(name, obj);
if (obj.isEmpty())
throw new ConfigException(name + " must not be empty");
}
-
+
public static void validateNotZero(String name, int i) throws ConfigException
{
if (i == 0)
throw new ConfigException(name + " must be non zero");
}
-
+
public static void validatePort(String name, int i) throws ConfigException
{
if (i < 0 || i > 65535)
b.write(System.currentTimeMillis() + " " + str + "\n");
b.close();
}
-
+
Timer.processTimers();
log.log(Level.FINEST, "<-: " + str);
User user = null;
Server server = null;
-
+
String source, message_name;
String[] params;
log.log(Level.SEVERE, "Error parsing message: " + str, ex);
continue;
}
-
+
Message m = Message.findMessage(message_name);
if (m == null)
{
log.log(Level.FINE, "Unknown message " + message_name);
continue;
}
-
+
if (user != null)
m.onUser(user, params);
else if (server != null)
m.onServer(server, params);
-
+
m.on(source, params);
}
catch (Exception e)
package net.rizon.acid.core;
-import net.rizon.acid.conf.Client;
-
import java.util.List;
+import net.rizon.acid.conf.Client;
+
public class AcidUser extends User
{
public Plugin pkg;
{
super(nick, user, host, vhost, name, AcidCore.me, AcidCore.getTS(), AcidCore.getTS(), modes, User.generateUID(), "255.255.255.255");
}
-
+
public AcidUser(Plugin pkg, Client c)
{
super(c.nick, c.user, c.host, c.vhost, c.name, AcidCore.me, AcidCore.getTS(), AcidCore.getTS(), c.modes, User.generateUID(), "255.255.255.255");
for (String ch : client.channels)
this.joinChan(Acidictive.conf.getChannelNamed(ch));
}
-
+
public void introduce()
{
Protocol.uid(this);
for (Channel chan : this.getChannels())
Protocol.join(this, chan);
}
-
+
public void joinChan(final String channel)
{
Channel chan = Channel.findChannel(channel);
chan = new Channel(channel, AcidCore.getTS());
chan.setMode('n'); chan.setMode('t');
}
- if (!Acidictive.me.isBursting())
+ if (!AcidCore.me.isBursting())
Protocol.join(this, chan);
chan.addUser(this, "");
this.addChan(chan);
}
-
+
public void partChan(Channel chan)
{
if (!this.isOnChan(chan))
return;
-
+
Protocol.part(this, chan.getName());
chan.removeUser(this);
this.remChan(chan);
}
-
+
public void quit(final String reason)
{
Protocol.quit(this, reason);
this.onQuit();
}
-
+
public final String getNSPass()
{
if (client != null)
else
return null;
}
-
+
public net.rizon.acid.conf.Command findConfCommand(final String name)
{
if (client != null && this.client.commands != null)
return c;
return null;
}
-
+
public List<net.rizon.acid.conf.Command> getConfCommands()
{
return this.client.commands;
package net.rizon.acid.core;
-import net.rizon.acid.conf.Client;
-import net.rizon.acid.conf.Config;
-import net.rizon.acid.sql.SQL;
-import net.rizon.acid.util.Blowfish;
-import net.rizon.acid.util.ClassLoader;
-import net.rizon.acid.util.Util;
-
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.util.List;
import java.util.logging.Level;
+import net.rizon.acid.conf.Client;
+import net.rizon.acid.conf.Config;
+import net.rizon.acid.sql.SQL;
+import net.rizon.acid.util.Blowfish;
+import net.rizon.acid.util.ClassLoader;
+import net.rizon.acid.util.Util;
+
public class Acidictive extends AcidCore
{
private static final Logger log = Logger.getLogger(Acidictive.class.getName());
public static int syncTime;
public static SQL acidcore_sql;
public static String bold = "\ 2";
-
+
public static String loaderBase = "commands";
public static ClassLoader loader; // loader for the core commands
-
+
public static String getVersion()
{
return "acid4 " + Version.getAttribute("revision");
}
AcidCore.start(conf.uplink.host, conf.uplink.port, conf.serverinfo.name, conf.serverinfo.description, conf.uplink.pass, conf.serverinfo.id, conf.uplink.ssl);
-
+
acidcore_sql = SQL.getConnection("acidcore");
if (acidcore_sql == null)
{
log.log(Level.SEVERE, "Unable to get connection for `acidcore`");
System.exit(-1);
}
-
+
loader = new ClassLoader(loaderBase);
if (conf.clients != null)
for (Client c : conf.clients)
User u = User.findUser(s);
if (!(u instanceof AcidUser))
continue;
-
+
((AcidUser) u).introduce();
}
// strip leading "." if needed
String command = (parts[0].startsWith(conf.general.command_prefix) ? parts[0].substring(conf.general.command_prefix.length()) : parts[0]).toLowerCase();
String[] args = Arrays.copyOfRange(parts, 1, parts.length);
-
+
Channel c = null;
AcidUser to = null;
net.rizon.acid.conf.Command confCommand = null;
c = Channel.findChannel(recipient);
if (c == null)
return;
-
+
// lol?
for (String s : c.getUsers())
{
{
AcidUser t = (AcidUser) u;
net.rizon.acid.conf.Command cmd = t.findConfCommand(command);
-
+
if (cmd != null)
{
to = t;
}
}
}
-
+
if (to == null)
return;
}
User targ = User.findUser(recipient);
if (targ == null || !(targ instanceof AcidUser))
return;
-
+
to = (AcidUser) targ;
confCommand = to.findConfCommand(command);
}
-
+
if (confCommand == null)
return;
// by searching the plugin loaders.
Plugin p = to.pkg;
// Use our loader if there is no plugin
- ClassLoader cl = p != null ? p.loader : loader;
+ ClassLoader cl = p != null ? p.loader : loader;
Class<?> commandClass = cl.loadClass(confCommand.clazz);
if (commandClass == null)
return;
-
+
Command cmd = (Command) commandClass.newInstance();
if (recipient.startsWith("#"))
{
return; // Access
}
-
+
// Now that we're in the right channel check for just being logged in OR +o OR spoof
if (x.getIdentNick().isEmpty() && !x.hasMode("o") && !x.getIP().equals("0"))
{
// Commands with no priv can not be executed in PM
return;
}
-
+
// Explicitly requires no privilege
if (confCommand.privilege.equals("none"))
;
try
{
cmd.Run(x, to, c, args);
-
+
/* log SUCCESSFUL privmsg command usages as well
* except help because that's just silly and nobody cares.
*/
public static void onCtcp(String creator, String recipient, String msg)
{
boolean stop = false;
-
+
if (msg.startsWith("\1VERSION"))
{
User u = User.findUser(recipient);
Acidictive.notice(au.getUID(), creator, "\1VERSION " + au.client.version + "\1");
}
}
-
+
for (Event e : Event.getEvents())
{
stop = stop || e.onCTCP(creator, recipient, msg);
for (int i = 0; i < x[0].length(); i++)
{
m = x[0].substring(i, i + 1);
-
+
if (m.equals("+"))
give = true;
else if (m.equals("-"))
chan.setKey(x[whatnick]);
else
chan.setKey(null);
-
+
++whatnick;
-
+
if (give)
chan.setMode(m.charAt(0));
else
}
else
chan.setLimit(0);
-
+
if (give)
chan.setMode(m.charAt(0));
else
}
}
}
-
+
for (Event e : Event.getEvents())
e.onChanModes(creator, chan, modes);
}
-
+
public static void setMode(String source, String target, String modes)
{
Channel c = Channel.findChannel(target);
if (c != null)
onChanMode(source, c, modes);
-
+
Protocol.mode(source, target, modes);
}
{
privmsg(conf.general.control, recipient, message);
}
-
+
public static void privmsg(String source, String target, String message)
{
if (target.startsWith("#"))
{
Protocol.notice(conf.general.control, recipient.getUID(), message);
}
-
+
public static void notice(final String source, final String recipient, final String message)
{
Protocol.notice(source, recipient, message);
else
privmsg(target, msg);
}
-
+
public static void reply(User source, AcidUser to, Channel c, String message)
{
if (c != null)
else
notice(to.getNick(), source.getNick(), message);
}
-
+
public static void loadClients(Plugin pkg, List<Client> clients)
{
for (Client c : clients)
if (u instanceof AcidUser)
{
AcidUser au = (AcidUser) u;
-
+
// update config and plugin
au.client = c;
au.pkg = pkg;
}
continue;
}
-
+
AcidUser au = new AcidUser(pkg, c);
if (syncTime != 0)
au.introduce();
public class Channel
{
private static final Logger log = Logger.getLogger(Channel.class.getName());
-
+
private int ts;
private String channel;
// User list: nick => channel user status modes. TreeMap auto-sorts keys
{
this.ts = ts;
this.channel = channel;
-
+
channelMap.put(channel.toLowerCase(), this);
}
-
+
public void destroy()
{
channelMap.remove(this.channel.toLowerCase());
}
-
+
public Set<String> getUsers()
{
return list.keySet();
{
return channel;
}
-
+
public int getTS()
{
return ts;
}
-
+
public void reset(int ts)
{
log.log(Level.FINE, "Lowering TS of " + channel + " from " + this.ts + " to " + ts);
-
+
this.ts = ts;
for (Membership cm : list.values())
cm.clear();
{
return list.size();
}
-
+
public void setMode(char mode)
{
if (modes.indexOf(mode) == -1)
modes += mode;
}
-
+
public void unsetMode(char mode)
{
modes = modes.replace("" + mode, "");
}
-
+
public boolean hasMode(char mode)
{
return modes.indexOf(mode) != -1;
}
-
+
public String getKey()
{
return key;
}
-
+
public int getLimit()
{
return limit;
}
-
+
public void setKey(String key)
{
this.key = key;
}
-
+
public void setLimit(int limit)
{
this.limit = limit;
}
-
+
public String getModes(boolean full)
{
if (!full)
Acidictive.notice(target, regs.get(i));
Acidictive.notice(target, "Listed " + (owners.size() + admins.size() + ops.size() + hops.size() + voices.size() + regs.size()) + " users that are currently in " + channel);
}
-
+
private static HashMap<String, Channel> channelMap = new HashMap<String, Channel>();
-
+
public static Set<String> getChannels()
{
return channelMap.keySet();
}
-
+
public static Channel findChannel(final String name)
{
return channelMap.get(name.toLowerCase());
package net.rizon.acid.core;
public abstract class Command
-{
+{
private int min;
private int max;
-
+
protected Command(int min, int max)
{
this.min = min;
this.max = max;
}
-
+
public void remove()
{
}
{
return this.min;
}
-
+
public int GetMaxArgs()
{
return this.max;
}
-
+
public abstract void Run(User source, AcidUser to, Channel c, final String[] args);
-
+
// For HELP COMMAND
public boolean onHelpCommand(User u, AcidUser to, Channel c) { return false; }
-
+
// For just HELP
public void onHelp(User u, AcidUser to, Channel c)
{
{
events.add(this);
}
-
+
public void remove()
{
events.remove(this);
}
-
+
public void onUserConnect(final User u) { }
-
+
public void onNickChange(final User u, final String oldnick) { }
-
+
public void onJoin(Channel channel, User[] users) { }
-
+
public void onPart(User user, Channel channel) { }
public void onKick(String kicker, User victim, Channel channel, String reason) { }
-
+
public boolean onPrivmsg(final String creator, final String recipient, final String msg) { return false; }
public void onCommandCertFPMismatch(final User u, final String certfp) { }
-
+
public boolean onNotice(final String creator, final String recipient, final String msg) { return false; }
-
+
public boolean onCTCP(final String creator, final String recipient, final String msg) { return false; }
public void onCTCPReply(User source, String target, String message) { }
-
+
public void onSync() { }
public void onEOB(Server server) { }
-
+
public void onKill(final String killer, User user, final String reason) { }
-
+
public void onQuit(User user, String msg) { }
-
+
public void onServerLink(Server server) { }
-
+
public void onServerDelink(Server server) { }
-
+
public void onUserMode(User user, String oldmodes, String newmodes) { }
public void onChanModes(String prefix, Channel chan, String modes) { }
-
+
public void onRehash() throws Exception { }
-
+
private static LinkedList<Event> events = new LinkedList<Event>();
-
+
public static final Event[] getEvents()
{
Event[] a = new Event[events.size()];
{
private static HashMap<String, Logger> loggers = new HashMap<String, Logger>();
private static final loggerHandler handler = new loggerHandler();
-
+
protected Logger(String name, String resourceBundleName)
{
super(name, resourceBundleName);
Logger l = loggers.get(name);
if (l != null)
return l;
-
+
l = new Logger(name, null);
loggers.put(name, l);
-
+
l.setLevel(Level.ALL);
l.addHandler(handler);
return l;
}
-
+
public void log(Exception ex)
{
this.log(Level.SEVERE, null, ex);
else
this.modes = modes;
}
-
+
public void clear()
{
modes = "";
public abstract class Message
{
public static final char BOLD = 2;
-
+
private static final String messageBase = "net.rizon.acid.messages";
private static final String[] messageClasses = {
"Encap", "EOB", "Error", "Join", "Kick", "Kill", "Mode", "Nick",
"Notice", "Part", "Pass", "Ping", "Privmsg", "Quit", "Server", "SID",
"SJoin", "SQuit", "Stats", "TMode", "UID", "Whois", "Operwall"
};
-
+
static
{
messages = new HashMap<String, Message>();
-
+
try
{
for (String s : messageClasses)
System.exit(-1);
}
}
-
+
protected Message(String name)
- {
+ {
messages.put(name.toUpperCase(), this);
}
-
+
public void onUser(User source, String[] params) { }
public void onServer(Server source, String[] params) { }
public void on(String source, String[] params) { }
-
+
private static HashMap<String, Message> messages;
-
+
public static Message findMessage(String name)
{
return messages.get(name.toUpperCase());
private String name;
private boolean permanent;
public ClassLoader loader; // Loader for this class
-
+
protected Plugin()
{
plugins.add(this);
}
-
+
public void remove()
{
for (User u : User.getUsersC())
{
return permanent;
}
-
+
public String getName()
{
return name;
}
-
+
public abstract void start() throws Exception;
public abstract void stop();
public void reload() throws Exception { }
-
+
public static Plugin loadPlugin(String name) throws Exception
{
Plugin p = findPlugin(name);
if (p != null)
return p;
-
+
String finalName = name.substring(name.lastIndexOf('.') + 1);
ClassLoader cl = new ClassLoader(name, pluginBase + name);
p.start();
return p;
}
-
+
private static LinkedList<Plugin> plugins = new LinkedList<Plugin>();
-
+
public static final Plugin[] getPlugins()
{
Plugin[] a = new Plugin[plugins.size()];
plugins.toArray(a);
return a;
}
-
+
public static Plugin findPlugin(String name)
{
for (Plugin p : plugins)
return p;
return null;
}
-
+
public static Plugin findPluginByClassName(String name)
{
if (!name.startsWith(Plugin.pluginBase))
return null;
-
+
name = name.substring(Plugin.pluginBase.length());
int idx = name.indexOf('.');
if (idx != -1)
name = name.substring(0, idx);
-
+
for (final Plugin p : plugins)
{
if (p.getName().equals(name))
return p;
}
-
+
return null;
}
}
public class Protocol
{
private static final Logger log = Logger.getLogger(Protocol.class.getName());
-
+
private static void privmsgInternal(final String sender, final String recipient, String message)
{
AcidCore.sendln(":" + sender + " PRIVMSG " + recipient + " :" + message);
}
-
+
private static void noticeInternal(final String sender, final String recipient, String message)
{
AcidCore.sendln(":" + sender + " NOTICE " + recipient + " :" + message);
}
-
+
private static void encap(final String server, final String command, final String buffer)
{
- AcidCore.sendln(":" + AcidCore.me.getSID() + " ENCAP " + server + " " + command + " " + buffer);
+ AcidCore.sendln(":" + AcidCore.me.getSID() + " ENCAP " + server + " " + command + " " + buffer);
}
-
+
public static void privmsg(final String source, final String recipient, String msg)
{
String[] split = msg.split("\n");
}
while (s.isEmpty() == false);
}
-
+
public static void notice(final String source, final String recipient, String msg)
{
String[] split = msg.split("\n");
}
while (s.isEmpty() == false);
}
-
+
public static void join(User u, Channel c)
{
if (u.getServer() != AcidCore.me)
log.log(Level.WARNING, "Fake direction for JOIN " + u.getServer().getName() + " <-> " + AcidCore.me.getName());
return;
}
-
+
join(u, "", c);
}
-
+
public static void join(User u, final String status, Channel c)
{
if (u.getServer() != AcidCore.me)
log.log(Level.WARNING, "Fake direction for SJOIN " + u.getServer().getName() + " <-> " + AcidCore.me.getName());
return;
}
-
+
AcidCore.sendln(":" + AcidCore.me.getSID() + " SJOIN " + AcidCore.getTS() + " " + c.getName() + " +" + c.getModes(true) + " :" + status + u.getUID());
}
-
+
public static void part(User u, final String channel)
{
if (u.getServer() != AcidCore.me)
log.log(Level.WARNING, "Fake direction for PART " + u.getServer().getName() + " <-> " + AcidCore.me.getName());
return;
}
-
+
AcidCore.sendln(":" + u.getUID() + " PART " + channel);
}
-
+
public static void quit(User u, final String reason)
{
if (u.getServer() != AcidCore.me)
log.log(Level.WARNING, "Fake direction for QUIT " + u.getServer().getName() + " <-> " + AcidCore.me.getName());
return;
}
-
+
AcidCore.sendln(":" + u.getUID() + " QUIT :" + reason);
}
-
+
public static void kick(User u, final String channel, final String reason)
{
AcidCore.sendln(":" + AcidCore.me.getSID() + " KICK " + channel + " " + u.getUID() + " :" + reason);
// Add kill path or the reason gets broken
AcidCore.sendln(":" + AcidCore.me.getSID() + " KILL " + target + " :" + AcidCore.me.getName() + " (" + reason + ")");
}
-
+
public static void svskill(final String target)
{
encap("*", "SVSKILL", target);
}
-
+
public static void noop(Server s)
{
encap(s.getName(), "SVSNOOP", "+");
}
-
+
public static void unnoop(Server s)
{
encap(s.getName(), "SVSNOOP", "-");
}
-
+
public static void capture(User u)
{
AcidCore.sendln(":" + AcidCore.me.getSID() + " CAPTURE " + u.getUID());
}
-
+
public static void uncapture(User u)
{
AcidCore.sendln(":" + AcidCore.me.getSID() + " UNCAPTURE " + u.getUID());
}
-
+
public static void svsmode(User u, final String modes)
{
encap("*", "SVSMODE", u.getUID() + " " + u.getNickTS() + " " + modes);
}
-
+
public static void chgident(User u, final String host)
{
encap("*", "CHGIDENT", u.getUID() + " " + host);
}
-
+
public static void chghost(User u, final String host)
{
encap("*", "CHGHOST", u.getUID() + " " + host);
}
-
+
public static void svsnick(User u, final String newnick)
{
encap("*", "SVSNICK", u.getUID() + " " + u.getNickTS() + " " + newnick + " " + AcidCore.getTS());
}
-
+
public static void svsjoin(User u, final String channel)
{
encap("*", "SVSJOIN", u.getUID() + " " + channel);
}
-
+
public static void svspart(User u, final String channel)
{
encap("*", "SVSPART", u.getUID() + " " + channel);
}
-
+
public static void resv(String source, Server s, final String what, final String reason)
{
AcidCore.sendln(":" + source + " RESV " + (s != null ? s.getName() : "*") + " " + what + " :" + reason);
{
AcidCore.sendln(":" + source + " UNRESV * " + what);
}
-
+
public static void wallop(final String source, final String what)
{
AcidCore.sendln(":" + source + " OPERWALL :" + what);
}
-
+
public static void kline(final String source, int time, final String user, final String host, final String reason)
{
if (host.replaceAll("[*.?]", "").isEmpty())
return;
- AcidCore.sendln(":" + source + " KLINE * " + time + " " + user + " " + host + " :" + reason);
+ AcidCore.sendln(":" + source + " KLINE * " + time + " " + user + " " + host + " :" + reason);
}
-
+
public static void unkline(final String source, final String user, final String host)
{
AcidCore.sendln(":" + source + " UNKLINE * " + user + " " + host);
}
-
+
public static void mode(final String source, final String target, final String modes)
{
AcidCore.sendln(":" + source + " MODE " + target + " " + modes);
}
-
+
public static void uid(User user)
{
// :99h UID deso 1 1233151144 +Saiowy deso canuck 0 99hAAAAAB 0 canuck :canuck
// :99h UID <nick> <hops> <ts> +<umodes> <user> <vhost> <ip> <uid> <svsts> <realhost> :<geco>
AcidCore.sendln(":" + AcidCore.me.getSID() + " UID " + user.getNick() + " 1 " + AcidCore.getTS() + " +" + user.getModes() + " " + user.getUser() + " " + user.getVhost() + " 0 " + user.getUID() + " 0 " + user.getHost() + " :" + user.getRealName());
}
-
+
public static void sid(Server server)
{
// :geo.rizon.net SID irc.test.net 2 98C :JUPED
AcidCore.sendln(":" + AcidCore.me.getSID() + " SID " + server.getName() + " " + (server.getHops() + 1) + " " + server.getSID() + " :" + server.getDescription());
}
-
- public static void squit(Server server, final String reason)
+
+ public static void squit(Server server, final String reason)
{
AcidCore.sendln(":" + AcidCore.me.getSID() + " SQUIT " + server.getName() + " :" + reason);
}
-
+
public static void eob()
{
AcidCore.sendln(":" + AcidCore.me.getSID() + " EOB");
}
-
+
public static void numeric(int num, final String what)
{
AcidCore.sendln(":" + AcidCore.me.getSID() + " " + num + " " + what);
syncTime = 0;
this.burst = true;
this.SID = SID;
-
+
sidMap.put(SID, this);
serverMap.put(name.toLowerCase(), this);
-
+
log.log(Level.FINE, "New server: " + name + " (SID: " + SID + ") uplinked to " + (hub != null ? hub.getName() : "nothing"));
}
-
+
public void onQuit()
{
sidMap.remove(SID);
{
return users;
}
-
+
public void incUsers()
{
++this.users;
}
-
+
public void decUsers()
{
--this.users;
log.log(Level.WARNING, "User count for " + this.getName() + " managed to drop below 0?");
}
}
-
+
public boolean isBursting()
{
return this.burst;
{
return hops;
}
-
+
public boolean isJupe()
{
return (hub == AcidCore.me || hub.isUlined());
{
return getName();
}
-
+
public void finishBurst()
{
if (this.burst == false)
return;
-
+
this.syncTime = AcidCore.getTS();
this.burst = false;
-
+
for (Iterator<String> it = Server.getServers().iterator(); it.hasNext();)
{
Server serv = Server.findServer(it.next());
-
+
if (serv.getHub() == this)
serv.finishBurst();
}
-
+
// If this server is finished syncing and it is uplinked directoy to me,
// then we are finished syncing
if (this.getHub() == AcidCore.me)
AcidCore.me.finishBurst();
}
-
+
public int getLinkCount()
{
int count = 1;
for (Iterator<String> it = Server.getServers().iterator(); it.hasNext();)
{
Server serv = Server.findServer(it.next());
-
+
if (serv.getHub() == this)
count += serv.getLinkCount();
}
-
+
return count;
}
-
+
public int getRecursiveUsers()
{
int count = this.getUsers();
for (Iterator<String> it = Server.getServers().iterator(); it.hasNext();)
{
Server serv = Server.findServer(it.next());
-
+
if (serv.getHub() == this)
count += serv.getRecursiveUsers();
}
-
+
return count;
}
{
return syncTime;
}
-
+
public boolean isUlined()
{
for (String s : Acidictive.conf.general.ulines)
return true;
return false;
}
-
+
private static HashMap<String, Server> sidMap = new HashMap<String, Server>();
private static HashMap<String, Server> serverMap = new HashMap<String, Server>();
-
+
public static Server findServer(final String name)
{
if (name.length() == 3 && name.indexOf('.') == -1)
return sidMap.get(name);
return serverMap.get(name.toLowerCase());
}
-
+
public static final Set<String> getServers()
{
return serverMap.keySet();
}
-
+
public static final String toName(final String sid)
{
Server s = findServer(sid);
return s.getName();
return sid;
}
-
+
public static int serverCount()
{
return serverMap.size();
}
-
+
public static Server[] sort(String method)
{
class ServerUsersComparator implements Comparator<Server>
Arrays.sort(e, comp);
return e;
}
-
+
public static String format(Server[] servers)
{
StringBuffer buf = new StringBuffer();
this.creation = new Date();
this.tick = new Date(System.currentTimeMillis() + (time_from_now * 1000));
this.time_from_now = time_from_now;
- this.repeating = repeating;
+ this.repeating = repeating;
this.dead = false;
}
-
+
public void start()
{
timers.add(this);
}
-
+
public void stop()
{
this.dead = true;
}
-
+
public abstract void run(final Date now);
-
+
public static void processTimers()
{
Date now = new Date();
for (int i = timers.size(); i > 0; --i)
{
Timer t = timers.get(i - 1);
-
+
if (t.dead == false && now.after(t.tick))
{
try
t.tick = new Date(System.currentTimeMillis() + (t.time_from_now * 1000));
}
}
-
+
for (Iterator<Timer> it = timers.iterator(); it.hasNext();)
{
Timer t = it.next();
-
+
if (t.dead == true)
it.remove();
}
package net.rizon.acid.core;
-import net.rizon.acid.conf.AccessPreset;
-
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Set;
import java.util.logging.Level;
+import net.rizon.acid.conf.AccessPreset;
+
public class User implements Comparable<User>
{
private static final Logger log = Logger.getLogger(User.class.getName());
this.getServer().decUsers();
if (!(this instanceof AcidUser))
UserList.decreaseHost(this.ip);
-
+
uidMap.remove(UID);
nickMap.remove(nick.toLowerCase());
}
{
if (mode.equals("") || mode == null)
return;
-
+
String old = modes;
-
+
boolean plus = true;
String chr;
for (int x = 0; x < mode.length(); x++)
modes = modes.replaceAll(chr, "");
}
}
-
+
for (Event e : Event.getEvents())
e.onUserMode(this, old, modes);
}
{
if (flags.isEmpty())
return false;
-
+
String my_flags = this.flags;
-
+
for (AccessPreset p : Acidictive.conf.access_preset)
{
for (String s : p.name)
flags = flags.replace(s, p.privileges);
}
}
-
+
for (int i = 0; i < flags.length(); ++i)
if (my_flags.indexOf(flags.charAt(i)) == -1)
return false;
-
+
return true;
}
{
return modes;
}
-
+
public String getCertFP()
{
return certfp;
}
-
+
public void setCertFP(String certfp)
{
this.certfp = certfp;
}
-
+
public String getAuthFlags()
{
return authflags;
}
-
+
public void setAuthFlags(String authflags)
{
this.authflags = authflags;
{
return su;
}
-
+
public void setSU(String su)
{
this.su = su;
}
-
+
@Override
public int compareTo(User user)
{
{
return nickMap.size();
}
-
+
private static char[] currentUid = new char[] { 'A', 'A', 'A', 'A', 'A', '@' };
-
+
public static String generateUID()
{
for (int i = 5; i >= 0; --i)
else
currentUid[i] = 'A';
}
-
+
return AcidCore.me.getSID() + new String(currentUid);
}
}
public class UserList
{
private static final Hashtable<String, Integer> ipList = new Hashtable<String, Integer>();
-
+
public static User[] findUsersByHost(String ip)
{
if (ip == null || ip.equalsIgnoreCase(""))
return null;
}
-
+
public static User locateNick(String nick)
{
for (Iterator<String> it = User.getUsers().iterator(); it.hasNext();)
x.clearFlood();
}
}
-
+
public static String globToRegex(String glob)
{
StringBuilder regex = new StringBuilder("^");
}
return regex.append("$").toString();
}
-
+
public static void increaseHost(final String ip)
{
Integer hosts = ipList.get(ip);
else
ipList.put(ip, hosts + 1);
}
-
+
public static void decreaseHost(final String ip)
{
int hosts = ipList.get(ip);
else
ipList.put(ip, hosts - 1);
}
-
+
public static int getUserCountForIP(final String ip)
{
Integer hosts = ipList.get(ip);
{
super("EOB");
}
-
+
// :00C EOB
-
+
@Override
public void onServer(Server server, String[] params)
{
{
super("ENCAP");
}
-
+
@Override
public void onServer(Server source, String[] params)
{
{
super("ERROR");
}
-
+
@Override
public void on(String source, String[] params)
{
{
super("JOIN");
}
-
+
// :4SSAAAATV JOIN 1218474093 #oper +
-
+
@Override
public void onUser(User u, String[] params)
{
package net.rizon.acid.messages;
+import java.util.logging.Level;
+
import net.rizon.acid.core.AcidCore;
import net.rizon.acid.core.Acidictive;
import net.rizon.acid.core.Channel;
import net.rizon.acid.core.Server;
import net.rizon.acid.core.User;
-import java.util.logging.Level;
-
public class Kick extends Message
{
public Kick()
{
super("KICK");
}
-
+
// :99hAAAAAB KICK #geo 99hAAAAAB :Lame and fake
-
+
@Override
public void on(String source, String[] params)
{
{
super("KILL");
}
-
+
// :pdi KILL kenzie :the.hub!staff.rizon.net!pdi!pdi (testing)
-
+
@Override
public void on(String source, String[] params)
{
{
super("MODE");
}
-
+
// :99hAAAAAB MODE 99hAAAAAB :-y
-
+
@Override
public void on(String source, String[] params)
{
{
super("NICK");
}
-
+
// :99hAAAAAB NICK wild :1233188135
-
+
@Override
public void onUser(User u, String[] params)
{
{
super("NOTICE");
}
-
+
// :99hAAAAAB NOTICE moo :BOO !
-
+
@Override
public void onUser(User sender, String[] params)
{
package net.rizon.acid.messages;
-import java.util.logging.Level;
-
-import net.rizon.acid.core.AcidCore;
-import net.rizon.acid.core.Acidictive;
-import net.rizon.acid.core.Channel;
import net.rizon.acid.core.Message;
import net.rizon.acid.core.User;
{
super("OPERWALL");
}
-
+
// :OperServ OPERWALL :USERS: py-ctcp!ctcp@ctcp-scanner.rizon.net is now an IRC operator.
-
+
@Override
public void onUser(User u, String[] params)
{
package net.rizon.acid.messages;
+import java.util.logging.Level;
+
import net.rizon.acid.core.AcidCore;
import net.rizon.acid.core.Acidictive;
import net.rizon.acid.core.Channel;
import net.rizon.acid.core.Message;
import net.rizon.acid.core.User;
-import java.util.logging.Level;
-
public class Part extends Message
{
public Part()
{
super("PART");
}
-
+
// :99hAAAAAB PART #geo
-
+
@Override
public void onUser(User u, String[] params)
{
public class Pass extends Message
{
public static String LinkSID;
-
+
public Pass()
{
super("PASS");
}
-
+
@Override
public void on(String source, String[] params)
{
{
super("PING");
}
-
+
@Override
public void on(String source, String[] params)
{
{
super("PRIVMSG");
}
-
+
// :99hAAAAAB PRIVMSG moo :hi there
-
+
@Override
public void onUser(User sender, String[] params)
{
{
super("QUIT");
}
-
+
// :99hAAAAAA QUIT :Quit: moo
-
+
@Override
public void onUser(User x, String[] params)
{
{
super("SID");
}
-
+
// :8OL SID irc.lolinator.net 6 17C :Rizon Client Server
// :4SS SID services.l2thorn.com 2 00H :Services for L2Thorn IRC Network
// :4SS SID irc.dev.cccp-project.net 2 99S :Communist Bitch ass Monkey whore
-
+
@Override
public void onServer(Server from, String[] params)
{
package net.rizon.acid.messages;
+import java.util.logging.Level;
+
import net.rizon.acid.core.AcidCore;
import net.rizon.acid.core.Acidictive;
import net.rizon.acid.core.Channel;
import net.rizon.acid.core.Server;
import net.rizon.acid.core.User;
-import java.util.logging.Level;
-
public class SJoin extends Message
{
public SJoin()
{
super("SJOIN");
}
-
+
// :4SS SJOIN 1233194735 #c +nt :@4SSAAAATV
// :80C SJOIN 1233634716 #DontJoinItsATrap +npstz :80CAACM7J
// :42C SJOIN 1233634716 #DontJoinItsATrap +mnpstz :
-
+
private static String stripUser(String user)
{
user = user.replaceAll("\\@|\\%", "");
user = user.replaceAll("\\&|\\~", "");
return user;
}
-
+
private static String getModes(String x)
{
String modes = "";
return modes;
}
-
+
@Override
public void onServer(Server source, String[] params)
{
String sts = params[0], channel = params[1], modes = params[2], nicks = params[params.length - 1];
for (int i = 3; i < params.length - 1; ++i)
modes += " " + params[i];
-
+
int ts = Integer.parseInt(sts);
boolean keep_their_modes = true;
{
super("SQUIT");
}
-
+
// SQUIT test.geodns.org :irc.geodns.org
// SQUIT 98C :jupe over
-
+
@Override
public void on(String source, String[] params)
{
{
super("SERVER");
}
-
+
//SERVER rizon.hub 1 :Rizon IRC Network - Client Server
-
+
@Override
public void on(String source, String[] params)
{
package net.rizon.acid.messages;
-import net.rizon.acid.core.Acidictive;
-import net.rizon.acid.core.Message;
-import net.rizon.acid.core.Protocol;
-
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
+import net.rizon.acid.core.AcidCore;
+import net.rizon.acid.core.Acidictive;
+import net.rizon.acid.core.Message;
+import net.rizon.acid.core.Protocol;
+
public class Stats extends Message
{
public Stats()
{
String letter = params[0];
- if (!params[1].equalsIgnoreCase(Acidictive.me.getName()))
+ if (!params[1].equalsIgnoreCase(AcidCore.me.getName()))
{
Protocol.numeric(219, source + " " + letter + " :End of /STATS report");
return;
{
super("TMODE");
}
-
+
// :4SSAAAAWB TMODE 1233718499 #a -sOb blah!*@*
-
+
@Override
public void on(String source, String[] params)
{
Channel chan = Channel.findChannel(params[1]);
if (chan == null)
return;
-
+
int ts;
try
{
ex.printStackTrace();
return;
}
-
+
if (ts > chan.getTS())
return;
modes += " " + params[i];
Acidictive.onChanMode(setter, chan, modes);
-
+
if (chan.size() == 0 && !chan.hasMode('z'))
chan.destroy();
}
{
super("UID");
}
-
+
// :00C UID Adam 1 1317939198 +aiow ~Adam 192.168.1.2 192.168.1.2 00CAAAAAA 0 192.168.1.2 :Adam
// source UID 0-nick 1-hops 2-ts 3-umode 4-username 5-hostname 6-ip 7-uid 8-servicesstamp 9-realhost 10-realname
-
+
@Override
public void onServer(Server source, String[] params)
{
{
super("WHOIS");
}
-
+
// :4SSAAAAXT WHOIS Acidictive :Acidictive
-
+
@Override
public void onUser(User whoiser, String[] params)
{
package net.rizon.acid.sql;
-import net.rizon.acid.conf.Database;
-import net.rizon.acid.core.Acidictive;
-import net.rizon.acid.core.Logger;
-
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.util.LinkedList;
import java.util.logging.Level;
+import net.rizon.acid.conf.Database;
+import net.rizon.acid.core.Acidictive;
+import net.rizon.acid.core.Logger;
+
public class SQL extends Thread
{
private static final Logger log = Logger.getLogger(SQL.class.getName());
return this.pendingQueries.size();
}
}
-
+
public void setAutoCommit(boolean state) throws SQLException
{
this.con.setAutoCommit(state);
lastWarn = now;
}
}
-
+
public static SQL getConnection(final String name)
{
SQL sql = null;
-
+
try
{
for (Database d : Acidictive.conf.database)
{
if (!d.name.equals(name))
continue;
-
+
return sql = new SQL(d.host, d.user, d.pass);
}
}
{
throw new RuntimeException(e.getMessage());
}
-
+
return sql;
}
}
{
private static final Logger log = Logger.getLogger(ClassLoader.class.getName());
private String plugin;
-
+
public ClassLoader(String plugin, String classname)
{
super(new URL[0]);
File jar = null;
this.plugin = plugin;
-
+
if (plugin != null)
{
String pluginPath = plugin.replaceAll("\\.", "/");
{
return loadClassRecurse(name, true);
}
-
+
private Class<?> loadClassRecurse(String name, boolean recurse) throws ClassNotFoundException
{
try
catch (ClassNotFoundException ex2)
{
}
-
+
throw ex;
}
}
public class EMail
{
private static final Logger log = Logger.getLogger(EMail.class.getName());
-
+
public EMail(String to, String subject, String msg)
{
Properties mailprops = new Properties();
mailprops.put("mail.smtp.host", Acidictive.conf.general.email_smtp);
if (Acidictive.conf.debug)
mailprops.put("mail.debug", "true");
-
+
Session session = Session.getInstance(mailprops);
-
+
try
{
Message m = new MimeMessage(session);
return false;
}
}
-
+
public static int getSeconds(String time) throws NumberFormatException
{
}
return rtime;
}
-
+
public static String fTime(int seconds)
{
int weeks = seconds / 604800;
}
return str.toString();
}
-
+
public static String safeRegex(String str)
{
String sr = "";
}
return sr;
}
-
+
public static String randomString(int length)
{
Random rand = new Random();
}
private static String randChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
-
+
public static String formatTime(int seconds)
{
int weeks = seconds / 604800;
package net.rizon.acid.plugins.pyva.core;
import net.rizon.acid.core.Plugin;
-import net.rizon.acid.util.ClassLoader;
public class core extends Plugin
{
{
super(0, 0);
}
-
+
@Override
public void Run(User x, AcidUser to, Channel c, final String[] args)
{
public class Plugins extends Command
{
private static final Logger log = Logger.getLogger(Plugins.class.getName());
-
+
public Plugins()
{
super(1, 2);
log.log(Level.WARNING, "Unable to get current plugins", e);
return;
}
-
+
if (args[0].equalsIgnoreCase("LIST"))
{
for (String s : loaded)
Acidictive.reply(u, to, c, s + " is already loaded.");
return;
}
-
+
try
{
pyva.loadPyvaPlugin(args[1]);
for (String s : loaded)
if (s.equalsIgnoreCase(args[1]))
found = true;
-
+
if (!found)
{
Acidictive.reply(u, to, c, args[1] + " is not loaded");
return;
}
-
+
try
{
pyva.unloadPyvaPlugin(args[1]);
package net.rizon.acid.plugins.pyva.pyva;
+import java.util.Arrays;
+import java.util.Date;
+import java.util.logging.Level;
+
import net.rizon.acid.core.Acidictive;
import net.rizon.acid.core.Channel;
import net.rizon.acid.core.Event;
import net.rizon.pyva.Pyva;
import net.rizon.pyva.PyvaException;
-import java.util.Arrays;
-import java.util.Date;
-import java.util.logging.Level;
-
class PyvaEvent extends Event
{
@Override
{
this.call("onUserConnect", u);
}
-
+
@Override
public void onJoin(Channel channel, final User[] users)
{
for (User u : users)
this.call("onJoin", u, channel.getName());
}
-
+
@Override
public void onPart(User user, Channel channel)
{
{
this.call("onQuit", user, msg);
}
-
+
@Override
public boolean onPrivmsg(String creator, String recipient, final String msg)
{
this.call("onPrivmsg", creator, recipient, msg);
return false;
}
-
+
@Override
public boolean onNotice(String creator, String recipient, final String msg)
{
this.call("onNotice", creator, recipient, msg);
return false;
}
-
+
@Override
public boolean onCTCP(final String creator, final String recipient, final String msg)
{
{
this.call("onChanModes", prefix, chan.getName(), modes);
}
-
+
private void call(String name, Object... params)
{
try
public static Pyva pyva;
private Event e;
-
+
@Override
public void start() throws Exception
{
reload();
pyva = new Pyva();
-
+
for (String path : conf.path)
pyva.addToSystemPath(path);
pyva.init();
e = new PyvaEvent();
-
+
for (String plugin : conf.plugins)
loadPyvaPlugin(plugin);
-
+
t = new GCTimer();
t.start();
}
public void stop()
{
t.stop();
-
+
e.remove();
-
+
try
{
for (String plugin : conf.plugins)
public void reload() throws Exception
{
conf = (Config) net.rizon.acid.conf.Config.load("pyva.yml", Config.class);
-
+
Acidictive.loadClients(this, conf.clients);
}
-
+
public static void loadPyvaPlugin(String name) throws PyvaException
{
pyva.invoke("plugin", "loadPlugin", name);
String[] stringArray = Arrays.copyOf(obj, obj.length, String[].class);
return stringArray;
}
-
+
public static void call(String name, Object... args) throws PyvaException
{
Object[] object = new Object[args.length + 1];
package net.rizon.acid.plugins.trapbot;
-import net.rizon.acid.core.Timer;
-
import java.util.Date;
import java.util.Iterator;
import java.util.Map;
+import net.rizon.acid.core.Timer;
+
class ExpireTimer extends Timer
{
ExpireTimer()
package net.rizon.acid.plugins.trapbot;
+import java.util.Date;
+import java.util.Random;
+
import net.rizon.acid.core.Message;
import net.rizon.acid.core.Protocol;
import net.rizon.acid.core.Timer;
-import java.util.Date;
-import java.util.Random;
-
class ReleaseTimer extends Timer
{
ReleaseTimer()
package net.rizon.acid.plugins.trapbot;
+import java.util.Date;
+
import net.rizon.acid.core.Message;
import net.rizon.acid.core.Protocol;
import net.rizon.acid.core.Timer;
-import java.util.Date;
-
class RetrapTimer extends Timer
{
RetrapTimer(long time_from_now, boolean repeating)
package net.rizon.acid.plugins.trapbot.commands;
+import net.rizon.acid.core.AcidCore;
import net.rizon.acid.core.AcidUser;
import net.rizon.acid.core.Acidictive;
import net.rizon.acid.core.Channel;
{
User u = User.findUser(args[0]);
- if (u == null || u.getServer() == Acidictive.me || u.getServer().isUlined())
+ if (u == null || u.getServer() == AcidCore.me || u.getServer().isUlined())
{
Acidictive.reply(x, to, c, "Cannot find user \2" + args[0] + "\2.");
return;
package net.rizon.acid.plugins.trapbot.conf;
+import java.util.List;
+
import net.rizon.acid.conf.Client;
import net.rizon.acid.conf.ConfigException;
import net.rizon.acid.conf.Configuration;
-import java.util.List;
-
public class Config extends Configuration
{
public List<Client> clients;
package net.rizon.acid.plugins.trapbot;
+import java.util.HashMap;
+
+import net.rizon.acid.core.AcidCore;
import net.rizon.acid.core.AcidUser;
import net.rizon.acid.core.Acidictive;
import net.rizon.acid.core.Event;
import net.rizon.acid.core.User;
import net.rizon.acid.plugins.trapbot.conf.Config;
-import java.util.HashMap;
-
public class trapbot extends Plugin
{
protected static final Logger log = Logger.getLogger(trapbot.class.getName());
public static void updateTrap(User u)
{
- if (u.getServer() == Acidictive.me || u.getServer().isUlined())
+ if (u.getServer() == AcidCore.me || u.getServer().isUlined())
return;
/* ignore spoofed users */