Hessian is a binary protocol designed with communication between web services in mind. It can be used to do some interesting things, but here’s a pointless example instead.
On the server side (running in Resin in my case; with Resin you will also need a resin-web.xml):
public class HessianThing extends HessianServlet {
public String insult(String name)
{
return "silly " + name;
}
}
On the client side (Ruby here):
c = HessianClient.new("http://localhost:8080/hessianthing")
puts c.insult("you")
Outputs: “silly you”
The server interface’s (or implementation’s) javadoc is all that is needed for a protocol specification.
~/.config/fsniper/scripts/pacman-cache.sh
#!/bin/bash
# This script checks the pacman cache directory and runs a command if it is over a certain size.
MAXSIZE="3500" # run the command you if the cache is over this size (in mb)
# run this command if CACHE is > MAXSIZE
COMMAND="echo \"oh no pacman's cache is over $MAXSIZE\" | mail -s \"pacman warning\" me@gmail.com "
CACHE="/var/cache/pacman/pkg" # cache location
if [[ "`du -sm $CACHE`" > "$MAXSIZE" ]]; then
$COMMAND
fi
and in ~/.config/fsniper/config
/var/cache/pacman/pkg/ {
* {
handler = pacman-cache.sh %%
}
scp can’t resume transfers where it left off. rsync can.
All it takes is:
rsync -r –partial –progress –rsh=ssh user@host:sekrit/ .
You may also want to add the —bwlimit option to specify the maximum transfer speed (in kbytes/s).
Following in the great Siman’s footsteps, I have written a script that is actually useful*.
What script, you ask? A script to place a call, using Asterisk’s AMI, if Gajim receives a message while you are away. If someone calls you and your status is not online, the script will call the phone number you provided and let you know the name of the person that has messaged you and their message. Festival is used to perform the text-to-speech function.
A working Festival installation is required, using the Perl AGI method. It can easily be modified to use the Festival() command instead if desired. pyst is also required for communicating with the AMI.
The script is located at this git repository.
* Please negate when reading.
The usual way to forward ports with SSH is to do something like:
ssh -L 3128:127.0.0.1:3128 user@remote
This, of course, forwards localhost:3128 on the local machine to localhost:3128 on phoenix. Coupled with a HTTP proxy running on phoenix and bound to localhost:3128, this can be used to tunnel traffic on the local machine through ssh in order to bypass restrictive firewalls. Squid is one such proxy, which works great, but a proxy is no longer necessary with SSH’s dynamic port forwarding. I’ll explain why in a bit.
Without a HTTP proxy running on phoenix, the only way to connect to accomplish this would be to do something like:
ssh -L 80:www.google.com:80 user@remote
which would forward localhost:80 on the current machine to google.com. The problems with this are obvious: you have to manually choose the websites you will access when you setup the connection, and it won’t work if the website checks to make sure that the HTTP Host your browser sends matches it (www.google.com is expected, not localhost).
Enter -D.
ssh -D creates a SOCKS proxy on the specified port that can be used to tunnel traffic. For example, running:
ssh -D 1234 user@remote
creates a SOCKS proxy on localhost:1234 of the machine running the command. Applications can then be configured to use localhost:1234 as their SOCKS proxy and all their traffic will be tunneled through the SSH connection, bypassing any firewalls in place. This is all that is needed to replace the earlier http proxy/ssh -L scenario.
If the application doesn’t support SOCKS, simply run it with tsocks. For example, tsocks irssi will make irssi use the SOCKS proxy. You will need to edit /etc/tsocks.conf to set the appropriate port and server. It would look something like this:
server = 127.0.0.1
server_port = 1234
# don’t use SOCKS for connections to these IPs
local = 127.0.0.0/255.0.0.0
tsocks will replace any connect/socket/etc calls with appropriate equivalents that use the SOCKS proxy.
I recently wrote an (incomplete) manual for fsniper.
This version covers a lot, but there’s still more that needs to be added (delays, handler examples). It was written in oowriter and exported to a PDF, but it really ought to be done in LaTeX, so I will most likely wait to make it official until I can produce a better-looking LaTeX version (this has the added benefit of being able to export to HTML for the fsniper website aswell).