Make config instantiation private

Fixup Paths
Moved all tests to phpunit tests

Signed-off-by: Diederik de Groot <ddegroot@talon.nl>
This commit is contained in:
Diederik de Groot
2020-03-18 11:57:30 +01:00
parent c535113c55
commit 3e9f731e9a
5 changed files with 87 additions and 83 deletions

View File

@@ -23,7 +23,7 @@ class TFTPProvisioner extends TFTP\TFTPServer
parent::__construct($server_url, $logger);
$this->_debug = $debug;
$this->max_put_size = 60000000;
$this->_resolve = new Resolve\Resolver($config);
$this->_resolve = new Resolve\Resolve($config);
$this->_settings_path = $this->_config['main']['base_path'] . DIRECTORY_SEPARATOR
. $this->_config['subdirs']['settings']['path'] . DIRECTORY_SEPARATOR;
}
@@ -83,12 +83,14 @@ class TFTPProvisioner extends TFTP\TFTPServer
}
global $base_path;
$host = "127.0.0.1";
$port = 10069;
$url = "udp://$host:$port";
echo "\nStarting TFTP Provisioner...\n";
$server = new TFTPProvisioner($url, $config, $logger);
$configParser = new SCCP\Config\ConfigParser($base_path, "config.ini");
$server = new TFTPProvisioner($url, $configParser->getConfiguration(), $logger);
if(!$server->loop($error))
die("$error\n");
?>

View File

@@ -1,6 +1,6 @@
<?php
include_once("../lib/config.php");
include_once("../lib/resolve.php");
include_once("../../lib/config.php");
include_once("../../lib/resolve.php");
$request = $_REQUEST ?? null;
function send_fallback_html($message) {
@@ -50,8 +50,10 @@ if (!$request || empty($request) || !array_key_exists('filename',$request) || em
exit();
}
try {
global $base_path;
$req_filename=$request['filename'];
$resolve = new Resolver($config);
$configParser = new SCCP\Config\ConfigParser($base_path, "config.ini");
$resolve = new SCCP\Resolve\Resolve($configParser->getConfiguration());
if (($filename = $resolve->resolve($req_filename))) {
sendfile($filename);
}