New stuff

feature/node-rewrite
Sven Slootweg 13 years ago
parent 312d862978
commit f2db8c25c2

@ -63,8 +63,8 @@ class Container extends CPHPDatabaseRecordClass
case "sBandwidthUsed":
return $this->GetBandwidthUsed();
break;
case "sStatus":
return (int)$this->GetStatus();
case "sCurrentStatus":
return (int)$this->GetCurrentStatus();
break;
case "sStatusText":
return $this->GetStatusText();
@ -80,7 +80,7 @@ class Container extends CPHPDatabaseRecordClass
return ($this->sOutgoingTrafficUsed + $this->IncomingTrafficUsed) / (1024 * 1024);
}
public function GetStatus()
public function GetCurrentStatus()
{
$command = "vzctl status {$this->sInternalId}";
@ -103,14 +103,7 @@ class Container extends CPHPDatabaseRecordClass
public function GetStatusText()
{
if(isset($this->sStatus))
{
$status = $this->sStatus;
}
else
{
$status = $this->GetStatus();
}
$status = $this->sCurrentStatus;
if($status == CVM_STATUS_STARTED)
{

@ -0,0 +1,14 @@
<?php
/*
* CVM is more free software. It is licensed under the WTFPL, which
* allows you to do pretty much anything with it, without having to
* ask permission. Commercial use is allowed, and no attribution is
* required. We do politely request that you share your modifications
* to benefit other developers, but you are under no enforced
* obligation to do so :)
*
* Please read the accompanying LICENSE document for the full WTFPL
* licensing text.
*/
?>

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

@ -15,6 +15,7 @@ if(!isset($_CVM)) { die("Unauthorized."); }
$_CPHP = true;
require("cphp/base.php");
require("include.config.php");
require("include.exceptions.php");
require("include.constants.php");
require("include.parsing.php");

@ -0,0 +1,18 @@
<?php
/*
* CVM is more free software. It is licensed under the WTFPL, which
* allows you to do pretty much anything with it, without having to
* ask permission. Commercial use is allowed, and no attribution is
* required. We do politely request that you share your modifications
* to benefit other developers, but you are under no enforced
* obligation to do so :)
*
* Please read the accompanying LICENSE document for the full WTFPL
* licensing text.
*/
$settings['master_privkey'] = "/etc/cvm/key";
$settings['master_pubkey'] = "/etc/cvm/key.pub";
$settings['salt'] = "kAU0qM";
?>

@ -10,7 +10,7 @@ $(function(){
return false;
});
$(this).children('.button-icon').addClass('running')[0].src = "images/loading.gif";
$(this).children('.button-icon').addClass('running')[0].src = "/images/loading.gif";
command_running = true;
}
});

@ -0,0 +1,17 @@
<?php
/*
* CVM is more free software. It is licensed under the WTFPL, which
* allows you to do pretty much anything with it, without having to
* ask permission. Commercial use is allowed, and no attribution is
* required. We do politely request that you share your modifications
* to benefit other developers, but you are under no enforced
* obligation to do so :)
*
* Please read the accompanying LICENSE document for the full WTFPL
* licensing text.
*/
if(!isset($_CVM)) { die("Unauthorized."); }
?>

@ -0,0 +1,43 @@
<?php
/*
* CVM is more free software. It is licensed under the WTFPL, which
* allows you to do pretty much anything with it, without having to
* ask permission. Commercial use is allowed, and no attribution is
* required. We do politely request that you share your modifications
* to benefit other developers, but you are under no enforced
* obligation to do so :)
*
* Please read the accompanying LICENSE document for the full WTFPL
* licensing text.
*/
if(!isset($_CVM)) { die("Unauthorized."); }
if(!empty($router->uParameters[2]))
{
if($router->uParameters[2] == "start")
{
require("submodule.start.php");
}
elseif($router->uParameters[2] == "stop")
{
require("submodule.stop.php");
}
elseif($router->uParameters[2] == "restart")
{
require("submodule.restart.php");
}
}
$sPageContents = Templater::InlineRender("vps.overview", $locale->strings, array(
'id' => $sContainer->sId,
'server-location' => $sContainer->sNode->sPhysicalLocation,
'operating-system' => $sContainer->sTemplate->sName,
'guaranteed-ram' => "{$sContainer->sGuaranteedRam}MB",
'burstable-ram' => "{$sContainer->sBurstableRam}MB",
'disk-space' => "{$sContainer->sDiskSpace}MB",
'total-traffic-limit' => "{$sContainer->sTotalTrafficLimit} bytes",
'bandwidth-limit' => "100mbit",
'status' => Templater::InlineRender("status.{$sContainer->sStatusText}", $locale->strings)
));
?>

@ -0,0 +1,46 @@
<?php
/*
* CVM is more free software. It is licensed under the WTFPL, which
* allows you to do pretty much anything with it, without having to
* ask permission. Commercial use is allowed, and no attribution is
* required. We do politely request that you share your modifications
* to benefit other developers, but you are under no enforced
* obligation to do so :)
*
* Please read the accompanying LICENSE document for the full WTFPL
* licensing text.
*/
if(!isset($_CVM)) { die("Unauthorized."); }
try
{
$sContainer = new Container($mainrouter->uParameters[1]);
$sError = "";
$sPageContents = "";
$router = new CPHPRouter();
$router->routes = array(
0 => array(
'^/([0-9]+)/?$' => "module.vps.overview.php",
'^/([0-9]+)/(start)/?$' => "module.vps.overview.php",
'^/([0-9]+)/(stop)/?$' => "module.vps.overview.php",
'^/([0-9]+)/(restart)/?$' => "module.vps.overview.php"
)
);
$router->RouteRequest();
$sMainContents = Templater::InlineRender("main.vps", $locale->strings, array(
'error' => $sError,
'contents' => $sPageContents,
'id' => $sContainer->sId
));
}
catch(NotFoundException $e)
{
$sMainContents = Templater::InlineRender("error.vps.notfound");
}
?>

@ -0,0 +1,45 @@
<?php
/*
* CVM is more free software. It is licensed under the WTFPL, which
* allows you to do pretty much anything with it, without having to
* ask permission. Commercial use is allowed, and no attribution is
* required. We do politely request that you share your modifications
* to benefit other developers, but you are under no enforced
* obligation to do so :)
*
* Please read the accompanying LICENSE document for the full WTFPL
* licensing text.
*/
$_CVM = true;
require("includes/include.base.php");
$sMainContents = "";
$sPageTitle = "";
// Initialize some variables to ensure they are available through the application.
// This works about the inability of CPHP to retain variables set in the first rewrite.
$sContainer = null;
$sPageContents = null;
$router = null;
$sError = null;
$mainrouter = new CPHPRouter();
$mainrouter->routes = array(
0 => array(
'^/?$' => "module.home.php",
'^/login/?$' => "module.login.php",
'^/logout/?$' => "module.logout.php",
'^/([0-9]+)(/.*)?$' => "module.vps.php"
)
);
$mainrouter->RouteRequest();
echo(Templater::InlineRender("main", $locale->strings, array(
'title' => $sPageTitle,
'main' => $sMainContents
)));
?>

@ -0,0 +1,39 @@
<?php
/*
* CVM is more free software. It is licensed under the WTFPL, which
* allows you to do pretty much anything with it, without having to
* ask permission. Commercial use is allowed, and no attribution is
* required. We do politely request that you share your modifications
* to benefit other developers, but you are under no enforced
* obligation to do so :)
*
* Please read the accompanying LICENSE document for the full WTFPL
* licensing text.
*/
if(!isset($_CVM)) { die("Unauthorized."); }
try
{
try
{
$sContainer->Stop();
}
catch(ContainerStopException $e)
{
// we can make this silently fail, as the only important thing is that it starts again
}
$sContainer->Start();
$sContainer->sCurrentStatus = CVM_STATUS_STARTED;
$err = new CPHPErrorHandler(CPHP_ERRORHANDLER_TYPE_SUCCESS, "Container restarted", "Your container was successfully restarted.");
$sError .= $err->Render();
}
catch(ContainerStartException $e)
{
$err = new CPHPErrorHandler(CPHP_ERRORHANDLER_TYPE_ERROR, "Container failed to start", "Your container could not be started. If this error persists, please file a support ticket.");
$sError .= $err->Render();
}
?>

@ -0,0 +1,38 @@
<?php
/*
* CVM is more free software. It is licensed under the WTFPL, which
* allows you to do pretty much anything with it, without having to
* ask permission. Commercial use is allowed, and no attribution is
* required. We do politely request that you share your modifications
* to benefit other developers, but you are under no enforced
* obligation to do so :)
*
* Please read the accompanying LICENSE document for the full WTFPL
* licensing text.
*/
if(!isset($_CVM)) { die("Unauthorized."); }
if($sContainer->sCurrentStatus != CVM_STATUS_STARTED)
{
try
{
$sContainer->Start();
$sContainer->sCurrentStatus = CVM_STATUS_STARTED;
$err = new CPHPErrorHandler(CPHP_ERRORHANDLER_TYPE_SUCCESS, "Container started", "Your container was successfully started.");
$sError .= $err->Render();
}
catch(ContainerStartException $e)
{
$err = new CPHPErrorHandler(CPHP_ERRORHANDLER_TYPE_ERROR, "Container failed to start", "Your container could not be started. If this error persists, please file a support ticket.");
$sError .= $err->Render();
}
}
else
{
$err = new CPHPErrorHandler(CPHP_ERRORHANDLER_TYPE_ERROR, "Container can't be started", "Your container cannot be started because it is already running.");
$sError .= $err->Render();
}
?>

@ -0,0 +1,38 @@
<?php
/*
* CVM is more free software. It is licensed under the WTFPL, which
* allows you to do pretty much anything with it, without having to
* ask permission. Commercial use is allowed, and no attribution is
* required. We do politely request that you share your modifications
* to benefit other developers, but you are under no enforced
* obligation to do so :)
*
* Please read the accompanying LICENSE document for the full WTFPL
* licensing text.
*/
if(!isset($_CVM)) { die("Unauthorized."); }
if($sContainer->sCurrentStatus != CVM_STATUS_STOPPED)
{
try
{
$sContainer->Stop();
$sContainer->sCurrentStatus = CVM_STATUS_STOPPED;
$err = new CPHPErrorHandler(CPHP_ERRORHANDLER_TYPE_SUCCESS, "Container stopped", "Your container was successfully stopped.");
$sError .= $err->Render();
}
catch(ContainerStartException $e)
{
$err = new CPHPErrorHandler(CPHP_ERRORHANDLER_TYPE_ERROR, "Container failed to stop", "Your container could not be stopped. If this error persists, please file a support ticket.");
$sError .= $err->Render();
}
}
else
{
$err = new CPHPErrorHandler(CPHP_ERRORHANDLER_TYPE_ERROR, "Container can't be stopped", "Your container cannot be stopped because it is not running.");
$sError .= $err->Render();
}
?>

@ -0,0 +1 @@
The specified VPS was not found.

@ -0,0 +1,4 @@
<div class="errorhandler error-error">
<div class="error-title"><%?title></div>
<div class="error-message"><%?message></div>
</div>

@ -0,0 +1,4 @@
<div class="errorhandler error-info">
<div class="error-title"><%?title></div>
<div class="error-message"><%?message></div>
</div>

@ -0,0 +1,4 @@
<div class="errorhandler error-success">
<div class="error-title"><%?title></div>
<div class="error-message"><%?message></div>
</div>

@ -0,0 +1,4 @@
<div class="errorhandler error-warning">
<div class="error-title"><%?title></div>
<div class="error-message"><%?message></div>
</div>

@ -3,14 +3,14 @@
<head>
<title>CVM</title>
<link href='http://fonts.googleapis.com/css?family=Open+Sans:400,700' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="css/cvm.css" type="text/css">
<link rel="stylesheet" href="/css/cvm.css?1" type="text/css">
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script type="text/javascript" src="js/cvm.js?1"></script>
<script type="text/javascript" src="/js/cvm.js?3"></script>
</head>
<body>
<div class="wrapper">
<div class="header">
<img src="images/logo.png">
<img src="/images/logo.png">
<div class="userbox">
<div>You are logged in as <strong>joepie91</strong>.</div>
<div><a href="/">Account overview</a> | <a href="/containers/">My VPSes</a></div>

@ -0,0 +1,14 @@
<div class="sidebar">
<a class="button" id="button_overview" href="/<%?id>/">Overview</a>
<a class="button" id="button_statistics" href="/<%?id>/statistics/">Statistics</a>
<a class="button" id="button_reinstall" href="/<%?id>/reinstall/">Reinstall</a>
<a class="button" id="button_backup" href="/<%?id>/backup/">Backups</a>
<a class="button" id="button_webshell" href="/<%?id>/webshell/">WebShell</a>
<a class="button" id="button_ip" href="/<%?id>/ip/">IP Allocation</a>
<a class="button" id="button_alerts" href="/<%?id>/alerts/">Alerts</a>
<a class="button" id="button_api" href="/<%?id>/api/">API</a>
</div>
<%?error>
<%?contents>

@ -0,0 +1 @@
<span class="online">Running</span>

@ -0,0 +1 @@
<span class="offline">Stopped</span>

@ -0,0 +1 @@
<span class="suspended">Suspended</span>

@ -0,0 +1 @@
<span class="unknown">Unknown</span>

@ -0,0 +1,89 @@
<h1>Overview</h1>
<!-- <h2>Consolidated traffic example</h2> -->
<div class="quota">
<div class="quota-item">
<h3>Disk space</h3>
<div class="quota-bar">
<div class="quota-bar-inner" style="width: 55%;"></div>
<div class="quota-bar-label">55/100GB</div>
</div>
</div>
<div class="quota-item">
<h3>RAM</h3>
<div class="quota-bar">
<div class="quota-bar-inner" style="width: 24%;"></div>
<div class="quota-bar-label">241/1024MB</div>
</div>
</div>
<div class="quota-item last">
<h3>Traffic</h3>
<div class="quota-bar">
<div class="quota-bar-inner" style="width: 8%;"></div>
<div class="quota-bar-label">80/1000GB</div>
</div>
</div>
<div class="clear"></div>
</div>
<div class="controlbox">
<a class="controlbutton button-loader" href="/<%?id>/start/">
<img src="/images/button_start.png" class="button-icon">
Start VPS
</a>
<a class="controlbutton button-loader" href="/<%?id>/restart/">
<img src="/images/button_restart.png" class="button-icon">
Restart VPS
</a>
<a class="controlbutton button-loader last" href="/<%?id>/stop/">
<img src="/images/button_stop.png" class="button-icon">
Stop VPS
</a>
<div class="clear"></div>
</div>
<div class="infobox">
<h2>VPS configuration</h2>
<table class="vpsinfo">
<tr>
<th>Status</th>
<td><%?status></td>
</tr>
<tr>
<th>Server location</th>
<td><%?server-location></td>
</tr>
<tr>
<th>Operating system</th>
<td><%?operating-system></td>
</tr>
<tr>
<th>IPv4 Addresses</th>
<td>98.142.213.226, 204.12.235.84</td>
</tr>
<tr>
<th>IPv6 Addresses</th>
<td>2607:f7a0:1:1::24:6</td>
</tr>
<tr>
<th>Guaranteed RAM</th>
<td><%?guaranteed-ram></td>
</tr>
<tr>
<th>Burstable RAM</th>
<td><%?burstable-ram></td>
</tr>
<tr>
<th>Disk space</th>
<td><%?disk-space></td>
</tr>
<tr>
<th>Traffic</th>
<td><%?total-traffic-limit></td>
</tr>
<tr>
<th>Bandwidth</th>
<td><%?bandwidth-limit></td>
</tr>
</table>
</div>

@ -0,0 +1,27 @@
-----BEGIN RSA PRIVATE KEY-----
MIIEpAIBAAKCAQEAzVGn22oP7Na8NYNuLlnqApMPzldYt3TQMGXvb3B1nBjU3Eha
VYKvl2HHQdH7tIAkk9WUXTO4d24Z+YKGdCgNgJIlF6iMswZBqBCHgyhWobeJxAzg
2tQbKyDyPoYpR5TDVOkAwDwL6auIlKgOPsmmde+zIovvUa0xEKEAD3sFykKAqXHW
i1CR/fyvfGiidSgfNoNApvJthP9PIs3w/b21vj8HmZ2hdo6WIF9mZK+snjiWiGqn
xBwhB9mjzfWnngxVLASDw1D9abSEVnX1pGrYSWescLjKp5QfN3xKv69EiDZUkQz0
dVKOSq15bbhAdntQI2Nu3K7NbkJsT3pE33pPqQIDAQABAoIBAQCfTA4+5xBKAeTu
Y/V1Ut+DddQalJxJYgEwu7XEMW2eWYm1CxHDLGzNt9gf0ipGxfEbHedJVJp3Vt4i
PsnQj07ChSDwNR5Mu7rvCTwKX56vQ7ZIfHFsdopJsPsh1XdriRjv5QNnIm9fsW17
YNQElPFoqTvDvu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SA PRIVATE KEY-----

@ -0,0 +1 @@
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDNUafbag/s1rw1g24uWeoCkw/OV1i3dNAwZe9vcHWcGNTcSFpVgq+XYcdB0fu0gCST1ZRdM7h3bhn5goZ0KA2AkiUXqIyzBkGoEIeDKFaht4nEDODa1BsrIPI+hilHlMNU6QDAPAvpq4iUqA4+yaZ177Mii+9RrTEQoQAPewXKQoCpcdaLUJH9/K98aKJ1KB82g0Cm8m2E/08izfD9vbW+PweZnaF2jpYgX2Zkr6yeOJaIaqfEHCEH2aPN9aeeDFUsBIPDUP1ptIRWdfWkathJZ6xwuMqnlB83fEq/r0SINlSRDPR1Uo5KrXltuEB2e1AjY27crs1uQmxPekTfek+p occupy@edge13.mydomain.internal

@ -0,0 +1,39 @@
from twisted.cred.portal import Portal
from twisted.conch.ssh.factory import SSHFactory
from twisted.internet import reactor
from twisted.conch.ssh.keys import Key
from twisted.conch.interfaces import IConchUser
from twisted.conch.avatar import ConchUser
from twisted.cred.checkers import AllowAnonymousAccess
with open('id_rsa.sshd') as privateBlobFile:
privateBlob = privateBlobFile.read()
privateKey = Key.fromString(data=privateBlob)
with open('id_rsa.sshd.pub') as publicBlobFile:
publicBlob = publicBlobFile.read()
publicKey = Key.fromString(data=publicBlob)
class StandardRealm(object):
def requestAvatar(self, avatarId, mind, *interfaces):
return IConchUser, ConchUser(), nothing
class CVMChecker:
implements(ICredentialsChecker)
credentialInterfaces = ICVMUser,
def requestAvatarId(self, credentials):
return defer.succeed("hai")
class ICVMUser(ICredentials):
pass
factory = SSHFactory()
factory.privateKeys = {'ssh-rsa': privateKey}
factory.publicKeys = {'ssh-rsa': publicKey}
factory.portal = Portal(StandardRealm())
factory.portal.registerChecker(CVMChecker())
reactor.listenTCP(2022, factory)
reactor.run()
Loading…
Cancel
Save