Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  This topic is locked: you cannot edit posts or make replies.     Home » Forums » CMUD General Discussion
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Sun Aug 26, 2007 5:55 pm   

Adding ATCP support to CMUD 2
 
Now we have Telnet triggers, we can properly auth ATCP sessions. Here's a trigger that'll generate the proper auth response and send it to the server.

Code:
<trigger type="Telnet" param="200" id="1">
  <pattern>Auth.Request CH$(%w)</pattern>
  <value>$atcp_result=17
$atcp_seed=%1
$atcp_counter=(%len($atcp_seed)-1)
$atcp_temp=%mod($atcp_counter,2)
#WHILE ($atcp_seed) {
 #IF ($atcp_temp) {
  #ADD $atcp_result %eval((%ascii(%rightback($atcp_seed,1))-96)*%bitor($atcp_counter,11)*-1)
 } {
  #ADD $atcp_result %eval((%ascii(%rightback($atcp_seed,1))-96)*%bitor($atcp_counter,13))
 }
 $atcp_temp=(!$atcp_temp)
 #ADD $atcp_counter -1
 $atcp_seed=%leftback($atcp_seed,1)
}
#sendsb 200 {auth $atcp_result cmud}
  </value>
</trigger>

This formula was first discovered by Whyte of Imperian. It was adapted to zScript by Vijilante, and then I tinkered with it a little.

This trigger will fire very soon after you log in - once it has, the server will start sending ATCP information. To display them, use something like this:

Code:
<trigger type="Telnet" param="200" id="2">
  <pattern>(*)</pattern>
  <value>#say %1</value>
</trigger>

Which will display all incoming ATCP text. Bear in mind, though, that some ATCP elements are more than one line (like the Auth.Request element above). I haven't seen any other than Auth.Request, but bear this in mind. The lines are separated using a single <LF> and not <CR><LF>, so you'll need to use the hex code \012 in a regex rather than the $ character to match the line break.

And yes, I know the Auth trigger above uses $ and not \012. I've no idea why it works sometimes but doesn't work others - it's probably a bug. Just play it safe and use \012.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
Dumas
Enchanter


Joined: 11 Feb 2003
Posts: 511
Location: USA

PostPosted: Mon Aug 27, 2007 5:23 am   
 
Thanks Fang. Just have one question. This is a sample output of what I get with the trigger response colored

Quote:
Room.Brief Darfinia Lane passing some ruins
Room.Exits n,se

Darfinia Lane passing some ruins.
RooThe only structure upon the western side of the street here are the ruins of an
ancient palace or temple. Wide marble steps, at least fifty of them, lead up to
a platform upon which several massive pillars hold up nothing at all, and some
of their sections lay in the overgrown grass amongst what is left of the
building. The dismembered head of a statue, and what might possibly have been an
arm, lies at the foot of the steps. Time and the elements have so worn away at
the sculptures, it is impossible to tell whom they depict or even if they were
once part of the same work. A rune resembling a horse has been sketched into the
ground here. A runic totem is planted solidly in the ground. Spreading its
majestic golden wings, a giant eagle searches the ground with piercing eyes.
Room.Exits n,se
ng north and southeast.


As you can see, it displays Room.Brief and Room.Exits right off the bat. It then seems to try to do something with a Room type setting as the description starts but is cut off. It then repeats Room.Exits before where the line that would normally tell you the exist would be. That line is cut off from 'You see exits leading ...' to just 'ng ...'.

Is this what the expected response is supposed to be? If not, can someone post an example of proper output. Or, barring that, is there a way to see the ATCP info without using the * trigger on the subotion?
Reply with quote
gamma_ray
Magician


Joined: 17 Apr 2005
Posts: 496

PostPosted: Mon Aug 27, 2007 5:54 am   
 
Code:
<trigger type="Telnet" param="200" priority="78510" case="true" regex="true" id="7851">
  <pattern>^Auth\.Request CH\n(.*)</pattern>
  <value>$seed = %1
$temp = 17
#loop 0,%eval(%len($seed)-1) {
  #if (%mod(%i,2) == 0) {
    $temp = %eval($temp + (%ascii($seed) - 96) * %bitor(%i,13))
  } {
    $temp = %eval($temp - (%ascii($seed) - 96) * %bitor(%i,11))
  }
  $seed = %right($seed,1)
}
#sendsb 200 {auth $temp CMud 2.01}</value>
</trigger>


That's what I've been using in Imperian, to authorize ATCP.

Code:
<trigger type="Telnet" param="200" priority="78530" case="true" regex="true" id="7853">
  <pattern>^Auth\.Request ON$</pattern>
  <value>#sendsb 200 {hello CMud 2.01%lf~auth 1%lf~char_name 1%lf~char_vitals 1%lf~room_brief 1%lf~room_exits 1}</value>
</trigger>


And that one'll turn on a bunch of useful things, otherwise Imperian just does room.brief and nothing else.

Dumas, you might try using, e.g., Wireshark to see what's actually being sent. I've found it to be highly useful. Also, which game are you playing? (Achaea, Lusternia, etc.)

And, does anyone have any ideas for implementing the editor? Enabling the option, great, but actually capturing (many) lines of text is not working so well, since #cap is no help at all for suboption stuff.

Edit: Quick note, you can use \n to match an LF in regex. That's what I've been using for char.vitals.
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Mon Aug 27, 2007 12:02 pm   
 
Weird, I tried \n in some of my tests and it didn't work. \012 worked every time, though, so that's why I suggest using it.

You can use CMUD's #debug command to get a dump of what the server is sending. The first parameter is a .txt file that's an exact reproduction of what the server sent and the second parameter is a .raw file that contains info about who sent what and what they sent with non-visible characters made visible.

#debug imperian.txt imperian.raw

As for your thing with the funny display - yes, it happens to me as well, and yes, it's on the bug list. But once you remove the second trigger (which you should do once you've set up other triggers for whatever you want), it'll go away :)
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
Zugg
MASTER


Joined: 25 Sep 2000
Posts: 23379
Location: Colorado, USA

PostPosted: Mon Aug 27, 2007 5:45 pm   
 
Keep in mind that the 2.01 beta version of CMUD already should handle the "hello" and "auth" messages. I didn't have much of a chance to test them fully, but I'd be interested in knowing how they are working. Hopefully that will allow you to focus on the more meaningful ATCP messages instead of getting bogged down in the auth stuff.

If you want to override the internal messages, create a Telnet Trigger with telnet option 200 and a pattern of "hello". If you use the #SENDSB command from this "hello" trigger, then that will prevent CMUD from sending it's own "hello" response.

Similarly, if you set up a trigger with a pattern of "Auth.Request CH" and send something using #SENDSB, then that will prevent CMUD from sending it's normal response. Basically, when CMUD gets an telnet IAC SB message, it calls your trigger (if it exists), and if your trigger uses #SENDSB, then CMUD assumes that you have sent a correct response, so it won't send anything of it's own.

This should allow you to test the internal ATCP support, but still play with your own support if you want to.
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Mon Aug 27, 2007 6:23 pm   
 
I did actually do a DEBUG recording of one of these sessions with my triggers turned off, and CMUD sent the IAC DO 200 and received the Auth.Request CH, but never sent a response (or didn't seem to), and then Auth.Request ON never arrived, so hello was never sent.

The Room.Brief started appearing, though, which would imply that it was authed (wouldn't it? I'm not sure if these get sent just from the IAC DO 200 message) but none of the extra items like Char.Vitals and Room.Exits appeared, which would back up the hello response not being sent.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
gamma_ray
Magician


Joined: 17 Apr 2005
Posts: 496

PostPosted: Mon Aug 27, 2007 6:42 pm   
 
You have to tick the ATCP box in the emulation section for it to do it automatically (it's not enabled by default). There was something else wrong with it, though, that I can't remember at the moment.

And hello was very, very spotty. A lot of the time I didn't seem to *get* a hello, but it didn't matter anyway since sending one on it's own is what it seems to expect.

Oh, and at some points it WAS sending it's own reply to Auth.Request CH, as well as the one I'd triggered. I'll post logs in a bit, once I get all of this stuff captured, at the time I was more in a make-it-work-NOW mode than in a careful note-taking mode.
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Mon Aug 27, 2007 6:54 pm   
 
Ah, fair enough. I assumed it'd be on by default for some bizarre reason (perhaps because the MUD will send IAC WILL 200 if it's supported?). I stand corrected.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
gamma_ray
Magician


Joined: 17 Apr 2005
Posts: 496

PostPosted: Mon Aug 27, 2007 7:11 pm   
 
OK, I unticked ATCP and restarted CMud (for some reason losing all of my changed settings in the process, argh) so I've got a good clean capture. I is Imperian, C is CMud, blank lines separate packets, obviously all that is just the suboption stuff, and data is boring data.

Quote:
I: Will ATCP

C: Do ATCP

I: Char.Name data
data
I: Auth.Request CH
data
I: Room.Brief data

C: auth -456 CMud 2.01

C: auth -456

I: Auth.Request ON

C: hello CMud 2.01
auth 1
char_name 1
char_vitals 1
room_brief 1
room_exits 1


The auth -456 CMud 2.01 is my trigger. The second one shouldn't be sent at all--bug.

The last packet is from another of my triggers, but you can see I never got a hello from the game, despite the fact that I authed and everything works.

Edit: And here's the same using a Nexus (Imperian's native client) login. I is still Imperian, N is nexus.

Quote:
N: hello Nexus 3.0.15
auth 1
composer 1
keepalive 1
char_name 1
filestore 1
topvote 1
char_vitals 1
room_brief 1
room_exits 1
mediapak 1
wiz 1

N: login data
file get nexus-settings Settings
file get nexus-reflexes Reflexes

I: Will ATCP

N: Do ATCP

I: Auth.Request CH
data

N: auth -502 Nexus 3.0.15

I: Char.Name data
data
Room.Brief data
Client.VoteReminder
[data]
Client.JavaEnv
Char.Vitals
data
Room.Brief data
Room.Exits data
File.Content Settings
lots of data
File.Content Reflexes
data

I: Auth.Request ON

N: javaenv
lots of data

N: ping 0

I: Client.Ping
Reply with quote
Zugg
MASTER


Joined: 25 Sep 2000
Posts: 23379
Location: Colorado, USA

PostPosted: Mon Aug 27, 2007 7:43 pm   
 
Quote:
OK, I unticked ATCP

OK, I'm confused. Was the ATCP option in CMUD enabled, or not. It sounds like you said "unticked" which would imply that it was disabled, but then CMUD shouldn't be sending any of it's own responses (just whatever you send in your own triggers).

Interesting in the Nexus output that it sends the "hello" packet even before the ATCP telnet option negotiation. That seems wrong to me. You should never send data for a suboption until *after* it has been negotiated. I hope their protocol doesn't require that, because it would be a kludge to implement.

From the documentation that I have, it simply states that the "hello" packet should be sent before any other ATCP data. So in CMUD I keep track of whether I have sent any ATCP text yet, and before I send the first ATCP command (usually the Auth response), I send the "hello" packet then.

Anyway, it would help if you could post a cleaner example of what CMUD is currently sending without any of your own triggers, or try to identify which lines are being sent by your triggers, and which lines are sent from CMUD itself.

(If Imperian would stop deleting my test characters, it would be a lot easier for me to test this myself. I'm getting tired of making new characters all the time)
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Mon Aug 27, 2007 7:53 pm   
 
I just took another DEBUG log, this time with ATCP properly enabled and disabled to compare. CMUD is sending its hello sequence, but it's not then responding to the Auth.Request CH (or at least didn't do it fast). Regardless of what the spec says, Auth.Request CH - auth - Auth.Request ON - hello is working fine for me.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
gamma_ray
Magician


Joined: 17 Apr 2005
Posts: 496

PostPosted: Mon Aug 27, 2007 9:56 pm   
 
I unticked it, so yes, it shouldn't be sending stuff, but it was sending a reply to the auth. It seems to be a bug.

Yes. Nexus is weird. I don't even try to explain why it does what it does, I was just using it for comparison. You don't have to send hello before negotiation, it works if you send it right after Auth.Request ON, or any other time for that matter (you can use it to toggle different options on and off if you want).

I'll post more logs when I get the chance.

I'm pretty sure Dranor would be willing to perm a character for you if you ask?, you can understand why inactive newbie level characters are regularly purged.
Reply with quote
Arminas
Wizard


Joined: 11 Jul 2002
Posts: 1265
Location: USA

PostPosted: Mon Aug 27, 2007 10:25 pm   
 
In Achaea at least all of my chars that never bought and converted any credits have been deleted. If I bought a credit with gold in the game even and converted it the char was left alone. If I had NOT purchased a credit with the char and converted it then the char was deleted. Even if I had registered them.

I tend to go long periods of time between playing and have had to recreate many chars. So I took note when they were NOT deleted on me.
_________________
Arminas, The Invisible horseman
Windows 7 Pro 32 bit
AMD 64 X2 2.51 Dual Core, 2 GB of Ram
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Mon Aug 27, 2007 11:05 pm   
 
Characters with credits are never deleted. Characters over level 21 are deleted very, very rarely.

Personally, when I turn off ATCP emulation, CMUD doesn't send anything.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
laysus
Newbie


Joined: 25 Oct 2005
Posts: 6

PostPosted: Sat Sep 08, 2007 12:11 pm   
 
I've been using an adaptation of the above trigger (basically added $ to the end of the trigger to echo ATCP text - without it it only matched the first word or so), and I'm finding it's showing me ansi codes as well, like so:

Code:

"No problem," you say offhandedly.
H:3220/3220 M:2480/3220 E:15000/15000 W:15000/15000 NL:31/100
[37m ex-


Any idea why that's happening?
Reply with quote
gamma_ray
Magician


Joined: 17 Apr 2005
Posts: 496

PostPosted: Sat Sep 08, 2007 12:27 pm   
 
Can you post the XML of the trigger you're using? Also, which version of CMud?
Reply with quote
laysus
Newbie


Joined: 25 Oct 2005
Posts: 6

PostPosted: Sat Sep 08, 2007 12:31 pm   
 
2.03, and the trigger is the following

Code:

<?xml version="1.0" encoding="UTF-8" ?>
<cmud>
  <trigger type="Telnet" param="200" priority="51460" regex="true" newline="false" prompt="true">
    <pattern>(.*)$</pattern>
    <value>#sayp %1</value>
  </trigger>
</cmud>


Working off the triggers given at the top of the page.
Reply with quote
laysus
Newbie


Joined: 25 Oct 2005
Posts: 6

PostPosted: Sat Sep 08, 2007 12:43 pm   
 
Ok, I screwed up, nevermind >.>
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Sat Sep 08, 2007 12:46 pm   
 
You don't need triggers like that in CMUD 2.03 - most of the tags are supported by default now. The only ones you need to watch for is Char.Vitals, and perhaps Char.Name. The other ones are handled automagically.

Since this sort of homebrew ATCP support is no longer required I'm going to lock this thread. If anyone has any problems with CMUD 2's built-in ATCP support, they should start a new thread.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
Display posts from previous:   
Post new topic   This topic is locked: you cannot edit posts or make replies.     Home » Forums » CMUD General Discussion All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

© 2009 Zugg Software. Hosted by Wolfpaw.net