Author Topic: Using Anyterm with Dead Souls  (Read 5525 times)

Offline cratylus

  • Your favorite and best
  • Administrator
  • ***
  • Posts: 1020
  • Cratylus@Dead Souls <ds> np
    • View Profile
    • About Cratylus
Using Anyterm with Dead Souls
« on: September 15, 2009, 02:54:42 PM »
Summary: This post explains how to get set up Anyterm on Ubuntu so that
people can play your mud through their browser.

Justification: It's a neat thing to be able to do, and DS is set up to
support it, but you have to be fairly leet to work out the details on
your own, so a basic guide seemed in order.

Scope: The idea is for people to see the logical flow of the installation
so that they can adapt it to suit them on their favorite unix OS. By
showing the Ubuntu steps, folks can figure out for themselves how to
get it running on, say, Fedora.

Support: ZERO! I am not at all affiliated with Anyterm, nor Ubuntu, nor
Apache. I prefer not to establish a precedent of teaching people how
their interweb servars go. If there are parts of this you do not understand,
take it as an opportunity to research the bits you don't get. Strong familiarity
with unix administration is assumed.

Support addendum: If something is mistaken or broken, let me know and I'll fix it.

Contributions: If you get it to work on WeirdNix or whatever, and want
to share how, by all means post here your procedure. Similarly, if someone
posts "omg this is sooo great...just one thing...how do I make it do SSL?"
and you happen to have the answer, please share it! Cuz I won't. See the
above section named "Support" for details on that.

HOWTO Use Anyterm with Dead Souls on Ubuntu

Install Ubuntu server. Select the installation of LAMP when asked.

sudo bash

apt-get update


You won't need every single one of these, but unless you know for
a fact you don't need em, get em all.

apt-get install build-essential bison libc6-dev vim-full screen aptitude lynx zip unzip wget apache2 apache2-mpm-prefork cron telnet lsof man zlibc zlib1g-dev

apt-get install zlib1g-dbg gdb libgdb-dev gdb-doc gdb64 cvs libz-dev boost-build libboost-dev javacc libapache2-mod-proxy-html

apt-get install subversion subversion-tools


Install Dead Souls 2.11a18 or higher: http://dead-souls.net/ds-inst-faq.html
These instructions assume your DS mud runs on port 6666.


*** CONFIGURING APACHE ***

cd /etc/apache2/sites-available

add +Includes to your options.

vi default

replace something like

Code: [Select]
Options FollowSymLinkswith something like
Code: [Select]
Options FollowSymLinks +Includes
and
Code: [Select]
Options Indexes FollowSymLinks MultiViewswith
Code: [Select]
Options Indexes FollowSymLinks MultiViews +Includes
and all cases of
Code: [Select]
AllowOverride Noneto
Code: [Select]
AllowOverride Options

Include the following below the main </Directory> (usually just before cgi)

Code: [Select]
       <Location /anyterm/proxy>
                Order allow,deny
                Allow from all
                ProxyPass http://localhost:5555
                ProxyPassReverse http://localhost:5555
        </Location>

Create necessary links for apache mods

ln -s /etc/apache2/mods-available/proxy_http.load /etc/apache2/mods-enabled/proxy_http.load
ln -s /etc/apache2/mods-available/include.load /etc/apache2/mods-enabled/include.load
ln -s /etc/apache2/mods-available/proxy.conf /etc/apache2/mods-enabled/proxy.conf
ln -s /etc/apache2/mods-available/proxy.load /etc/apache2/mods-enabled/proxy.load

apache2ctl configtest



*** INSTALLING ANYTERM ***

Replace 192.168.0.224 with your external IP address.

svn co http://svn.anyterm.org/anyterm/trunk trunk

cd trunk


Add a line to the javascript file just below "var undefined;"

vi browser/anyterm.js


Code: [Select]
var url_prefix = "proxy/";

Replace some lines in the javascript file

vi browser/anyterm.js

change
Code: [Select]
return s.replace(/%v/g,version).replace(/%h/g,hostname);to
Code: [Select]
var ipee='<!--#echo var="REMOTE_ADDR"-->';
return s.replace(/%v/g,version).replace(/%h/g,hostname).replace(/%i/g,ipee);

Change anyterm.html to anyterm.shtml in common.mk

vi common.mk

change
Code: [Select]
BLOBFILES=anyterm.html anyterm.js anyterm.css copy.png paste.png copy.gif paste.gifto
Code: [Select]
BLOBFILES=anyterm.shtml anyterm.js anyterm.css copy.png paste.png copy.gif paste.gif
Rename the web file

mv browser/anyterm.html browser/anyterm.shtml

Modify the web file

vi browser/anyterm.shtml

change
Code: [Select]
browser/anyterm.htmlto
Code: [Select]
browser/anyterm.shtml
change
Code: [Select]
window.onload=function() {create_term("term","%h (Anyterm%v)",25,80,"","",50);};to
Code: [Select]
var ip = '<!--#echo var="REMOTE_ADDR"-->';
window.onload=function() {create_term("term","MyMud, from "+ip,25,80,ip,"",50);};

mkdir /var/www/anyterm
\cp -f browser/* /var/www/anyterm


Add a redirect index
vi /var/www/anyterm/index.html

Code: [Select]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<html>
<head>
<META http-equiv="refresh" content="0;URL=./anyterm.shtml">
</head>
<body>
</body>
</html>


make

cp anytermd /usr/bin/

/usr/bin/anytermd --port 5555 -u nobody -c 'telnet -E 192.168.0.224 6666 -l %p'

apache2ctl restart



*** Configure Dead Souls ***
It's assumed you installed in /usr/local/mud

vi /usr/local/mud/lib/secure/lib/connect.c


change

Code: [Select]
static private string array anyterms = ({"97.107.133.86", "127.0.0.1"});to
Code: [Select]
static private string array anyterms = ({"192.168.0.224", "127.0.0.1"});
Restart the mud

You should now be able to use Firefox to connect to your mud by
entering the url: http://192.168.0.224/anyterm

Ta daaa!

Appendix A, sample apache config file
Code: [Select]
<VirtualHost *:80>
        ServerAdmin webmaster@localhost

        DocumentRoot /var/www/
        <Directory />
                Options FollowSymLinks +Includes
                AllowOverride Options
        </Directory>
        <Directory /var/www/>
                Options Indexes FollowSymLinks MultiViews +Includes
                AllowOverride Options
                Order allow,deny
                allow from all
        </Directory>
        <Location /anyterm/proxy>
                Order allow,deny
                Allow from all
                ProxyPass http://localhost:5555
                ProxyPassReverse http://localhost:5555
        </Location>

        ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
        <Directory "/usr/lib/cgi-bin">
                AllowOverride None
                Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
                Order allow,deny
                Allow from all
        </Directory>

        ErrorLog /var/log/apache2/error.log

        # Possible values include: debug, info, notice, warn, error, crit,
        # alert, emerg.
        LogLevel warn

        CustomLog /var/log/apache2/access.log combined

    Alias /doc/ "/usr/share/doc/"
    <Directory "/usr/share/doc/">
        Options Indexes MultiViews FollowSymLinks
        AllowOverride None
        Order deny,allow
        Deny from all
        Allow from 127.0.0.0/255.0.0.0 ::1/128
    </Directory>

</VirtualHost>

Appendix B, contents of /etc/apache2/mods-enabled
Code: [Select]
lrwxrwxrwx 1 root root 28 2009-09-14 12:40 alias.conf -> ../mods-available/alias.conf
lrwxrwxrwx 1 root root 28 2009-09-14 12:40 alias.load -> ../mods-available/alias.load
lrwxrwxrwx 1 root root 33 2009-09-14 12:40 auth_basic.load -> ../mods-available/auth_basic.load
lrwxrwxrwx 1 root root 33 2009-09-14 12:40 authn_file.load -> ../mods-available/authn_file.load
lrwxrwxrwx 1 root root 36 2009-09-14 12:40 authz_default.load -> ../mods-available/authz_default.load
lrwxrwxrwx 1 root root 38 2009-09-14 12:40 authz_groupfile.load -> ../mods-available/authz_groupfile.load
lrwxrwxrwx 1 root root 33 2009-09-14 12:40 authz_host.load -> ../mods-available/authz_host.load
lrwxrwxrwx 1 root root 33 2009-09-14 12:40 authz_user.load -> ../mods-available/authz_user.load
lrwxrwxrwx 1 root root 32 2009-09-14 12:40 autoindex.conf -> ../mods-available/autoindex.conf
lrwxrwxrwx 1 root root 32 2009-09-14 12:40 autoindex.load -> ../mods-available/autoindex.load
lrwxrwxrwx 1 root root 26 2009-09-14 12:40 cgi.load -> ../mods-available/cgi.load
lrwxrwxrwx 1 root root 30 2009-09-14 12:40 deflate.conf -> ../mods-available/deflate.conf
lrwxrwxrwx 1 root root 30 2009-09-14 12:40 deflate.load -> ../mods-available/deflate.load
lrwxrwxrwx 1 root root 26 2009-09-14 12:40 dir.conf -> ../mods-available/dir.conf
lrwxrwxrwx 1 root root 26 2009-09-14 12:40 dir.load -> ../mods-available/dir.load
lrwxrwxrwx 1 root root 26 2009-09-14 12:40 env.load -> ../mods-available/env.load
lrwxrwxrwx 1 root root 40 2009-09-14 13:56 include.load -> /etc/apache2/mods-available/include.load
lrwxrwxrwx 1 root root 27 2009-09-14 12:40 mime.conf -> ../mods-available/mime.conf
lrwxrwxrwx 1 root root 27 2009-09-14 12:40 mime.load -> ../mods-available/mime.load
lrwxrwxrwx 1 root root 34 2009-09-14 12:40 negotiation.conf -> ../mods-available/negotiation.conf
lrwxrwxrwx 1 root root 34 2009-09-14 12:40 negotiation.load -> ../mods-available/negotiation.load
lrwxrwxrwx 1 root root 27 2009-09-14 12:40 php5.conf -> ../mods-available/php5.conf
lrwxrwxrwx 1 root root 27 2009-09-14 12:40 php5.load -> ../mods-available/php5.load
lrwxrwxrwx 1 root root 38 2009-09-14 13:56 proxy.conf -> /etc/apache2/mods-available/proxy.conf
lrwxrwxrwx 1 root root 33 2009-09-14 13:18 proxy_html.conf -> ../mods-available/proxy_html.conf
lrwxrwxrwx 1 root root 33 2009-09-14 13:18 proxy_html.load -> ../mods-available/proxy_html.load
lrwxrwxrwx 1 root root 43 2009-09-14 13:42 proxy_http.load -> /etc/apache2/mods-available/proxy_http.load
lrwxrwxrwx 1 root root 38 2009-09-14 13:56 proxy.load -> /etc/apache2/mods-available/proxy.load
lrwxrwxrwx 1 root root 31 2009-09-14 12:40 setenvif.conf -> ../mods-available/setenvif.conf
lrwxrwxrwx 1 root root 31 2009-09-14 12:40 setenvif.load -> ../mods-available/setenvif.load
lrwxrwxrwx 1 root root 29 2009-09-14 12:40 status.conf -> ../mods-available/status.conf
lrwxrwxrwx 1 root root 29 2009-09-14 12:40 status.load -> ../mods-available/status.load
« Last Edit: September 15, 2009, 02:58:01 PM by cratylus »

Offline cratylus

  • Your favorite and best
  • Administrator
  • ***
  • Posts: 1020
  • Cratylus@Dead Souls <ds> np
    • View Profile
    • About Cratylus
Re: Using Anyterm with Dead Souls
« Reply #1 on: September 15, 2009, 03:23:07 PM »
Some notes to provide a little more context.

Anyterm version:
It's my understanding that the currently released (1.1.29) stable
version of Anyterm does not properly handle an important feature that I think
is essential to using Anyterm for a mud, which is why the instructions
outline the use of a dev branch. What is that feature? Funny you ask...

Server Side Includes:
Here's the thing. The way anyterm works in this case, it basically lets
people telnet from the computer anytermd is on to the computer you specify
in its starttime arguments. This means that when someone connects to the mud,
they look like they're telnetting in from the anytermd server (usually
the same host as the mud).

This creates an administrative problem because if tons of people are coming
from the same IP, it is difficult to enforce things like bans.

There's a neat trick to anytermd, though. It can accept a token containing a
string that it uses as part of the command line. This token thingy is
the feature that I don't think works 100% in 1.1.29 and below.

By enabling server side includes we can send to the anytermd daemon the
ip address (in the token %p) that it can include in the command line.

This is useful because telnet has a subnegotiation feature called
NEW-ENVIRONMENT whose "user" variable is invoked in telnet with the -l
flag. It gets kinda complicated here, but the idea is this


1) Apache uses SSI to figure out the client IP.
2) This information is collected by the Anyterm javascript and web file.
3) The information is sent to the anytermd in the form of a string.
4) The connection initiated by anytermd includes this ip as the "user" NEW-ENv var.
5) The mud receives a connection that LOOKS normal to the player, but includes the ip.
6) Dead Souls then determines whether the info is legit, and if so, considers it the user's ip.

As you can see, if you're using Dead Souls on an older driver, or
not using Dead Souls at all, you may wind up being able to to use anyterm
but finding that the control over ip connections is no longer
possible at the mud level.

It is unusual for mud servers/drivers to handle NEW-ENVIRONMENT, but it's
not exactly rocket science to add. If you're on a Diku derivative mud,
you should visit http://mudbytes.net and do a search for MSSP. I think a
dev named Scandum has documented some ways of implementing telopts into
Diku-type muds, and there may even be snippets available.

-Crat

Offline quixadhal

  • BFF
  • ***
  • Posts: 631
    • View Profile
    • WileyMUD
Re: Using Anyterm with Dead Souls
« Reply #2 on: September 15, 2009, 07:05:36 PM »
Hmmm, interesting.

I may have to try using this for a different project.  I have a couple of old curses-based games that were popular, but which nobody really wants to use anymore because you had to have a login shell to run them (they just accessed files via locking, no client/server).  If anyterm supports a full ANSI terminal and provides the environment responses properly, I might be able to have it run the game client as their user id and let apache do the authentication.

I'll poke at it and let you know if it works.  Might also be a way to share nethack. :)

Offline Holyavenger

  • Friend
  • **
  • Posts: 92
    • View Profile
Re: Using Anyterm with Dead Souls
« Reply #3 on: January 15, 2011, 11:14:56 AM »
Really cool writeup with intriguing discourse. Thank you. As for the nethack reference, "now thats a name I havent heard since" 1985. ;D

Offline amylase

  • Friend
  • **
  • Posts: 75
    • View Profile
    • gpLand
Re: Using Anyterm with Dead Souls
« Reply #4 on: November 02, 2011, 02:48:07 PM »
Thanks for the clear instructions following which, with a bit of modifications and help of a friend, we managed to get it working on CentOS, running Dead Souls 3.0

I read numerous complaints of crashes of Dead Souls 3.2. Has anyone tried the latest 3.6 using with & without Anyterm with much trouble at all? Or have previous problems resolved?

If people are still having problems with 3.2+, I'll just leave mine as it is at 3.0. Otherwise I might try upgrading to 3.6 next week as I think DS3.0 doesn't handle multiple users same IP issue when logging on using Anyterm (fix was introduced to DS3.2 onwards).