Skip to content

anantn/web9

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

86 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Welcome

The Web9 project is about making the 9P protocol accessible to web developers. The project involves developing PHP and Javascript implementations of the protocol and some applications that utilize the implementations.

The project currently consists of the following components:

  • PHP9P: Bindings over the libixp library to provide an efficient and usable 9P development toolkit for PHP

  • Net_9P: A pure PHP implementation of 9P, suitable for inclusion in PEAR. Not as efficient as PHP9P, but extremely valuable in environments where PHP extensions cannot be loaded.

  • JS9P: A pure Javascript implementation of 9P. May use one of the following transport mechanisms:

    • XHR: Uses XMLHttpRequest as a transport to send and receive 9P messages. Requires a relay server at the other end.
    • Angled: Uses Mozilla's XPConnect and can directly connect to 9P servers. Also a Firefox extension.

This project was funded by Google, under their Summer of Code program for Plan 9 from Bell Labs. Many thanks to Devon H. O'Dell and Matt Lawless for mentoring the project.

Source

Web9 uses Mercurial for version control. To check out the code to a local repository:

git clone https://github.com/anantn/web9.git

You will find three directories: Net_9P, js9p and php9p when you check out the web9 sources. js9p corresponds to the JavaScript implemetation of 9P, while php9p is the PHP binding to libixp. Net_9P is a (currently incomplete) implementation of 9P in pure PHP.

PHP9P

php9p is a PHP 5.2+ extension that works on POSIX systems only. The extension exports two classes IxpClient and IxpServer for you to access and create 9P filesystems. The documentation for them is incomplete, please have a look in the php9p/examples directory for sample usage. Read the INSTALL file for instructions on installing php9p.

JS9P

js9p consists of three parts. The main file is js9p.js which exports the JS9P.Base object. The object provides methods to encode and decode the 14 types of 9P messages. Encoded messages are returned either as raw, unpacked strings or as Base64-encoded strings. You can control endian-ness and Base64'edness using the JS9P.Base.setBigEndian and JS9P.Base.setBase64 methods. By default, Base64 encoding is turned on and all data is encoded in the little-endian format.

Once messages are created, you actually need some transport to send it via. JS9P provides two methods of doing do.

Angled is a firefox extension to access 9P resources. It uses JS9P.Base and provides its own JS9P.Angled object to communicate with a 9P server via XPCOM's sockets. The extension handles all URI's beginning with ninep://

XHR provides the JS9P.XHR object which is responsible for sending messages generated by JS9P.Base via an XMLHttpRequest. Naturally, you'd need a listener on the HTTP server, which is provided by listener.php. Messages generated by JS9P.Base are collected by JS9P.XHR and sent as a comma-seperated list of Base64 encoded messages to listener.php. listener.php then sends those messages via a TCP socket to the 9P server and records responses into a JSON-encoded array in Base64 format. JS9P.XHR then calls JS9P.Base to decode the messages one-by-one. Note that XHR is a very inefficient transport, as you need to perform the version and attach messages everytime a new request is generated.

License

Web9 is licensed under a combination of the MIT, MPL and LPL licenses. Refer to the source code for more details on which licenses apply to particular modules.

Screenshots

View a text file over JS9P/Angled

Text Read

View an image file JS9P/Angled

Image Read

Error in JS9P/Angled

Error

IXP9 Sample App Home Screen

IXP9 Start

IXP9 Sample App View Contents

IXP9 View