Archive for October, 2004

XDoclet

Wednesday, October 27th, 2004

Xdoclett seems to be a nice way of generating web.xml descriptor based on the JavaDOC style comments in a source code. From what Chris showed me, it looks it’s quite difficult to run though. (more…)

Getting a class name from a static method

Monday, October 25th, 2004

public class ClassFromStatic { public static void main(java.lang.String[] args) { someStaticMethod(); }

public static void someStaticMethod() 
{
    System.out.println("I'm in " + new CurrentClassGetter().getClassName() 
        + " class");
}

public static class CurrentClassGetter extends SecurityManager 
{
    public String getClassName() 
    {
        return getClassContext()[1].getName();
    }
}

}

Bind forwarding

Monday, October 25th, 2004

One of the problems with DNS cat is that the sefver may be already running a DNS server. Multiple servers cannot share a single port 53.

The workaround is “DNS forwarding”. (more…)

Java non-blocking I/O

Wednesday, October 20th, 2004

Java SUCKS! Platform independence doesn’t come with a high price. The last two days I have been trying to do asynchronous non-blocking I/O and got really frustrated. Moreover, I come to think that what I really wanted is simply not possible.

Correction - Java sucks LESS ;-) It’s not so well documented though…

I have a fully functional non-blocking IO for Java 1.4. It is multithreaded and it works great. (more…)

IPtables tricks

Tuesday, October 19th, 2004
iptables -t nat -I PREROUTING -p tcp --destination-port <other port> -j REDIRECT --to-ports 25
  • redirecting incoming packets to other ports

    iptables -t nat -I POSTROUTING -o <internet_interface> -http://lists.netfilter.org/pipermail/netfilter/2004-March/051478.htmlj MASQUERADE

  • all packets that would go through internet connected interface will be maqueraded

I recently found out that this redirect doesn’t work for traffix generated to the local interface. Following the advice from this list I made it to work (I don’t know if you need some special kernel options as they suggested it just worked for me on 2.6.x).

iptables -t nat -I OUTPUT -p tcp --destination-port <other port> -o lo -d localhost -j REDIRECT --to-ports 25

Converting all EPSs to PDF

Monday, October 18th, 2004

ls *.eps | xargs -l1 epstopdf

one liner — i like it.

Printing with CUPS

Friday, October 15th, 2004

For an unknown reason my printing stopped working with CUPS and lpd. I have modified my setup to use CUPS: /etc/cups/cupsd.conf

Browsing On BrowsePoll <cupssrv1>

This works better than setting your cups client to usr one cups server as this one allows you to have local printers defined as well. Downside: when you start your cupsd with no network, you need to restart cupsd (/etc/init.d/cupsys restart) to reconnect.

Changing permissions hack

Wednesday, October 13th, 2004

chmod -R go=u,go-w /directory

Copying user’s permissions to group and others, clearing write permission (all this to merely preserve x for directories without setting it to all other files).

PPP over SSH

Friday, October 8th, 2004

WHY?????? WHY NOT? ;-) Run this on client:

pppd noauth debug nodetach  10.0.0.1:10.0.0.2 pty 'ssh user@server "pppd noauth debug nodetach notty "'

It works, even if the server asks for password, as it uses a direct terminal I/O, not stdin. Note that for noauth option pppd needs to be run as root (otherwise, some authentication options have to be set).

BTW Chris found this link. I think our one-liner is much nicer ;-)