Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - Chavo

Pages: 1 [2]
16
General Security Information / SMF Security
« on: January 19, 2007, 05:54:41 pm »
A friend of mine was having problems with someone hacking his IPB installation for an online community with a large user base.  He didn't have the money to upgrade to the newest version of IPB so I suggested SMF.

Any SMF veterans have any tips for securing SMF for a large user base?  I'm looking at you iago and Sidoh.

17
I'm helping a friend improve the way he is running an e-sports league (currently ~600 members).  One of the things that is in major need of improvement is the method of determining rating changes after a game.  I can't go into too much detail because I've been asked to keep specifics on a need-to-know basis.

If anyone would like to work on this with me, my statistics knowledge is limited enough that I need help with this :)  Basically it would involve writing a new rating system from the ground up that meets a number of qualifications and then rigorous testing of a number of circumstances where the existing system has flaws.

FYI: I've already employed the help of a real-life friend who is a Stats major, but his time is limited (the fool is quadruple majoring and hes in his final year).  He will however, be able to easily check up on any algorithms devised to make sure they make mathematical sense.

18
Trash Can / test
« on: October 17, 2006, 10:16:30 am »
test

19
General Programming / [java] Rolling (Shared) Queue
« on: October 14, 2006, 02:52:09 pm »
So apparently I'm one of those strange people that still has a legitimate reason to do battle.net related programming.

I wrote my own bot with some very unique core features.  One of the biggest features is the ability to handle multiple connections to battle.net inside one process.  This lets me send outgoing messages on a 'rolling' or shared system.

For example, in any bot that I know of, if you wanted to send 10 long messages, it would probably take you a while to avoid flooding off.  However, with a rolling Queue setup, you can divide those messages over a number of connections so that they are displayed much faster while still avoiding flooding off.

I've written, tested, debugged, and racked my brian for improvements on the code I'm using and it works pretty well.  However, sometimes it will display messages in the wrong order (for example, if I enqueue'd messages 1,2,3,4,5,6,7,8,9,10 it might display them as 1,2,3,4,5,7,8.6,10,9).  The more messages in the queue(s), the more likely they will be displayed out of order. 

iago, this is the code that I was talking to you about a while back that we both forgot I still wanted help with :)

I'm looking for any ideas or suggestions to help elliminate the problem or any insight to why it is occuring because I've tried to anticipate and prevent it in my code. Without further ado:

Queue.java
Code: [Select]
package connect;

import java.util.Timer;
import java.util.TimerTask;
import java.util.PriorityQueue;

import util.BNetPacket;
import util.QueuePacket;

/***
* Queue manages timing of outgoing data for a given PacketThread connection.
* Numbers and algorithm for computing proper delays inspired by iago's JavaOp2 code (www.javaop.com)
*
*@author unTactical
*/
public class Queue {

private final PriorityQueue<QueuePacket> queue = new PriorityQueue<QueuePacket>();
private final Timer timer = new Timer();

private TimerTask current;
private PacketThread conn;
    private boolean queueReady = true;
    private boolean enabled = false;
    private long lastSent = System.currentTimeMillis();

//TODO: make these customizable
    int packetCost = 250;
    int byteCost = 17;
    int byteOverThresholdCost = 17;
    int thresholdBytes = 65;
    int maxCredits = 800;
    int creditRate = 5;
    int credits = 800;   
   
    public Queue(PacketThread connection)
    {
    conn = connection;
    }
   
    public Queue(String DONOTUSESTHIS_FORTESTINGONLY) // for testing with QueueManager main function
    {
    }
   
    /** Supports disabling of the queue temporarily (useful for faster logon)
     *
     * @param status - enable/disable
     */
    public void enable(boolean status)
    {
    enabled = status;
    }
   
    /** Clear the queue if it gets too full  */
    public synchronized void clear()
    {
    queue.clear();
    }
   
    /** Primary function of Queue, schedules a packet to be sent, ordered by Priority and time scheduled
     *
     * @param data - packet to send to battle.net
     * @param priority - higher means it will be sent sooner
     */
    public synchronized void send(BNetPacket data, int priority)
    {
    QueuePacket q = new QueuePacket(data,priority);
    queue.add(q);
    if(queueReady)
    {
    long delay = getDelay(data.getBytes());
    timer.schedule(new QueueTask(),delay);
    queueReady = false;
    }
    }
   
    /** Tells us if this Queue is ready to send a message immediately or if it will have to be scheduled
     *
     * @return true if message can be sent immediately, false if we must schedule it
     */
    public synchronized boolean isReady()
    {
    return queueReady;
    }
   
    /** Lets us predict how long it will be before a new message can be sent based on this queue's status.
     * This is the core function that allows us to use a rolling queue system.
     *
     * @param priority - only consider packets in the queue matching or exceeding a given priority
     * @return amount to wait
     */
    public synchronized long getWait(int priority)
    {
    QueuePacket qpacket;
    updateCredits();
    int wait = credits;
   
    if(queue.size() > 0)
    {
    Object[] elements = queue.toArray();
    int tempCredits = credits;
    for(int i=0;i<elements.length;i++)
    {
    qpacket = (QueuePacket) elements[i];
    if(qpacket.getPriority() >= priority)
    getDelay(qpacket.getData().getBytes());
    }
    wait = credits;
    credits = tempCredits;
    }
   
    return wait;
    }
   
    /** Does the math for figuring out how long to wait after a message is sent
     * If you call this method, it adjusts the queue's status so if you don't really want to send the message,
     * make sure you return credits to its previous value.
     * I borrowed and tweaked this from iago's code.
     *
     * @param bytes - the longer the message, the more we need to wait.  This could be replaced with a length variable
     * @return time to wait after sending a message of length specified
     */
    private long getDelay(byte[] bytes)
    {   
    if(!enabled)
    return 0;
   
    // Add the credits for the elapsed time
    updateCredits();
        lastSent = System.currentTimeMillis();

        // Get the packet's "cost"
        int thisByteDelay = byteCost;       
        if(bytes.length > thresholdBytes)
            byteCost = byteOverThresholdCost;
        int thisPacketCost = packetCost + (thisByteDelay * bytes.length);

        // Check how long this packet will have to wait
        int requiredDelay = 0;
        // If we can't "afford" the packet, figure out how much time we'll have to wait
        if(credits < 0)
            requiredDelay = -credits * creditRate;

        // Deduct this packet from the credits
        credits -= thisPacketCost;
        return requiredDelay;
    }
   
    /** Since credits doesn't change on its own, we need a way to ensure its status is correct
     * when determining wait time.
     */
    private void updateCredits()
    {
        if(credits < maxCredits)
        {
            credits += (System.currentTimeMillis() - lastSent) / creditRate;
           
            if(credits > maxCredits)
                credits = maxCredits;
        }       
    }
   
    /** Waits after a message is sent and sends the next message in line, then schedules the next wait
     * If there is no next message to send, it sets the queue to a 'ready' status.
     *
     * @author unTactical
     */
    private class QueueTask extends TimerTask
    {
    QueuePacket data;   
   
    public void run()
        {
        if(!queue.isEmpty())
        {
        // send the message and schedule the next one
        data = queue.remove();
        byte[] tosend = data.getData().getBytes();
        conn.send(tosend);
        long delay = getDelay(tosend);
        timer.schedule(current = new QueueTask(),delay);

        queueReady = false;
        }
        else
        queueReady = true;
        }
    }
}

QueueManager.java
Code: [Select]
package _main;

import java.util.HashMap;

import events.OutChatCommand;
import connect.Queue;
import plugins.Logger;
import util.BNetPacket;

/** Central point for all outgoing data to battle.net
 *  - IndividalQueueArray: add to a specific bot
 *  - AllQueueArray: add to all bots
 *  - OpOnlyArray: add to the most available bot with ops
 *  - NonOpArray: add to the most available both without ops
 *
 * @author unTactical
 */
public class QueueManager {

private static HashMap <String, Queue> all = new HashMap<String, Queue>();
private static HashMap <String, Queue> ops = new HashMap<String, Queue>();
private static HashMap <String, Queue> nonops = new HashMap<String, Queue>();

private QueueManager() {}

/** Lets us disable flood protection for a given Queue so that messages are sent immediately
*
* @param id - the name of the queue to enable/disable
* @param status - true to enable flood protection, false to disable
*/
public static void enable(String id, boolean status)
{
all.get(id).enable(status);
}

/** Add a Queue to the Manager
*
* @param id - name of the Queue
* @param q - Queue to manage
* @param hasOps - whether this bot handles 'operator' or non 'operator' messages by default
*/
public synchronized static void addQueue(String id, Queue q, boolean hasOps)
{
all.put(id,q);
if(hasOps)
ops.put(id,q);
else
nonops.put(id, q);
}

/** Remove a queue no longer in use
* This usually happens when we reset a connection.
*
* @param id - name of the Queue to remove
*/
public synchronized static void removeQueue(String id)
{
all.remove(id);
ops.remove(id);
nonops.remove(id);
}

/** Allows us to change whether a given Queue handles ops or non ops messages
*
* @param id - name of the Queue
* @param hasOps - true to handle 'operator' messages, false to handle non 'operator' messages by default
*/
public synchronized static void updateOps(String id, boolean hasOps)
{
if(hasOps)
{
nonops.remove(id);
if(!ops.containsKey(id))
ops.put(id, all.get(id));
}
else
{
ops.remove(id);
if(!nonops.containsKey(id))
nonops.put(id, all.get(id));
}
}

/** Allows us to change whether a given Queue handles ops or non ops messages
*
* @param id - int ID of the Queue to be looked up
* @param hasOps - true to handle 'operator' messages, false to handle non 'operator' messages by default
*/
public synchronized static void updateOps(int id, boolean hasOps)
{
updateOps(ConnectionManager.getInstance().getConnection(id).getName(), hasOps);
}

/** Remove all Queues
* Usually done when there is a connection error and all Queues must be reset
*/
public static void clearAll()
{
Object[] queues = all.values().toArray();
for(int i=0;i<queues.length;i++)
{
((Queue) queues[i]).clear();
}
}

/** Sends a message on all Queues in this Manager
*
* @param data - packet to send to battle.net
* @param priority - order in line, greatest first
*/
public static void sendAll(BNetPacket data, int priority)
{
Object[] queues = all.values().toArray();
for(int i=0;i<queues.length;i++)
{
((Queue) queues[i]).send(data,priority);
}
}

/** Send a message on a specific Queue
* Primarily done when a packet must be returned on the same Queue it was received (ie logon)
*
* @param data - packet to send to battle.net
* @param priority - order in line, greatest first
* @param id - name of the Queue we want to send the packet on
*/
public static void sendByName(BNetPacket data, int priority, String id)
{
Queue sender = all.get(id);
if(sender != null)
sender.send(data, priority);
else
Logger.logConsoleText("Sender id " + id + " is null!");
}

/** Send a message on a specific Queue
* Primarily done when a packet must be returned on the same Queue it was received (ie logon)
*
* @param data - packet to send to battle.net
* @param priority - order in line, greatest first
* @param id - int ID of the Queue to lookup
*/
public static void sendByID(BNetPacket data, int priority, int ID)
{
sendByName(data, priority, ConnectionManager.getInstance().getConnection(ID).getName());
}

/** Send a non 'operator' message. 
* The message will be sent on the first queue that is ready. If no queue is ready, it is added to the Queue
* that will be ready to send it soonest
*
* @param data - packet to send to battle.net
* @param priority - order in line, greatest first
*/
public static void sendOps(BNetPacket data, int priority)
{
Object[] queues = ops.values().toArray();
sendSpecified(queues,data,priority);
}

/** Send an 'operator' message.
* The message will be sent on the first queue that is ready. If no queue is ready, it is added to the Queue
* that will be ready to send it soonest
*
* @param data - packet to send to battle.net
* @param priority - order in line, greatest first
*/
public static void sendNonOps(BNetPacket data, int priority)
{
Object[] queues;
if(!nonops.isEmpty())
queues = nonops.values().toArray();
else
queues = ops.values().toArray(); // If there is no non-ops Queue available, it will be sent on an op Queue instead.

sendSpecified(queues,data,priority);
}

/** Checks all of the Queues availability and chooses (ideally) the first Queue that is ready to send the message.
* If no Queue is ready, it determines which Queue will be ready to send the message soonest and adds it to that one.
* (Ideally)
*
* @param queues - spefies whether we are checking the Ops Queue or the NonOps Queue
* @param data - packet to send to battle.net
* @param priority - a message of a higher priority is sent before messages of lower priority, so only check those relevant
*/
private static synchronized void sendSpecified(Object[] queues, BNetPacket data, int priority)
{
long highCredits = -999999;
int lowID = -1;
Queue current;

for(int i=0;i<queues.length;i++)
{
current = ((Queue) queues[i]);
long thisWait = current.getWait(priority);

if(thisWait == 800)
{
current.send(data, priority);
try {Thread.sleep(500); } catch(Exception e) {};
return;
}
else if(thisWait > highCredits)
{
highCredits = thisWait;
lowID = i;
}
}

if(lowID == -1) // this will happen if the queue is empty (ie a op message is requested but no op queue exists)
Logger.logConsoleText("Message not sent! lowID invalid!!");
else
((Queue) queues[lowID]).send(data, priority);

try {Thread.sleep(500); } catch(Exception e) {}; // wait a short time to account for non-0 travel time across internet
}

public static void main(String[] args)
{
addQueue("zero",new Queue(""),false);
addQueue("one",new Queue(""),false);
System.out.println("test1");
sendNonOps(new OutChatCommand(-1,"test1").getBNetPacket(),0);
System.out.println("test2");
sendNonOps(new OutChatCommand(-1,"test2").getBNetPacket(),0);
System.out.println("test3");
sendNonOps(new OutChatCommand(-1,"test3").getBNetPacket(),0);
System.out.println("test4");
sendNonOps(new OutChatCommand(-1,"test4").getBNetPacket(),0);
System.out.println("test5");
sendNonOps(new OutChatCommand(-1,"test5").getBNetPacket(),0);
System.out.println("test6");
sendNonOps(new OutChatCommand(-1,"test6").getBNetPacket(),0);
System.out.println("test7");
sendNonOps(new OutChatCommand(-1,"test7").getBNetPacket(),0);
System.out.println("test8");
sendNonOps(new OutChatCommand(-1,"test8").getBNetPacket(),0);
System.out.println("test9");
sendNonOps(new OutChatCommand(-1,"test9").getBNetPacket(),0);
System.out.println("test10");
sendNonOps(new OutChatCommand(-1,"test10").getBNetPacket(),0);
}
}

20
AntiVirus' Home for Lost Toys / Rolla!
« on: September 14, 2006, 12:59:56 am »
Tell me about it!  As you know I almost went there myself, so while I know everything they tell you to recruit you, I don't have the advantage of the perspective of a new student.  Since I'm still considering it for my graduate degree, what do you think?

Teachers:  understandable? ta's speak (real) english? do they go too fast? too slow?

Curriculum: How hard does it look to be? Are the curriculums pretty generic or well thought out and specialized for each major?  Do you actually learn anything in the classes (might not apply as a freshman :))

Campus Life:  How does the atmosphere feel in general, is the Student Union actively providing lots of fun activities? Interesting lectures/visitors? Campus sponsored events? Are the clubs generally too crowded/vacant?

Partying: mostly bar atmosphere? house parties? greek-oriented?

Just wondering :)

21
General Programming / [Java] Efficiency/best practice dilemna
« on: July 24, 2006, 12:03:47 pm »
The code in question is kinda in-between a couple versions I am playing around with, so I won't bother posting all of it since it won't help ;)

I have a class called EventManager which basically receives a generic Event, iterates through a list of EventHandlers for that specific Event and calls a dispath() method on each of those Handlers.

dispatch utilizes Reflection in order to call a method by name that wants to handle the raised Event.  Let me know if I've lost you yet ;)

All of the above works fine.  Now for the 'dilemna' (I wouldn't call it a problem, just a matter of deciding which solution is better).

A class that wants to handle a raised event can have any name it wants, but it must accept the type of arguments that dispatch() specifies.  Since there are a number of events, dispatch() calls the handling object's method and passes a generic superclass.  The handling method must then cast to a sub-class if they want to access the sub-class data.  I find this less than pretty and somewhat error prone.

The alternative is to write seperate dispatch() methods for every single Event type (there are a lot) so that the parent class does not have to be the argument.  This makes it safer/easier for the handling methods, but significantly sloppier looking with all the dispatch methods (and very redundant code).

There is a third option.  One dispatch method could be written accepting the parent class.  The dispatch method could then switch on the type of event and call the handling event with the proper child class.  The problem I see with this approach is that you are switching and casting multiple times for the same object because dispatch will be called multiple times for a single event if there are multiple handlers for that event.

Thoughts?  Am I being too vague?

22
General Discussion / Forum name!
« on: June 28, 2006, 03:41:45 pm »
Vote!  Other options welcome, but they should probably include a reference to HGTTG, DotA, Kansas, Monty Python, or a word that just sounds cool.

For those of you that don't know what Lamuella is:
Quote from: wiki
Lamuella is the planet on which Arthur Dent lives and works as The Sandwich Maker at the start of Mostly Harmless. The planet is mostly made up of villages, but intersects a plural zone, allowing for teleportation to the Domain of the King. The primary species of the planet are humanoids, Perfectly Normal Beasts and pikka birds. The residents of Lamuella worship a deity by the name of Almighty Bob.

To Arthur (hgttg reference), its as close to Paradise as he can find.

The other references:
War-Room - should be fairly obvious, fits the unTactical name better than the others imo even if its not catchy
Land of Oz - I'm closer to Oz than any other clan member and have been on the yellow brick road :O
chasm - no idea, sounded good though

23
I'd like to join! / Accept me into your brotherhood
« on: June 10, 2006, 01:19:33 pm »
Howdy, I think you all know who I am and if not, thats..uh...your fault.

When I first happened upon x86, it was to find out more about JavaOp.  Since then I've been attached like a magnet to x86 news, debates and discussions.

I feel I often offer a unique point of view in many of these topics and contribute whenever I think it is relevant.  I am not a forum junkie (well, apart from my own website ;)) but the x86 community is the first place I've found where the vast majority of discussions are actually intelligent and flame/moron/i33tspeak free.  I've enjoyed healthy debate since I was in high school and this is a great place to do so.  While I have lots of real life friends, there are many topics that I cannot discuss with them simply because they do not share certain intrusts with me.  Not so in x86! With the exception of DotA and WoW (you are all noobs, I swear), virtually all of my interests are shared with some of the members of x86.  The more time I spend here, the more I feel I belong. 

Don't tell me I slept with deadly's mom for nothing! ;)

All joking asside, I have no alterior motive for getting into x86, I believe I belong.  What say you?

iago, I'll tell you the other word if you approve me :)

24
Entertainment District / The Ultimate Showdown
« on: February 04, 2006, 07:54:44 pm »
absolutely hilarious, I watched it three times in a row and then once more with subtitles

http://www.newgrounds.com/portal/view/285267

25
General Programming / Theory question
« on: February 02, 2006, 12:15:11 pm »
I hate doing things the hard way, but in this case I have not been able to think of an alternative yet.

-I have a finite, positive number of integers (in most cases between 3 and 20)
-I want to split the integers into two groups such that their sums are as equal as possible (easy)
-One group must not have a size greater than the other group + 1 (they must be of equal size when there is an even number of elements and as close as possible in size when there is an odd number of elements)

now the part that I'm having trouble with:

-I want to find the top X combinations of groupings with the closest total sums (not just the top 1)

Obviously, I need calculate the sums for every possible combination, but I'm having trouble figuring out an efficient way to do this. Any ideas on a strategy to approach this or a recommended data structure?

My initial thought was an ordered binary tree, but now I think that would just make it more difficult than it needs to be.

26
Introductions! / Howdy
« on: December 05, 2005, 05:23:32 pm »
Newby/iago, I must say you have come up with an intereseting introduction format :)

I'm unTactical, aka daryll, aka criz8426.  My real name is Chris. I am 21 and I'll give you a cookie if you can figure out what day of the month I was born on.

I'm from the exciting land known as Kansas where I go to school and work (I work for the university doing tech support)

I'm a big fan of Revis, Green Day, Seether, Crossfade, Metallica, and Copus (if any of you have ever heard of Copus, I'll give you a whole plate full of cookies).  That said, I'll listen to pretty much anything except "depressive" country type music (upbeat country is fine).

I have a girlfriend of just over 3 years and a damn good one if I do say so myself.

I'm a co-chieftan of clan tactical on azeroth (wc3 dota clan, channel clan hiim).  There is a long and semi-interesting story about hiim for anyone that cares  ;)  Most of us are pretty good friends and we focus more on having fun than anything else.

The only person from x86 that I know previously is deadly7, although I have had the pleasure of seeing other members' works.

I'd like to get to know x86 because they seem like a bunch of froods that really know where their respective towels are at.

Rules? what rules?  /ducks (yes, I read them)

I don't watch too terribly much tv apart from Football, but I am a big fan of That 70's Show

Favorite movie is by far Boondock Saints (where are you sequel!?!)

Favorite country is UK because I love the freakin accent, continent: er.....australia....they have kangaroos! season is definately winter, can't get enough snow.

My major is computer engineering with a minor in computer science (I would double major if it wouldnt require me to take ~80 more credit hours).  My favorite class thus far (I'm a junior) was Microcontroller assembly (we worked with Motorolla chips, fun stuff).

Favorite chemical:

Favorite food is my grandma's applie pie....mmmm mmmm good, Pepsi is my favorite soda but my favorite drink is up in the air right now as I try to decide which beer I like best  ;D

Douglas Adams is just a genious of an author so he wins hands down, I'll take away your cookies if you can't guess which of his books I like best.

I currently dual boot my primary computer to winxp and archlinux, mainly because I'm still learning linux and wanted a distro that I could actually learn the OS with and not just how to use it (I previously had FC4 installed).  On my server I run win2003 and plan on installing debian.

I prefer to build my own computer so I don't really have a favorite brand. I absolutely deplore most HP/Compaq's though.

I play frisbee football and football on a regular basis and would play soccer if not for a lack of interest amongst my friends.

I'm a big strategy game buff.  Warcraft 3 (dota), civilization series, heroes of might and magic series  have been my favorite computer games, I'll play any card game, any time.  Especially pitch, spades, or Up and Down the river (insanely fun party game).  I have enjoyed the Settlers of Catan board game as well as Tom Clancy's Politika.  I'll play just about anything though.

I'm really not an animal person. I don't dislike them persay, I just don't enjoy their company most of the time (that and they all smell).

My interests are primarily living the college life (aka party), programming, random hardware "hacking" (see hackaday.com), and my girlfriend.  I know Java and C# pretty well, I think I've forgotten most of what C++ I knew simply because I haven't used it in almost 4 years, but I'd probably pick it up quickly.  I know asp.net, php, css, html, sql, and vb as well.

with that I tip my hat, all this typing has made me thirsty


Pages: 1 [2]