Compare commits

...

21 Commits
1.3.3 ... main

Author SHA1 Message Date
Tamer
286d892703
Merge pull request #49 from fhservinga/main
make logo configurable with env vars
2025-01-13 10:31:21 +01:00
fhservinga
a5bd259466
Merge branch 'hybula:main' into main 2025-01-10 17:16:47 +01:00
Fabian Hufenreuter
c4bfe0624e
make logo configurable with env vars 2025-01-10 17:14:27 +01:00
Tamer
f87a19fa1e
Merge pull request #48 from fhservinga/main
Update Dockerfile for php-fpm and config.php
2025-01-10 13:39:39 +01:00
Fabian Hufenreuter
cbb1a95b64
change $_ENV to getenv 2025-01-10 13:24:08 +01:00
Fabian Hufenreuter
05ea20c332
add use of production php.ini 2025-01-10 13:23:29 +01:00
Fabian Hufenreuter
10c9e545d0
unloy use major.minor for php fpm 2025-01-10 13:22:30 +01:00
Tamer
b453e719f7
Update README.md 2025-01-04 22:13:13 +01:00
Tamer
4a95d3854f
Merge pull request #46 from clertes/main
Docker images vulnerable (CVE-2024-4577)
2024-12-20 09:31:21 +01:00
Christian
91b36725a3
Update Dockerfile
Upgraded PHP-FPM container image to PHP version 8.4.1
2024-12-19 17:48:24 +01:00
dqos
4db24c99d1
Update to Bootstrap 5.3.3 2024-08-24 20:40:23 +02:00
dqos
761c00740f
Fixes issue 44, caused by --- in PTRs. 2024-08-24 20:26:09 +02:00
Tamer
24445308dc
Merge pull request #41 from SalmonCloud/contrib
Docker Fixes, iPerf3 Feature Completion, Minor PHP Code Improvements
2024-04-27 18:47:51 +02:00
RealBrandon
fb6a7a83e9 Make iPerf3 Docker container optional. Relocate iPerf3 installation instructions in a separate section 2024-04-27 15:57:58 +01:00
RealBrandon
4906fd0227 Change default values of LG_LOCATIONS and LG_SPEEDTEST_FILES back 2024-04-27 15:19:45 +01:00
RealBrandon
531c39ab90 Change iPerf3 commands from using "LG_IPV4" back to "hostname" 2024-04-27 15:14:41 +01:00
RealBrandon
c7339f04cf Update Nginx Dockerfile copy path 2024-04-19 23:08:55 +01:00
RealBrandon
900c29f255 Add iPerf3-related instructions 2024-04-19 22:57:45 +01:00
RealBrandon
7759c1c1fb Adjust default values to benefit from auto hiding. Minor improvements 2024-04-19 20:46:52 +01:00
RealBrandon
4723633bcc Change network mode of containers to host. Add iproute2 package in php-fpm image 2024-04-19 20:26:09 +01:00
RealBrandon
87b343749d Add iPerf3 container. Add container name for easier management 2024-04-19 20:11:13 +01:00
9 changed files with 66 additions and 32 deletions

View File

@ -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();

View File

@ -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.

View File

@ -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;

View File

@ -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

View File

@ -1,3 +1,3 @@
FROM nginx:mainline-alpine
COPY nginx.conf /etc/nginx/nginx.conf
COPY docker/nginx/nginx.conf /etc/nginx/nginx.conf

View File

@ -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;

View File

@ -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 . .

View File

@ -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('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';

View File

@ -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>