Difference between revisions of "Ice"

From Mumble Wiki
Jump to: navigation, search
m (How to set up a Windows web server and use the ICE php scripts)
m (ICE -> Ice)
Line 1: Line 1:
Murmur supports remote scripting using [http://www.zeroc.com/ ZeroC ICE], a RPC mechanism. There are bindings for C++, Java, .NET, Python, PHP and Ruby, and this is supported on all our platforms (Win32, Linux and OSX). ICE also works over a network, meaning you can create a web application that interfaces with a murmur process running on another machine.
+
Murmur supports remote scripting using [http://www.zeroc.com/ ZeroC Ice], a RPC mechanism. There are bindings for C++, Java, .NET, Python, PHP and Ruby, and this is supported on all our platforms (Win32, Linux and OSX). Ice also works over a network, meaning you can create a web application that interfaces with a murmur process running on another machine.
  
= Getting ready to use ICE =
+
= Getting ready to use Ice =
  
You can download ICE directly from ZeroC. If you installed a binary version of Murmur, it already includes the necessary components for running ICE, but you might need additional tools to develop with it.
+
You can download Ice directly from ZeroC. If you installed a binary version of Murmur, it already includes the necessary components for running Ice, but you might need additional tools to develop with it.
  
To enable ICE in your murmur.ini configuration file first comment out
+
To enable Ice in your murmur.ini configuration file first comment out
 
  dbus=session
 
  dbus=session
 
to disable dbus and add
 
to disable dbus and add
 
  ice="tcp -h 127.0.0.1 -p 6502"
 
  ice="tcp -h 127.0.0.1 -p 6502"
to enable ICE for localhost on port 6502.
+
to enable Ice for localhost on port 6502.
  
To check if ICE in fact does listen, type
+
To check if Ice in fact does listen, type
 
  netstat -apn | grep 6502
 
  netstat -apn | grep 6502
  
 
== Apache and PHP ==
 
== Apache and PHP ==
  
If you want to use ICE from PHP, you'll have to add the extension to php and tell php where to find the Murmur.ice file.
+
If you want to use Ice from PHP, you'll have to add the extension to php and tell php where to find the Murmur.ice file.
  
 
To add the IcePHP extension to php, first check that the file IcePHP.so for linux, or php_ice.dll for windows is in your php extensions folder specified in your php.ini as  
 
To add the IcePHP extension to php, first check that the file IcePHP.so for linux, or php_ice.dll for windows is in your php extensions folder specified in your php.ini as  
Line 26: Line 26:
 
At least the linux rpms will do this automatically, so check that you're not doing it a second time.
 
At least the linux rpms will do this automatically, so check that you're not doing it a second time.
  
Second, you have to tell the PHP parser where to find the slice ('''S'''pecification '''L'''anguage for '''ICE''') file.
+
Second, you have to tell the PHP parser where to find the slice ('''S'''pecification '''L'''anguage for '''Ice''') file.
 
Add
 
Add
 
  ice.slice = /path/to/Murmur.ice
 
  ice.slice = /path/to/Murmur.ice
Line 40: Line 40:
 
then make, and in the lib folder, there'll be your IcePHP.so file.
 
then make, and in the lib folder, there'll be your IcePHP.so file.
  
= Using ICE =
+
= Using Ice =
  
How to use ICE differs from language to language. The parameters and method names will remain the same, but the syntax will naturally be different. Murmur will, by default, open up an adapter on port 6502 (or 10000 for homedir installs), which has a single accessible object named "Meta". This is the Meta server, and from it you can retrieve adapters for any configured server.
+
How to use Ice differs from language to language. The parameters and method names will remain the same, but the syntax will naturally be different. Murmur will, by default, open up an adapter on port 6502 (or 10000 for homedir installs), which has a single accessible object named "Meta". This is the Meta server, and from it you can retrieve adapters for any configured server.
  
 
There's an example included in the source; have a look at [http://mumble.svn.sourceforge.net/viewvc/mumble/trunk/scripts/icedemo.php?view=markup icedemo.php].
 
There's an example included in the source; have a look at [http://mumble.svn.sourceforge.net/viewvc/mumble/trunk/scripts/icedemo.php?view=markup icedemo.php].
Line 141: Line 141:
 
--[[User:xenonR|xenonR]] 13:02, 06 April 2009 (UTC)
 
--[[User:xenonR|xenonR]] 13:02, 06 April 2009 (UTC)
  
= How to set up a Windows web server and use the ICE php scripts =
+
= How to set up a Windows web server and use the Ice php scripts =
  
These are example scripts. Use at your own risk. These scripts are not intended for production machines. These are examples of what ICE can do. Note that if you already have a web server installed on the server you can adapt this guide to use it instead of installing Apache.
+
These are example scripts. Use at your own risk. These scripts are not intended for production machines. These are examples of what Ice can do. Note that if you already have a web server installed on the server you can adapt this guide to use it instead of installing Apache.
  
 
First install [http://apache.mirror.facebook.com/httpd/binaries/win32/apache_2.2.11-win32-x86-openssl-0.9.8i.msi Apache]. Install it to ''C:\apache\''.  
 
First install [http://apache.mirror.facebook.com/httpd/binaries/win32/apache_2.2.11-win32-x86-openssl-0.9.8i.msi Apache]. Install it to ''C:\apache\''.  
Line 174: Line 174:
 
= Using Glacier2 =
 
= Using Glacier2 =
  
Glacier2 is a ICE routing and firewall utility, and allows you to securely run the server on one machine and murmur on another. Note that if both server and client are on a secure LAN, you can just use iptables to protect the ICE port, which is a lot easier than setting up Glacier2.
+
Glacier2 is a Ice routing and firewall utility, and allows you to securely run the server on one machine and murmur on another. Note that if both server and client are on a secure LAN, you can just use iptables to protect the Ice port, which is a lot easier than setting up Glacier2.
  
 
The examples here assume that 1.2.3.4 is the public IP address of the server running Murmur. We're going to use the username "magic" with the password "pink".
 
The examples here assume that 1.2.3.4 is the public IP address of the server running Murmur. We're going to use the username "magic" with the password "pink".
Line 195: Line 195:
 
   glacier2router --Ice.Config=config.glacier2
 
   glacier2router --Ice.Config=config.glacier2
  
You will need to have ICE installed - http://zeroc.com/download.html glacier2router is a binary that is located in ''<location_of_ICE_installation>/bin/glacier2router.exe.''
+
You will need to have Ice installed - http://zeroc.com/download.html glacier2router is a binary that is located in ''<location_of_Ice_installation>/bin/glacier2router.exe.''
  
 
== Configuring Murmur ==
 
== Configuring Murmur ==
Line 203: Line 203:
 
== Configuring Client (PHP) ==
 
== Configuring Client (PHP) ==
  
This is where it starts getting slightly ugly. Note that this requires ICE >= 3.3.1, as Ice 3.3.0 has a bug in it which prevents this from working. The following is the adaptation necessary to weblist.php to get it to work:
+
This is where it starts getting slightly ugly. Note that this requires Ice >= 3.3.1, as Ice 3.3.0 has a bug in it which prevents this from working. The following is the adaptation necessary to weblist.php to get it to work:
  
 
<pre>
 
<pre>

Revision as of 03:16, 22 May 2009

Murmur supports remote scripting using ZeroC Ice, a RPC mechanism. There are bindings for C++, Java, .NET, Python, PHP and Ruby, and this is supported on all our platforms (Win32, Linux and OSX). Ice also works over a network, meaning you can create a web application that interfaces with a murmur process running on another machine.

Getting ready to use Ice

You can download Ice directly from ZeroC. If you installed a binary version of Murmur, it already includes the necessary components for running Ice, but you might need additional tools to develop with it.

To enable Ice in your murmur.ini configuration file first comment out

dbus=session

to disable dbus and add

ice="tcp -h 127.0.0.1 -p 6502"

to enable Ice for localhost on port 6502.

To check if Ice in fact does listen, type

netstat -apn | grep 6502

Apache and PHP

If you want to use Ice from PHP, you'll have to add the extension to php and tell php where to find the Murmur.ice file.

To add the IcePHP extension to php, first check that the file IcePHP.so for linux, or php_ice.dll for windows is in your php extensions folder specified in your php.ini as

extension_dir = /usr/lib/php5/extensions

If it is not, get the correspoding files from ZeroCs downloads page.

Then either in your php.ini file or in your /etc/php.d or /etc/php5/conf.d folder in ice.ini, add the line

extension=IcePHP.so

At least the linux rpms will do this automatically, so check that you're not doing it a second time.

Second, you have to tell the PHP parser where to find the slice (Specification Language for Ice) file. Add

ice.slice = /path/to/Murmur.ice

to your php.ini or other config file (ice.ini).

Troubleshooting

If you encounter problems, check your apache log.

If it tells you the php extension was compiled on an older api, you have to compile the IcePHP.so from source.

Download Ice-3.3.0.tar.gz from ZeroCs downloads page, untar, cd, cd into php, as written in the INSTALL file export ICE_HOME environment variable pointing to your ice install dir. If you installed it with an rpm, type

export ICE_HOME=/usr

then make, and in the lib folder, there'll be your IcePHP.so file.

Using Ice

How to use Ice differs from language to language. The parameters and method names will remain the same, but the syntax will naturally be different. Murmur will, by default, open up an adapter on port 6502 (or 10000 for homedir installs), which has a single accessible object named "Meta". This is the Meta server, and from it you can retrieve adapters for any configured server.

There's an example included in the source; have a look at icedemo.php.

The ice interface is fully documented, and you can browse the generated documentation.

How to set up a Debian web server to work with ZeroC-Ice

These are example scripts. Use at your own risk.

This guide is for debian 5.0 (lenny) -upgraded to date 06.04.2009-

I assume you already have a working apache2 and php environment.


Prerequisites

First we need some essentials to aquire these execute the following in a root shell

apt-get update

apt-get install mumble-server libzeroc-ice32 php-zeroc-ice lzma

These are namely the Mumble server himself (mumble-server), the ZeroC-Ice C++ runtime Library (libzeroc-ice32), the Ice PHP extension (php-zeroc-ice) and the lzma extractor. Be aware that this installs a older server version WITHOUT Ice support. We will fix this later on.

Additionally we need the current Murmur, thats what the Mumble server is called, release.

Go to http://mumble.sourceforge.net/ and download the latest stable Static Linux Server. I suggest your home directory for that.

cd ~
wget http://switch.dl.sourceforge.net/sourceforge/mumble/murmur-static_x86-1.1.8.tar.lzma
unlzma -v murmur-static_x86-1.1.8.tar.lzma
tar xfv murmur-static_x86-1.1.8.tar


Step 1 - Murmur Setup

OPTIONAL: To run Murmur at every startup change the config value in /etc/default/mumble-server acordingly with a editor of your choice.

Now open the file /etc/mumble-server.ini

vim /etc/mumble-server.ini

OR

nano -w /etc/mumble-server.ini 

Uncomemnt the line that starts with dbus=

#dbus=system

Create a new line and paste

ice="tcp -h 127.0.0.1 -p 6502"

Murmur now knows that he should listen for Ice requests.


Step 2 - Manual update Murmur

First of all why did we installed a old version first to replace it now?

It's easy, we have much less to do. Anyway there is a downside.

When the package is updated in the repository you will probably break your Ice support. But i think thats the best way and you can easily fix that just with replacing the murmurd binary again.

You alread extracted the Static Linux Server to your home directory. Now we need some files from there.

First replace the repository binary with the manually downloaded one.

cd ~/murmur-static_x86-1.1.8
chmod +x ./murmur.x86
cp murmur.x86 /usr/sbin/murmurd

Now copy the Ice specification for murmur.

cp Murmur.ice /var/lib/mumble-server/Murmur.ice


Step 3 - PHP Setup Now we need to tell the PHP-Ice Extension where the Ice specification file can be found. You should already have a file /etc/php5/conf.d/IcePHP.ini from your PHP module install. Open it with a editor.

vim /etc/php5/conf.d/IcePHP.ini

OR

nano -w /etc/php5/conf.d/IcePHP.ini

Paste the folowing in a new line at the end of the file

ice.slice = /var/lib/mumble-server/Murmur.ice

Step 4 - Relaod and Check

Everything needed should be done now let us populate your new settings.

Restart your apache2.

/etc/init.d/apache2 restart

And start your Mumble server

/etc/init.d/mumble-server start

Now we will take a look in the mumble-server log to see if everything is fine.

tail -n10 /var/log/mumble-server/mumble-server.log

If you find a line similar to the following

...
<W>2009-04-06 13:37:11.316 MurmurIce: Endpoint "tcp -h 127.0.0.1 -p 6502" running
...

everything is fine and you can now comunicate to Murmur over the IcePHP extension.

Again be aware of that you can break your Ice support when the package gets an update in the repository!

--xenonR 13:02, 06 April 2009 (UTC)

How to set up a Windows web server and use the Ice php scripts

These are example scripts. Use at your own risk. These scripts are not intended for production machines. These are examples of what Ice can do. Note that if you already have a web server installed on the server you can adapt this guide to use it instead of installing Apache.

First install Apache. Install it to C:\apache\.

Now install PHP. Tell PHP to install to C:\PHP5\. In the installer on the "Web Server Setup" window select Apache 2.2.x Module. When you get to "Select Apache Configuration Directory" put C:\apache\conf\. Proceed through the installer. Install the defaults, you do not need to install the extensions for PHP.

Now download and install Ice-x.x.x-VC60.msi. Go to C:\Ice-3.3.1-VC60\bin\ and copy

bzip2.dll 
ice33.dll 
iceutil33.dll 
msvcp60.dll 
msvcrt.dll 
php_ice.dll 
slice33.dll 
stlport_vc646.dll 

to C:\apache\bin . Now open C:\PHP5\php.ini and add the following two lines to the bottom of the file:

extension=php_ice.dll
ice.slice=C:\PHP5\Murmur.ice

Now save and exit php.ini.

After you have done all that, download Murmur.ice, icedemo.php, and weblist.php (Click the links, and on the Sourceforge page right click on "(download)" and select "Save Link As...".) Put Murmur.ice in C:\PHP5. Put icedemo.php and weblist.php in C:\apache\htdocs.

Double click the Apache icon in the system tray and select "Restart".

You now need at least one running Murmur server. Go to C:\Program Files\Mumble and double click murmur.exe and the server will start.

You should now be able to go to http://<your IP or Domain>/icedemo.php (or weblist.php). Make SURE that you have icedemo.php protected so that only YOU can access it. If you do not want to use icedemo.php, here is a list of other web interfaces you can use.

Using Glacier2

Glacier2 is a Ice routing and firewall utility, and allows you to securely run the server on one machine and murmur on another. Note that if both server and client are on a secure LAN, you can just use iptables to protect the Ice port, which is a lot easier than setting up Glacier2.

The examples here assume that 1.2.3.4 is the public IP address of the server running Murmur. We're going to use the username "magic" with the password "pink".

Configuring Glacier2

Create a config file called config.glacier2 and put the following in it:

 Glacier2.Client.Endpoints=tcp -h 1.2.3.4 -p 4063
 Glacier2.SessionTimeout=60
 Glacier2.CryptPasswords=passwords.txt

Then, create a password hash using the OpenSSL utility.

 openssl passwd pink

this will spit out a hash, which looks something like CTThafhdv9Lz2

Create a file called passwords.txt containing:

 magic CTThafhdv9Lz2

Start glacier2 as this:

 glacier2router --Ice.Config=config.glacier2

You will need to have Ice installed - http://zeroc.com/download.html glacier2router is a binary that is located in <location_of_Ice_installation>/bin/glacier2router.exe.

Configuring Murmur

There's nothing to do in murmur. Seriously. Leave the default setting of binding to 127.0.0.1 alone.

Configuring Client (PHP)

This is where it starts getting slightly ugly. Note that this requires Ice >= 3.3.1, as Ice 3.3.0 has a bug in it which prevents this from working. The following is the adaptation necessary to weblist.php to get it to work:

try {
  $router = $ICE->stringToProxy("Glacier2/router:tcp -p 4063 -h 1.2.3.4");
  $router = $router->ice_uncheckedCast("::Glacier2::Router")->ice_router(null);
  $session = $router->createSession("magic", "pink");
  $base = $ICE->stringToProxy("Meta:tcp -h 127.0.0.1 -p 6502")->ice_router($router);
  $meta = $base->ice_checkedCast("::Murmur::Meta")->ice_router($router);

  ...

For each object you get a proxy to (including the return from $meta->getServer), you need to add ->ice_router($router)