From 096b51567c2c7263d83e490cbaa9e20b7d628e83 Mon Sep 17 00:00:00 2001
From: Matthew McTague
Date: Mon, 31 Jan 2022 10:29:11 +1300
Subject: [PATCH 01/12] cPanel deployment config
---
.cpanel.yml | 4 ++++
1 file changed, 4 insertions(+)
create mode 100644 .cpanel.yml
diff --git a/.cpanel.yml b/.cpanel.yml
new file mode 100644
index 0000000..c84bd0d
--- /dev/null
+++ b/.cpanel.yml
@@ -0,0 +1,4 @@
+---
+deployment:
+ tasks:
+ - /bin/cp -R ./htdocs/* ~/public_html/
From 7e7a84e6634ab05abd3b99968023fd2442ff6d1e Mon Sep 17 00:00:00 2001
From: Matthew McTague
Date: Fri, 11 Feb 2022 11:18:36 +1300
Subject: [PATCH 02/12] Public-facing LG
- Added hiding of BGP summary and command line for public-facing LG's
- Added safe subnets array to permit some subnets to view peer information
- Added RADb to footer
- Stopped hyperlinks being added for private ASNs
- Minor code formatting changes
---
htdocs/index.php | 175 +++++++++++++++++++++++++++++++----
htdocs/lg_config.php.example | 21 ++++-
2 files changed, 178 insertions(+), 18 deletions(-)
diff --git a/htdocs/index.php b/htdocs/index.php
index 32bea0f..a24743d 100644
--- a/htdocs/index.php
+++ b/htdocs/index.php
@@ -59,6 +59,8 @@
'company' => 'My Company Name',
'logo' => 'lg_logo.gif',
'color' => '#E48559',
+ 'showpeerinfo' => 'TRUE',
+ 'safesubnet' => '',
'sshauthtype' => 'password',
'sshprivatekeypath' => '',
'sshpwdcommand' => 'plink',
@@ -278,10 +280,76 @@ function load() {
),
);
+# Test shell_exec to make sure it's available and working
+if(trim(shell_exec('echo lgshellexectest')) != 'lgshellexectest')
+{
+ print '
shell_exec not enabled
';
+ exit;
+}
+
+# Test popen to make sure it's available and working
+$popentest = "";
+$fp = popen('echo lgpopentest','r');
+while(!feof($fp))
+ {
+ // send the current file part to the browser
+ $popentest .= trim(fread($fp, 1024));
+ // flush the content to the browser
+ flush();
+ }
+fclose($fp);
+$popentest = trim($popentest);
+if($popentest != "lgpopentest")
+{
+ print '
popen not working
';
+ exit;
+}
+
+# Check if client IP is within safe subnets
+
+$ipsafe = false;
+if(isset($_CONFIG['safesubnets']) AND ! empty($_CONFIG['safesubnets']))
+{
+ foreach($_CONFIG['safesubnets'] as $safesubnet)
+ {
+ if(! empty($safesubnet))
+ {
+ if(checkIP($_SERVER['REMOTE_ADDR'], $safesubnet))
+ {
+ $ipsafe = true;
+ }
+ }
+ }
+}
+
+if($ipsafe){
+ if($command == 'graph' AND isset($_REQUEST['render']) AND $_REQUEST['render'] == true)
+ {
+ # Don't display
+ }
+ else
+ {
+ echo '
Your public IP is ' . $_SERVER['REMOTE_ADDR'] . ' and is within a safe subnet, therefore permitting display of peer information.
';
+ }
+
+}
+
if (isset($_CONFIG['routers'][$router]) AND
isset($queries[$_CONFIG['routers'][$router]['os']][$protocol]) AND
(isset($queries[$_CONFIG['routers'][$router]['os']][$protocol][$command]) OR $command == 'graph'))
{
+ if(!$ipsafe AND ($_CONFIG['showpeerinfo'] == "FALSE" OR $_CONFIG['routers'][$router]['showpeerinfo'] == "FALSE"))
+ {
+ switch ($command)
+ {
+ case "summary":
+ {
+ print '
Summary not permitted.
';
+ exit;
+ break;
+ }
+ }
+ }
if ($protocol == 'ipv6' AND (!isset($_CONFIG['routers'][$router]['ipv6']) OR
$_CONFIG['routers'][$router]['ipv6'] !== TRUE))
{
@@ -492,7 +560,12 @@ function load() {
}
else
{
- print '