Compare commits
21 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
286d892703 | ||
|
a5bd259466 | ||
|
c4bfe0624e | ||
|
f87a19fa1e | ||
|
cbb1a95b64 | ||
|
05ea20c332 | ||
|
10c9e545d0 | ||
|
b453e719f7 | ||
|
4a95d3854f | ||
|
91b36725a3 | ||
|
4db24c99d1 | ||
|
761c00740f | ||
|
24445308dc | ||
|
fb6a7a83e9 | ||
|
4906fd0227 | ||
|
531c39ab90 | ||
|
c7339f04cf | ||
|
900c29f255 | ||
|
7759c1c1fb | ||
|
4723633bcc | ||
|
87b343749d |
@ -348,7 +348,7 @@ class LookingGlass
|
||||
if ($type === 'mtr') {
|
||||
// correct output for mtr
|
||||
$parser->update($str);
|
||||
echo '---'.PHP_EOL.$parser->__toString().PHP_EOL.str_pad('', 4096).PHP_EOL;
|
||||
echo '@@@'.PHP_EOL.$parser->__toString().PHP_EOL.str_pad('', 4096).PHP_EOL;
|
||||
|
||||
// flush output buffering
|
||||
@ob_flush();
|
||||
|
22
README.md
22
README.md
@ -17,7 +17,7 @@ made user-friendly for everyone to use. It allows you to execute network related
|
||||
- Dark/light/auto mode theme.
|
||||
|
||||
### Requirements
|
||||
- Any Linux distribution, this has been tested on RHEL 8 + 9.
|
||||
- Any Linux distribution, this has been tested on RHEL 8 + 9, for NetBSD users see [#47](https://github.com/hybula/lookingglass/issues/47).
|
||||
- PHP 7.1 or higher, PHP 8 preferred.
|
||||
- IPv6 connectivity if you want to use the v6 equivalents.
|
||||
- Root access.
|
||||
@ -29,7 +29,7 @@ Note: These steps also work with AlmaLinux 9, but it will install PHP 8 instead
|
||||
|
||||
1. Install the required network tools: `dnf install mtr traceroute -y`.
|
||||
2. Install the web server with PHP (by default it will install 7.2 on RHEL 8): `dnf install httpd mod_ssl php php-posix -y`.
|
||||
3. Enable and start Apache/PHP-FPM: `systemctl enable httpd; systemctl enable php-fpm` and `systemctl start httpd; systemctl start php-fpm`.
|
||||
3. Enable and start Apache/PHP-FPM: `systemctl enable --now httpd && systemctl enable --now php-fpm`.
|
||||
4. Let's help MTR to work, execute the following command: `ln -s /usr/sbin/mtr /usr/bin/mtr` and also mtr helper called mtr-packet: `ln -s /usr/sbin/mtr-packet /usr/bin/mtr-packet`.
|
||||
5. You *must* configure SELinux before this all works, or you can disable SELinux using `setenforce 0` and possibly make it permanent: `nano /etc/selinux/config` change to `SELINUX=disabled`.
|
||||
6. Upload the contents of the ZIP to /var/www/html/.
|
||||
@ -47,6 +47,24 @@ For installation using Docker, follow these steps and run the commands on the ta
|
||||
6. Create and start the containers: `docker compose up -d`.
|
||||
7. Afterward, the Looking Glass should be reachable from your web browser at `http://$your_server_ip/`!
|
||||
|
||||
### iPerf3 Installation (Optional)
|
||||
> It is recommended to install iPerf3 on a different server from your looking glass to avoid network congestion.
|
||||
|
||||
#### Manual
|
||||
Again, we will assume that we are working on AlmaLinux 8 or 9.
|
||||
1. Install iPerf3: `dnf install iperf3 -y`
|
||||
2. Launch iPerf3 as a daemon: `iperf3 -sD -p 5201`.
|
||||
3. (Optional) You might want to add a systemd unit file for iPerf3, so it automatically starts when the system boots up.
|
||||
4. Locate the two lines containing `LG_SPEEDTEST_CMD_INCOMING` and `LG_SPEEDTEST_CMD_OUTGOING` respectively in `config.php`.
|
||||
5. Change `hostname` in these lines to the IPv4 address of your iPerf3 server.
|
||||
|
||||
#### Docker
|
||||
1. Uncomment the section for `iperf3` in `docker-compose.yml` if you want iPerf3 and the looking glass to be on the same server.
|
||||
Otherwise, please copy the `iperf3` section and save it as `docker-compose.yml` on another server with Docker and Docker Compose installed.
|
||||
2. Start the iPerf3 container: `docker compose up -d`.
|
||||
3. Locate the two lines containing `LG_SPEEDTEST_CMD_INCOMING` and `LG_SPEEDTEST_CMD_OUTGOING` respectively in `docker/php-fpm/src/config.php`.
|
||||
5. Change `hostname` in these lines to the IPv4 address of your iPerf3 server.
|
||||
|
||||
### Upgrading
|
||||
Upgrading from a previous version is easy, simply overwrite your current installation with the new files. Then update your config.php accordingly, the script will automatically check for missing variables.
|
||||
|
||||
|
@ -15,7 +15,7 @@ const LG_LOGO_URL = 'https://github.com/hybula/lookingglass/';
|
||||
const LG_THEME = 'auto';
|
||||
|
||||
// Enable the latency check feature;
|
||||
const LG_CHECK_LATENCY = false;
|
||||
const LG_CHECK_LATENCY = true;
|
||||
|
||||
// Define a custom CSS file which can be used to style the LG, set false to disable, else point to the CSS file;
|
||||
const LG_CSS_OVERRIDES = false;
|
||||
|
@ -1,20 +1,20 @@
|
||||
version: "3.8"
|
||||
|
||||
services:
|
||||
nginx:
|
||||
image: hybula/lookingglass-nginx:1
|
||||
container_name: lg-nginx
|
||||
build:
|
||||
context: docker/nginx
|
||||
dockerfile: Dockerfile
|
||||
ports:
|
||||
- "80:80"
|
||||
context: .
|
||||
dockerfile: docker/nginx/Dockerfile
|
||||
network_mode: host
|
||||
restart: unless-stopped
|
||||
|
||||
php-fpm:
|
||||
image: hybula/lookingglass-php:1
|
||||
container_name: lg-php
|
||||
build:
|
||||
context: .
|
||||
dockerfile: docker/php-fpm/Dockerfile
|
||||
network_mode: host
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
# For a better reference as to what these variables do, check out 'config.dist.php' or 'docker/php-fpm/src/config.php'.
|
||||
@ -22,6 +22,9 @@ services:
|
||||
LOCATION: Location
|
||||
FACILITY: Facility
|
||||
FACILITY_URL: http://localhost/
|
||||
LOGO_URL: https://github.com/hybula/lookingglass/
|
||||
LOGO: '<h2 style="color: #000000;">Company Looking Glass</h2>'
|
||||
LOGO_DARK: '<h2 style="color: #ffffff;">Company Looking Glass</h2>'
|
||||
IPV4_ADDRESS: 127.0.0.1
|
||||
IPV6_ADDRESS: ::1
|
||||
MAPS_QUERY: Amsterdam
|
||||
@ -33,3 +36,12 @@ services:
|
||||
# ENABLE_CUSTOM_BLOCK: 'true'
|
||||
# Uncomment if you require visitors to accept the Terms of Use; the value should be a link to the terms.
|
||||
# LG_TERMS: http://localhost/
|
||||
|
||||
# iperf3:
|
||||
# image: networkstatic/iperf3:latest
|
||||
# container_name: lg-iperf3
|
||||
# network_mode: host
|
||||
# command: -s
|
||||
# tty: true
|
||||
# stdin_open: true
|
||||
# restart: unless-stopped
|
||||
|
@ -1,3 +1,3 @@
|
||||
FROM nginx:mainline-alpine
|
||||
|
||||
COPY nginx.conf /etc/nginx/nginx.conf
|
||||
COPY docker/nginx/nginx.conf /etc/nginx/nginx.conf
|
||||
|
@ -41,7 +41,7 @@ http {
|
||||
|
||||
location ~ \.php$ {
|
||||
fastcgi_split_path_info ^(.+\.php)(/.+)$;
|
||||
fastcgi_pass php-fpm:9000;
|
||||
fastcgi_pass localhost:9000;
|
||||
fastcgi_index index.php;
|
||||
include fastcgi.conf;
|
||||
fastcgi_buffering on;
|
||||
|
@ -1,9 +1,11 @@
|
||||
FROM php:8.1-fpm-bullseye
|
||||
FROM php:8.4-fpm-bullseye
|
||||
|
||||
RUN apt-get update && \
|
||||
apt-get --no-install-recommends -y install iputils-ping mtr traceroute && \
|
||||
apt-get --no-install-recommends -y install iputils-ping mtr traceroute iproute2 && \
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
|
||||
RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini"
|
||||
|
||||
WORKDIR /var/www/html
|
||||
|
||||
COPY --chown=www-data:www-data . .
|
||||
|
@ -5,17 +5,17 @@ use Hybula\LookingGlass;
|
||||
const LG_TITLE = 'Looking Glass';
|
||||
|
||||
// Define a logo, this can be HTML too, see the other example for an image;
|
||||
const LG_LOGO = '<h2 style="color: #000000;">Company Looking Glass</h2>';
|
||||
const LG_LOGO_DARK = '<h2 style="color: #ffffff;">Company Looking Glass</h2>';
|
||||
define('LG_LOGO', getenv('LOGO'));
|
||||
define('LG_LOGO_DARK', getenv('LOGO_DARK'));
|
||||
|
||||
// Define the URL where the logo points to;
|
||||
const LG_LOGO_URL = 'https://github.com/hybula/lookingglass/';
|
||||
// Define the URL where the logo points to;
|
||||
define('LG_LOGO_URL', getenv('LOGO_URL'));
|
||||
|
||||
// Theme mode;
|
||||
const LG_THEME = 'auto';
|
||||
|
||||
// Enable the latency check feature;
|
||||
const LG_CHECK_LATENCY = false;
|
||||
const LG_CHECK_LATENCY = true;
|
||||
|
||||
// Define a custom CSS file which can be used to style the LG, set false to disable, else point to the CSS file;
|
||||
const LG_CSS_OVERRIDES = false;
|
||||
@ -23,11 +23,11 @@ const LG_CSS_OVERRIDES = false;
|
||||
const LG_CUSTOM_HEAD = false;
|
||||
|
||||
// Enable or disable blocks/parts of the LG, pass these environment variables with any value to disable them;
|
||||
define('LG_BLOCK_NETWORK', !isset($_ENV['DISABLE_BLOCK_NETWORK']));
|
||||
define('LG_BLOCK_LOOKINGGLASS', !isset($_ENV['DISABLE_BLOCK_LOOKINGGLASS']));
|
||||
define('LG_BLOCK_SPEEDTEST', !isset($_ENV['DISABLE_BLOCK_SPEEDTEST']));
|
||||
define('LG_BLOCK_NETWORK', !getenv('DISABLE_BLOCK_NETWORK'));
|
||||
define('LG_BLOCK_LOOKINGGLASS', !getenv('DISABLE_BLOCK_LOOKINGGLASS'));
|
||||
define('LG_BLOCK_SPEEDTEST', !getenv('DISABLE_BLOCK_SPEEDTEST'));
|
||||
// This enables the custom block, which you can use to add something custom to the LG;
|
||||
define('LG_BLOCK_CUSTOM', isset($_ENV['ENABLE_CUSTOM_BLOCK']));
|
||||
define('LG_BLOCK_CUSTOM', getenv('ENABLE_CUSTOM_BLOCK'));
|
||||
|
||||
// Define a file here which will be used to display the custom block, can be PHP too which outputs HTML;
|
||||
const LG_CUSTOM_HTML = __DIR__.'/custom.html.php';
|
||||
|
12
index.php
12
index.php
@ -107,7 +107,7 @@ $templateData['csrfToken'] = $_SESSION[LookingGlass::SESSION_CSRF] = bin2hex(ran
|
||||
<meta content="" name="description">
|
||||
<meta content="Hybula" name="author">
|
||||
<title><?php echo $templateData['title'] ?></title>
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN" crossorigin="anonymous">
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">
|
||||
<?php if ($templateData['custom_css']) { echo '<link href="'.$templateData['custom_css'].'" rel="stylesheet">'; } ?>
|
||||
<?php if ($templateData['custom_head']) { echo $templateData['custom_head']; } ?>
|
||||
</head>
|
||||
@ -130,7 +130,9 @@ $templateData['csrfToken'] = $_SESSION[LookingGlass::SESSION_CSRF] = bin2hex(ran
|
||||
<select class="form-select" onchange="window.location = this.options[this.selectedIndex].value" <?php if (count($templateData['locations']) == 0) echo 'disabled'; ?>>
|
||||
<option selected><?php echo $templateData['current_location'] ?></option>
|
||||
<?php foreach ($templateData['locations'] as $location => $link): ?>
|
||||
<?php if ($location !== $templateData['current_location']): ?>
|
||||
<option value="<?php echo $link ?>"><?php echo $location ?></option>
|
||||
<?php endif ?>
|
||||
<?php endforeach ?>
|
||||
</select>
|
||||
</div>
|
||||
@ -171,14 +173,14 @@ $templateData['csrfToken'] = $_SESSION[LookingGlass::SESSION_CSRF] = bin2hex(ran
|
||||
|
||||
<div class="row mb-3">
|
||||
<div class="col-md-3">
|
||||
<label class="mb-2 text-muted">Test IPv4</label>
|
||||
<label class="mb-2 text-muted">Looking Glass IPv4</label>
|
||||
<div class="input-group">
|
||||
<input type="text" class="form-control" value="<?php echo $templateData['ipv4'] ?>" onfocus="this.select()" readonly="">
|
||||
<button class="btn btn-outline-secondary" onclick="copyToClipboard('<?php echo $templateData['ipv4'] ?>', this)">Copy</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-5">
|
||||
<label class="mb-2 text-muted">Test IPv6</label>
|
||||
<label class="mb-2 text-muted">Looking Glass IPv6</label>
|
||||
<div class="input-group">
|
||||
<input type="text" class="form-control" value="<?php echo $templateData['ipv6'] ?>" onfocus="this.select()" readonly="">
|
||||
<button class="btn btn-outline-secondary" onclick="copyToClipboard('<?php echo $templateData['ipv6'] ?>', this)">Copy</button>
|
||||
@ -346,7 +348,7 @@ $templateData['csrfToken'] = $_SESSION[LookingGlass::SESSION_CSRF] = bin2hex(ran
|
||||
for await (const chunk of readChunks(reader)) {
|
||||
const text = decoder.decode(chunk)
|
||||
<?php if(in_array($_SESSION[LookingGlass::SESSION_TARGET_METHOD], [LookingGlass::METHOD_MTR, LookingGlass::METHOD_MTR6])): ?>
|
||||
let splittedText = text.split('---')
|
||||
let splittedText = text.split('@@@')
|
||||
if (!splittedText[1]) {
|
||||
continue
|
||||
}
|
||||
@ -391,7 +393,7 @@ $templateData['csrfToken'] = $_SESSION[LookingGlass::SESSION_CSRF] = bin2hex(ran
|
||||
}
|
||||
</script>
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-C6RzsynM9kWDrMNeT87bh95OGNyZPhcTNXj1NW7RuBCsyN/o0jlpcV8Qyq46cDfL" crossorigin="anonymous"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz" crossorigin="anonymous"></script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
Loading…
x
Reference in New Issue
Block a user