Cannot use ICE when server is behind router

It crashed, it is bugged, ...
Post Reply
kentarii
Posts: 2
Joined: 04 Mar 2011, 13:59

Cannot use ICE when server is behind router

Post by kentarii »

The scenario is like this...

I have a server on my local network with the IP 10.0.0.10
The server's public IP is 123.123.123.123 (dummy ip)
I'm connecting from a host with IP 234.234.234.234 (another dummy ip)

To enable Ice and make it available on not just localhost, i edited murmur.ini and set the following:

Code: Select all

ice="tcp -h 0.0.0.0 -p 6502"
icesecretread=foobar
Then I started up murmur.x86 and got the following:

Code: Select all

<W>2011-03-04 15:13:22.549 MurmurIce: Endpoint "tcp -h 10.0.0.10 -p 6502" running
10.0.0.10:6502 and 10.0.0.10:64738 are portforwarded to external 123.123.123.123:6502 and 123.123.123.123:64738

So far, so good, I can connect to the mumble-server on port 64738 with a normal mumble client.
I can connect to the ICE port with telnet:

Code: Select all

telnet 123.123.123.123 6502
Trying 123.123.123.123...
Connected to 123.123.123.123.
Escape character is '^]'.
IceP
Then I wrote a small script using php-zeroc-ice (v3.3.1-12)
I can connect to the server and run some basic commands and get the result

Code: Select all

$icesecret = array('secret' => 'foobar');
global $ICE;
Ice_loadProfile();
$base = $ICE->stringToProxy('Meta:tcp -h 123.123.123.123 -p 6502');
$meta = $base->ice_checkedCast("::Murmur::Meta");
$meta = $meta->ice_context($icesecret);
$meta = $meta->ice_timeout(10000);

$meta->getVersion($major, $minor, $patch, $text);
print "Result of getVersion(): ". $major . '.' . $minor . '.' . $patch . ' ' . $text. "\n";

print "Result of getUptime(): ". $meta->getUptime() ." seconds\n";

$servers = $meta->getBootedServers();
print "Result of getBootedServers(): ". count($servers) ."\n";
print_r($servers);
I get the following output:

Code: Select all

[ 04. mars 2011 15:21:31.187 Network: trying to establish tcp connection to 123.123.123.123:6502 ]
[ 04. mars 2011 15:21:31.188 Network: tcp connection established
  local address = 234.234.234.234:59370
  remote address = 123.123.123.123:6502 ]
[ 04. mars 2011 15:21:31.196 Network: trying to establish tcp connection to 123.123.123.123:6502 ]
[ 04. mars 2011 15:21:31.198 Network: tcp connection established
  local address = 234.234.234.234:59371
  remote address = 123.123.123.123:6502 ]
Result of getVersion(): 1.2.3 Compiled Feb 19 2011 22:36:52
Result of getUptime(): 488 seconds
Result of getBootedServers(): 1
Array
(
    [0] => Ice_ObjectPrx Object
        (
        )

)
So far so good, now that I found a server, I'm going to try to get some information from that server:

Code: Select all

foreach ($servers as $server) {
    $server = $server->ice_context($icesecret);
    print "ID: ". $server->id() ."\n";
}
This is where things go wrong, the $server Ice_ObjectPrx is unaware of the server's external IP and assume that the server IP is the internal IP.

Code: Select all

[ 04. mars 2011 15:21:31.206 Network: trying to establish tcp connection to 10.0.0.10:6502 ]
[ 04. mars 2011 15:21:52.202 Network: failed to establish tcp connection
  local address = 234.234.234.234:59089
  remote address = <not connected>
  Network.cpp:1226: Ice::ConnectFailedException:
  connect failed: Connection timed out ]
[ 04. mars 2011 15:21:52.202 Network: closing tcp connection
  local address = 234.234.234.234:59089
  remote address = <not connected> ]
[ 04. mars 2011 15:21:52.203 Network: trying to establish tcp connection to 10.0.0.10:6502 ]
[ 04. mars 2011 15:21:55.202 Network: failed to establish tcp connection
  local address = 234.234.234.234:59092
  remote address = <not connected>
  Network.cpp:1226: Ice::ConnectFailedException:
  connect failed: Network is unreachable ]
[ 04. mars 2011 15:21:55.202 Network: closing tcp connection
  local address = 234.234.234.234:59092
  remote address = <not connected> ]
Ice_UnknownLocalException Object
(
    [unknown] => Network.cpp:1226: Ice::ConnectFailedException:
connect failed: Network is unreachable
    [message:protected] =>
    [string:Exception:private] =>
    [code:protected] => 0
    [file:protected] => /home/kentarii/mumble_ice.php
    [line:protected] => 37
    [trace:Exception:private] => Array
        (
            [0] => Array
                (
                    [file] => /home/kentarii/mumble_ice.php
                    [line] => 37
                    [function] => id
                    [class] => Ice_ObjectPrx
                    [type] => ->
                    [args] => Array
                        (
                        )

                )

        )
    [previous:Exception:private] =>
)
It makes sense that I'm not able to connect to 10.0.0.10 from my 234.234.234.234 IP. So I guess the issue here is that $meta->getAllServers() and $meta->getBootedServers() return array with ice objects which is not aware of the server's external IP.
My question is, why can't it inherit the remote address from the $meta object?

Post Reply