public function __construct($vpnConfigDir, $vpnTlsDir) { FileIO::createDir($vpnConfigDir, 0700); $this->vpnConfigDir = $vpnConfigDir; FileIO::createDir($vpnTlsDir, 0700); $this->vpnTlsDir = $vpnTlsDir; }
public function __construct($dataDir) { $this->disableDir = sprintf('%s/disabled', $dataDir); FileIO::createDir($this->disableDir, 0711); $this->otpDir = sprintf('%s/otp_secrets', $dataDir); FileIO::createDir($this->otpDir, 0711); $this->vootDir = sprintf('%s/voot_tokens', $dataDir); FileIO::createDir($this->vootDir, 0711); }
public function __construct($dataDir) { $this->disableDir = sprintf('%s/disabled', $dataDir); FileIO::createDir($this->disableDir, 0711); }
* License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ require_once sprintf('%s/vendor/autoload.php', dirname(__DIR__)); use SURFnet\VPN\Server\OtpLog; use SURFnet\VPN\Common\CliParser; use SURFnet\VPN\Common\FileIO; try { $p = new CliParser('Initialize the OTP key storage', ['instance' => ['the instance', true, true]]); $opt = $p->parse($argv); if ($opt->e('help')) { echo $p->help(); exit(0); } $vpnDataDir = sprintf('%s/openvpn-data/%s', dirname(__DIR__), $opt->v('instance')); // create VPN directory if it does not yet exist FileIO::createDir($vpnDataDir, 0711); $db = new PDO(sprintf('sqlite://%s/otp.sqlite', $vpnDataDir)); $otpLog = new OtpLog($db); $otpLog->init(); } catch (Exception $e) { echo sprintf('ERROR: %s', $e->getMessage()) . PHP_EOL; exit(1); }
// XXX if an error occurred decoding the message, it was // probably a log error message, ignore them for now, but later we // will need them as well! continue; } if (!verifyMessage($messageData, 'disconnect')) { continue; } $instanceId = $messageData['INSTANCE_ID']; $poolId = $messageData['POOL_ID']; $logKey = sprintf('%s:%s:%s', $poolId, $messageData['common_name'], $messageData['time_unix']); // XXX what if instanceId key does not exist? if (!array_key_exists($logKey, $logData[$instanceId])) { // XXX we did not find a matching connect entry... // just ignore it continue; } $dataTransferred = $messageData['bytes_sent'] + $messageData['bytes_received']; $logData[$instanceId][$logKey] = array_merge($logData[$instanceId][$logKey], ['disconnect_time' => $messageData['time_unix'] + intval($messageData['time_duration']), 'traffic' => $dataTransferred]); } } foreach ($logData as $instanceId => $logEntries) { $logFile = sprintf('%s/data/%s/log.json', dirname(__DIR__), $instanceId); $logDir = dirname($logFile); FileIO::createDir($logDir, 0711); FileIO::writeJsonFile($logFile, ['entries' => array_values($logEntries)], 0644); } } catch (Exception $e) { echo sprintf('ERROR: %s', $e->getMessage()) . PHP_EOL; exit(1); }