Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are
spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the
password reset link.
Due to spam on this forum, all posts now need moderator approval.
Entire forum
➜ MUSHclient
➜ Plugins
➜ Plugin to convert packet debug output ready for simulating input
|
Plugin to convert packet debug output ready for simulating input
|
It is now over 60 days since the last post. This thread is closed.
Refresh page
| Posted by
| Nick Gammon
Australia (23,166 posts) Bio
Forum Administrator |
| Date
| Mon 20 Jul 2009 12:59 AM (UTC) Amended on Wed 19 Aug 2009 05:49 AM (UTC) by Nick Gammon
|
| Message
| From time to time I get problem reports with a packet debug output in it. To test these in my local copy the data in the packet debug needs a bit of massaging before it can be submitted into Game menu -> Test Trigger.
The plugin below automates that. Just copy the packet output to the clipboard, and then type "convert_packet". This is an alias that scans the text on the clipboard. For each line that appears to be packet debug output, it puts a backslash in front of each hex sequence.
For example, if I see:
Incoming packet: 7 (512 bytes) at Monday, July 20, 2009, 10:40:57 AM
.[1;37mThe Guild 1b 5b 31 3b 33 37 6d 54 68 65 20 47 75 69 6c 64
of Thieves...[1 20 6f 66 20 54 68 69 65 76 65 73 0d 0a 1b 5b 31
;33mYou stand in 3b 33 33 6d 59 6f 75 20 73 74 61 6e 64 20 69 6e
side the main ha 73 69 64 65 20 74 68 65 20 6d 61 69 6e 20 68 61
ll of the Guild 6c 6c 20 6f 66 20 74 68 65 20 47 75 69 6c 64 20
of Thieves. Vel 6f 66 20 54 68 69 65 76 65 73 2e 20 20 56 65 6c
vet couches..lin 76 65 74 20 63 6f 75 63 68 65 73 0a 0d 6c 69 6e
e the walls, no 65 20 74 68 65 20 77 61 6c 6c 73 2c 20 6e 6f 20
doubt stolen fro 64 6f 75 62 74 20 73 74 6f 6c 65 6e 20 66 72 6f
m some wealthy m 6d 20 73 6f 6d 65 20 77 65 61 6c 74 68 79 20 6d
erchant. Painti 65 72 63 68 61 6e 74 2e 20 20 50 61 69 6e 74 69
ngs..and tapestr 6e 67 73 0a 0d 61 6e 64 20 74 61 70 65 73 74 72
ies hang from th 69 65 73 20 68 61 6e 67 20 66 72 6f 6d 20 74 68
e stone walls, d 65 20 73 74 6f 6e 65 20 77 61 6c 6c 73 2c 20 64
isplaying scenes 69 73 70 6c 61 79 69 6e 67 20 73 63 65 6e 65 73
of deception,.. 20 6f 66 20 64 65 63 65 70 74 69 6f 6e 2c 0a 0d
stealth and veng 73 74 65 61 6c 74 68 20 61 6e 64 20 76 65 6e 67
eance. The trai 65 61 6e 63 65 2e 20 20 54 68 65 20 74 72 61 69
ning room is to 6e 69 6e 67 20 72 6f 6f 6d 20 69 73 20 74 6f 20
the east while a 74 68 65 20 65 61 73 74 20 77 68 69 6c 65 20 61
small..the dona 20 73 6d 61 6c 6c 0a 0d 74 68 65 20 64 6f 6e 61
tion room is to 74 69 6f 6e 20 72 6f 6f 6d 20 69 73 20 74 6f 20
the north and a 74 68 65 20 6e 6f 72 74 68 20 61 6e 64 20 61 20
dark alley becko 64 61 72 6b 20 61 6c 6c 65 79 20 62 65 63 6b 6f
ns to the south. 6e 73 20 74 6f 20 74 68 65 20 73 6f 75 74 68 2e
...[1;37mExits: 0a 0d 1b 5b 31 3b 33 37 6d 45 78 69 74 73 3a 20
north east south 6e 6f 72 74 68 20 65 61 73 74 20 73 6f 75 74 68
......[0m.[0;37m 2e 0d 0a 0d 0a 1b 5b 30 6d 1b 5b 30 3b 33 37 6d
<.[1;33m10000hp 3c 1b 5b 31 3b 33 33 6d 31 30 30 30 30 68 70 20
.[1;36m25000m .[ 1b 5b 31 3b 33 36 6d 32 35 30 30 30 6d 20 1b 5b
1;32m109mv.[0;37 31 3b 33 32 6d 31 30 39 6d 76 1b 5b 30 3b 33 37
m> <#21141> .[0m 6d 3e 20 3c 23 32 31 31 34 31 3e 20 1b 5b 30 6d
I just copy all that to the clipboard, load the plugin and type "convert_packet" and see this in the output window:
------------------------------------------------------------
\1b\5b\31\3b\33\37\6d\54\68\65\20\47\75\69\6c\64\20\6f\66\20\54
\68\69\65\76\65\73\0d\0a\1b\5b\31\3b\33\33\6d\59\6f\75\20\73\74
\61\6e\64\20\69\6e\73\69\64\65\20\74\68\65\20\6d\61\69\6e\20\68
\61\6c\6c\20\6f\66\20\74\68\65\20\47\75\69\6c\64\20\6f\66\20\54
\68\69\65\76\65\73\2e\20\20\56\65\6c\76\65\74\20\63\6f\75\63\68
\65\73\0a\0d\6c\69\6e\65\20\74\68\65\20\77\61\6c\6c\73\2c\20\6e
\6f\20\64\6f\75\62\74\20\73\74\6f\6c\65\6e\20\66\72\6f\6d\20\73
\6f\6d\65\20\77\65\61\6c\74\68\79\20\6d\65\72\63\68\61\6e\74\2e
\20\20\50\61\69\6e\74\69\6e\67\73\0a\0d\61\6e\64\20\74\61\70\65
\73\74\72\69\65\73\20\68\61\6e\67\20\66\72\6f\6d\20\74\68\65\20
\73\74\6f\6e\65\20\77\61\6c\6c\73\2c\20\64\69\73\70\6c\61\79\69
\6e\67\20\73\63\65\6e\65\73\20\6f\66\20\64\65\63\65\70\74\69\6f
\6e\2c\0a\0d\73\74\65\61\6c\74\68\20\61\6e\64\20\76\65\6e\67\65
\61\6e\63\65\2e\20\20\54\68\65\20\74\72\61\69\6e\69\6e\67\20\72
\6f\6f\6d\20\69\73\20\74\6f\20\74\68\65\20\65\61\73\74\20\77\68
\69\6c\65\20\61\20\73\6d\61\6c\6c\0a\0d\74\68\65\20\64\6f\6e\61
\74\69\6f\6e\20\72\6f\6f\6d\20\69\73\20\74\6f\20\74\68\65\20\6e
\6f\72\74\68\20\61\6e\64\20\61\20\64\61\72\6b\20\61\6c\6c\65\79
\20\62\65\63\6b\6f\6e\73\20\74\6f\20\74\68\65\20\73\6f\75\74\68
\2e\0a\0d\1b\5b\31\3b\33\37\6d\45\78\69\74\73\3a\20\6e\6f\72\74
\68\20\65\61\73\74\20\73\6f\75\74\68\2e\0d\0a\0d\0a\1b\5b\30\6d
\1b\5b\30\3b\33\37\6d\3c\1b\5b\31\3b\33\33\6d\31\30\30\30\30\68
\70\20\1b\5b\31\3b\33\36\6d\32\35\30\30\30\6d\20\1b\5b\31\3b\33
\32\6d\31\30\39\6d\76\1b\5b\30\3b\33\37\6d\3e\20\3c\23\32\31\31
\34\31\3e\20\1b\5b\30\6d
------------------------------------------------------------
(Linebreaks were inserted to make this forum posting easier to read).
Basically you see all the hex codes from the packet debug, without all the spaces and other stuff. Now Shift+double-click to copy that entire paragraph (the hex stuff) and then you can hit Shift+Ctrl+F12 to try that packet out again.
This then shows in the output window:
The Guild of Thieves
You stand inside the main hall of the Guild of Thieves. Velvet couches
line the walls, no doubt stolen from some wealthy merchant. Paintings
and tapestries hang from the stone walls, displaying scenes of deception,
stealth and vengeance. The training room is to the east while a small
the donation room is to the north and a dark alley beckons to the south.
Exits: north east south.
<10000hp 25000m 109mv> <#21141>
 |
To save and install the Convert_Packet_Debug plugin do this:
- Copy between the lines below (to the Clipboard)
- Open a text editor (such as Notepad) and paste the plugin into it
- Save to disk on your PC, preferably in your plugins directory, as Convert_Packet_Debug.xml
- Go to the MUSHclient File menu -> Plugins
- Click "Add"
- Choose the file Convert_Packet_Debug.xml (which you just saved in step 3) as a plugin
- Click "Close"
|
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>
<!-- Saved on Monday, July 20, 2009, 10:47 AM -->
<!-- MuClient version 4.43 -->
<!-- Plugin "Convert_Packet_Debug" generated by Plugin Wizard -->
<muclient>
<plugin
name="Convert_Packet_Debug"
author="Nick Gammon"
id="cae868ff0b7d205596cf6db7"
language="Lua"
purpose="Converts packet debug lines for Test Trigger"
date_written="2009-07-20 10:45:55"
requires="4.40"
version="1.0"
>
<description trim="y">
<![CDATA[
1. Copy some packet debug to the Clipboard (possibly omitting sent packets)
2. Type: convert_packet
3. Converted packet will be echoed to output.
Extra lines which don't look like packet debug will be ignored.
]]>
</description>
</plugin>
<!-- Aliases -->
<aliases>
<alias
script="convert_packet"
match="convert_packet"
enabled="y"
sequence="100"
>
</alias>
</aliases>
<!-- Script -->
<script>
<![CDATA[
require "getlines"
function convert_packet (name, line, wildcards)
-- get clipboard, remove carriage-returns
local clip = string.gsub (GetClipboard (), "\r", "")
-- starting line of hyphens
print (string.rep ("-", 60))
-- for each line see if it looks like a debug line
-- debug lines have 16 ASCII characters, 3 spaces, and then some hex stuff
for line in getlines (clip) do
local hex = string.match (line, "^................ ([%x ]+)$")
if hex then -- looks OK
for s in string.gmatch (hex, "%x%x") do
Tell ("\\" .. s) -- output without a linebreak
end -- for
end -- seems to be a packet debug line
end -- for loop
print ("") -- new line
print (string.rep ("-", 60))
end -- function convert_packet
]]>
</script>
</muclient>
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | | Top |
|
| Posted by
| Nick Gammon
Australia (23,166 posts) Bio
Forum Administrator |
| Date
| Reply #1 on Mon 20 Jul 2009 01:11 AM (UTC) |
| Message
| | The point of using packet debug, in case you are wondering, is that it includes stuff like ANSI colour codes, MXP codes, telnet negotiation, and other things that are not visible in the normal output window. Sometimes these are needed to debug obscure problems like triggers that only match on certain colours. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | | Top |
|
| Posted by
| Nick Gammon
Australia (23,166 posts) Bio
Forum Administrator |
| Date
| Reply #2 on Sat 15 Aug 2009 10:14 PM (UTC) Amended on Wed 19 Aug 2009 05:50 AM (UTC) by Nick Gammon
|
| Message
| An improved version below does not convert ordinary ASCII, so it makes it easier to see what is in the packet.
 |
To save and install the Convert_Packet_Debug plugin do this:
- Copy between the lines below (to the Clipboard)
- Open a text editor (such as Notepad) and paste the plugin into it
- Save to disk on your PC, preferably in your plugins directory, as Convert_Packet_Debug.xml
- Go to the MUSHclient File menu -> Plugins
- Click "Add"
- Choose the file Convert_Packet_Debug.xml (which you just saved in step 3) as a plugin
- Click "Close"
|
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>
<!-- Saved on Monday, July 20, 2009, 10:47 AM -->
<!-- MuClient version 4.43 -->
<!-- Plugin "Convert_Packet_Debug" generated by Plugin Wizard -->
<muclient>
<plugin
name="Convert_Packet_Debug"
author="Nick Gammon"
id="cae868ff0b7d205596cf6db7"
language="Lua"
purpose="Converts packet debug lines for Test Trigger"
date_written="2009-07-20 10:45:55"
requires="4.40"
version="1.0"
>
<description trim="y">
<![CDATA[
1. Copy some packet debug to the Clipboard (possibly omitting sent packets)
2. Type: convert_packet
3. Converted packet will be echoed to output.
Extra lines which don't look like packet debug will be ignored.
]]>
</description>
</plugin>
<!-- Aliases -->
<aliases>
<alias
script="convert_packet"
match="convert_packet"
enabled="y"
sequence="100"
>
</alias>
</aliases>
<!-- Script -->
<script>
<![CDATA[
function convert_packet (name, line, wildcards)
clip = string.gsub (GetClipboard (), "\r", "")
require "getlines"
print (string.rep ("-", 60))
local t = {}
for line in getlines (clip) do
hex = string.match (line, "^................ ([%x ]+)$")
if hex then
for s in string.gmatch (hex, "%x%x") do
local c = tonumber (s, 16)
if c == 0x5C then -- double a backslash
table.insert (t, "\\\\")
elseif c >= 0x20 and c <= 0x7f then
table.insert (t, string.char (c)) -- show actual character
else
table.insert (t, "\\" .. s) -- show as hex
end -- if
end -- for
end -- seems to be a packet debug line
end -- for loop
local s = table.concat (t)
s = string.gsub (s, "\\0d\\0a", "\n") -- convert \r\n to \n which works in simulate window
print (s) -- new line
print (string.rep ("-", 60))
end -- function convert_packet
]]>
</script>
</muclient>
With that, the same packet in the earlier post looks like this:
\1b[1;37mThe Guild of Thieves
\1b[1;33mYou stand inside the main hall of the Guild of Thieves. Velvet couches\0a\0dline the walls, no doubt stolen from some wealthy merchant. Paintings\0a\0dand tapestries hang from the stone walls, displaying scenes of deception,\0a\0dstealth and vengeance. The training room is to the east while a small\0a\0dthe donation room is to the north and a dark alley beckons to the south.\0a\0d\1b[1;37mExits: north east south.
\1b[0m\1b[0;37m<\1b[1;33m10000hp \1b[1;36m25000m \1b[1;32m109mv\1b[0;37m> <#21141> \1b[0m
As you can see, it is easier to tweak the packet contents if you want to.
Note some idiosyncrasies - SMAUG is incorrectly outputting \0a\0d for new lines in some places, and (correctly) \0d\0a in others. There is a string.gsub in the code above that converts \0d\0a (carriage return followed by linefeed) into a single linefeed. If this is pasted into the Game -> Test Trigger window then the line breaks are converted back into \0d\0a and everything works out. :)
However \0a\0d is not converted, as that would change the sense of what is being simulated. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | | Top |
|
The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).
To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.
11,093 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top