summaryrefslogtreecommitdiffstats
path: root/doc/scriptexamples/srfs.kvs
blob: 1d4bd2e72617e7e8d5664835137c1173de5a7421 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# Connect to firewalled sysreset fserves without /dccserver
# SlickMcSly@mail.com
# Everything here was derived through simple experimentation while learning how everything involved
# works.  If there's a better way I'm in no rush figure it out.
#
# Firewalled sysreset fserves try to open a dcc chat connection to the target port and send
# the message "100 fservenick".  After the fserve sends the "100 fservenick" message it expects a
# "101 recipientnick" message, with "recipientnick" being the nick of whoever got the message.
# I wasn't able to send it some1 else's nick and get a connection that way, which would be
# interesting since you could theoretically serve connections to other ppl behind firewalls.
#
# This code requires opening a listening socket, but since sysreset is mircx specific (essentially
# winhozed specific) it doesn't hestitate to asking people who connect to open a listening port in
# the well known/privileged range which requires root (NONO).  To deal with this, I setup iptables
# to forward packets bound for port 59 to port 12345 (which can be bound by non-root) by using:
# "iptables -t nat -I PREROUTING -p tcp -m multiport --dports 59 -j DNAT --to-destination :12345"
# (this requires root)
#
# There also appears to also be an option for some firewalled dcc send protocol.  I've only
# encountered this once though and didn't care to figure it out.

# Execute all the following code in the "New code tester" window
alias(srfs)	# Create alias: srfs
	{
	if($0 && $1)	# make sure there are enough parameters
		{
		dcc.chat -n -u -p=12345 $0;	# listen on port 12345 for incoming chat
		ctcp $0 $1-;	# send the ctcp trigger
		}
	else
		echo "Usage: /srfs <nick> <trigger>";	# when there aren't enough parameters
	}

event(OnDCCChatMessage,srfsHook)	# Create  OnDCCChatMessage event: srfs
	{
	# Since this event will parse ALL dcc chat messages, it looks for a message in the format
	# "100 word" with no other trailing text.  This is only a hack so it doesn't verify that
	# "word" is a nickname, much less the nick of an expected fserve.
	if(!$str.cmp($str.word(0, $0-), "100") && $str.cmp($str.word(1, $0-), "") && !$str.cmp($str.word(2, $0-), ""))
		say "101 $me";	# reply 101 mynick	# reply "101 mynick"
	}
# End