Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- __PACKAGE__->register_method({
- name => 'vncwebsocket',
- path => '{vmid}/vncwebsocket',
- method => 'GET',
- permissions => {
- description => "You also need to pass a valid ticket (vncticket).",
- check => ['perm', '/vms/{vmid}', [ 'VM.Console' ]],
- },
- description => "Opens a weksocket for VNC traffic.",
- parameters => {
- additionalProperties => 0,
- properties => {
- node => get_standard_option('pve-node'),
- vmid => get_standard_option('pve-vmid'),
- vncticket => {
- description => "Ticket from previous call to vncproxy.",
- type => 'string',
- maxLength => 512,
- },
- port => {
- description => "Port number returned by previous vncproxy call.",
- type => 'integer',
- minimum => 5900,
- maximum => 5999,
- },
- },
- },
- returns => {
- type => "object",
- properties => {
- port => { type => 'string' },
- },
- },
- code => sub {
- my ($param) = @_;
- my $rpcenv = PVE::RPCEnvironment::get();
- my $authuser = $rpcenv->get_user();
- my $vmid = $param->{vmid};
- my $node = $param->{node};
- my $authpath = "/vms/$vmid";
- PVE::AccessControl::verify_vnc_ticket($param->{vncticket}, $authuser, $authpath);
- my $conf = PVE::QemuServer::load_config($vmid, $node); # VM exists ?
- # Note: VNC ports are acessible from outside, so we do not gain any
- # security if we verify that $param->{port} belongs to VM $vmid. This
- # check is done by verifying the VNC ticket (inside VNC protocol).
- my $port = $param->{port};
- return { port => $port };
- }});
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement