22 lines
758 B
PHP
22 lines
758 B
PHP
<?php
|
|
require __DIR__ . '/../lib/app.php';
|
|
require __DIR__ . '/../lib/torctl.php';
|
|
|
|
header('Content-Type: application/json');
|
|
|
|
$parsed = read_torpanel_conf();
|
|
$ui = torrc_to_ui($parsed);
|
|
|
|
$rate_mb = round($ui['rate_mbps'] / 8, 2);
|
|
$burst_mb = round($ui['burst_mbps'] / 8, 2);
|
|
$torrc = [
|
|
'Nickname' => $ui['nickname'],
|
|
'ContactInfo' => $ui['contact'],
|
|
'ORPort' => (string)$ui['orport'],
|
|
'BandwidthRate' => rtrim(rtrim(number_format($rate_mb, 2, '.', ''), '0'), '.') . ' MB',
|
|
'BandwidthBurst' => rtrim(rtrim(number_format($burst_mb, 2, '.', ''), '0'), '.') . ' MB',
|
|
'AccountingMax' => $ui['cap_gb'] . ' GB',
|
|
'AccountingStart' => 'month ' . $ui['acc_day'] . ' 00:00',
|
|
];
|
|
|
|
echo json_encode(['ok' => true] + $ui + $torrc); |