hsdn / lg

PHP Version of BGP Looking Glass script, based on the Perl sources: https://github.com/Cougar/lg
Other
41 stars 33 forks source link

BGP Graph size not automated #8

Closed chathurag closed 6 years ago

chathurag commented 6 years ago

Used given configurations to display bgp graph, however it displays as follows with scroll bars. Unable to get size automatically. lg

justkeepquiet commented 6 years ago

Hi, what browser do you use? In Chrome and Firefox works fine by dafault on any graphs.

chathurag commented 6 years ago

Chrome - Version 63.0.3239.132 (Official Build) (64-bit) lg

Firefox - 42.0 lg1

On both browsers I can see scroll bars.

justkeepquiet commented 6 years ago

You see graph size problems on this link? http://lg.hsdn.org/?command=graph&protocol=ipv4&query=8.8.8.8&router=test

chathurag commented 6 years ago

No Its fine. lg

Use the following link to check. http://lg.lankabell.com/index.php.bak

UN - test PWD - test

justkeepquiet commented 6 years ago

For fine working the pages, you need to use the html doctype of original version of LG script. Also, you need use latest version of script with changes in html. Please update to latest version.

chathurag commented 6 years ago

I have used the Latest one. Still same. Is this because of graphviz tool?

justkeepquiet commented 6 years ago

I see the following html on your LG site:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>

This is not a latest version of html part. For correct working, you need all code from the current version of script.

justkeepquiet commented 6 years ago

And, the graphviz tool (svg document) does not affect this. The problem on rendering an html page. I guess this is related to the doctype and the order of loading html tags. In the latest version, there are no such problems, you see this on our LG website.

chathurag commented 6 years ago

Hello Please check.

DOCTYPE is changed.

http://lg.lankabell.com

chathurag commented 6 years ago

http://lg.lankabell.com/?command=graph&protocol=ipv4&query=8.8.8.8&router=example

justkeepquiet commented 6 years ago

Please use the following config for tests (the "AT&T example" not working now):

    'test5' => array
    (
        'url' => 'telnet://route-server.eastlink.ca:23',
        'pingtraceurl' => FALSE,
        'description' => 'TEST5',
        'group' => 'TEST',
        'ipv6' => TRUE,
        'os' => 'ios',
    ),

More Telnet route-servers for tests you can find on this site: http://traceroute.org/#Route%20Servers

chathurag commented 6 years ago

I have added our own router.

However I still get the graph in same way.

Can be this be because of PHP version, Apache version.

http://lg.lankabell.com/?command=graph&protocol=ipv4&query=8.8.8.8&router=SLIC-LG-001

UN = test PWD=test

justkeepquiet commented 6 years ago

I found the problem. Your server sends an svg document as text/html, but should send it as image/svg+xml. Probably, your server disables the header() php function in the Image_GraphViz library. This function needed for set the correct Content-Type. See your server settings, maybe it's security settings php.

The same problem with the rendering of png, the link does not show: http://lg.lankabell.com/?command=graph&protocol=ipv4&query=8.8.8.8&router=SLIC-LG-001&render=png

And should works fine like this: http://lg.hsdn.org/?command=graph&protocol=ipv4&query=8.8.8.8&router=test5&render=png

In any case, this is not a LG script error.

justkeepquiet commented 6 years ago

Also, please check your php.ini, you need to enable a Output Buffering by setting:

output_buffering = 4096

If you use nginx server as front-end, you need set the following settings in the nginx config for disable buffering and gzip compression in the proxying:

gzip off;
proxy_buffering off;
chathurag commented 6 years ago

Output buffering is set to 4096,

However could you please let me know how to set content type?

justkeepquiet commented 6 years ago

The Image_GraphViz library does this in these lines of code (see GraphViz.php in your Pear include dir):

...
        case 'gif':
        case 'png':
        case 'bmp':
        case 'jpeg':
        case 'tiff':
            header('Content-Type: image/' . $format);
            break;
...
        case 'svg':
            header('Content-Type: image/svg+xml');
            break;
...

You do not need to set the Content-Type manually in script.

chathurag commented 6 years ago

I need to know how can I enable this with php?

justkeepquiet commented 6 years ago

By default, it is not disabled. Probably, this is some kind of problem with the server.

Check the work of the headers by creating a simple script:

<?php
$im = imagecreatetruecolor(120, 20);
$text_color = imagecolorallocate($im, 233, 14, 91);
imagestring($im, 1, 5, 5,  'A Simple Text String', $text_color);
header('Content-Type: image/jpeg');
imagejpeg($im);
imagedestroy($im);

And open it in your browser. If works, you should see the image with text, like this http://dev.hsdn.org/gd_test.php

chathurag commented 6 years ago

http://lg.lankabell.com/a.php

It works.

chathurag commented 6 years ago

however graph is still same

justkeepquiet commented 6 years ago

I do not know how to solve this problem. this is a server problem, not a bug in the script.

justkeepquiet commented 6 years ago

Try to add a following lines to LG script (for tests):

    switch ($format)
    {
        case 'png':
            header('Content-Type: image/png');
            break;

        case 'svg':
            header('Content-Type: image/svg+xml');
            break;
    }

before the lines:

    $graph->image($format);
    exit;
chathurag commented 6 years ago

Fixed by upgrading php from 5.3 to 5.4

justkeepquiet commented 6 years ago

Ok, thanks for this information.