1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2026-03-23 11:04:49 +00:00

Make VNC listen by default only on 127.0.0.1 and add a checkbox on vncsettings to listen on 0.0.0.0

This commit is contained in:
Valentin Samir 2016-05-04 14:03:16 +02:00
parent 2c4a6e16eb
commit fd2dc1296f
4 changed files with 51 additions and 2 deletions

View file

@ -227,8 +227,8 @@ class wvmCreate(wvmConnect):
xml += """ <input type='mouse' bus='ps2'/>
<input type='tablet' bus='usb'/>
<graphics type='%s' port='-1' autoport='yes' listen='0.0.0.0'>
<listen type='address' address='0.0.0.0'/>
<graphics type='%s' port='-1' autoport='yes' listen='127.0.0.1'>
<listen type='address' address='127.0.0.1'/>
</graphics>
<console type='pty'/>
<video>

View file

@ -435,6 +435,25 @@ class wvmInstance(wvmConnect):
return "127.0.0.1"
return listen_addr
def set_console_listen_addr(self, addr):
xml = self._XMLDesc(VIR_DOMAIN_XML_SECURE)
root = ElementTree.fromstring(xml)
console_type = self.get_console_type()
try:
graphic = root.find("devices/graphics[@type='%s']" % console_type)
except SyntaxError:
# Little fix for old version ElementTree
graphic = root.find("devices/graphics")
if graphic is None:
return False
listen = graphic.find("listen")
graphic.set('listen', addr)
if listen is not None:
listen.set('address', addr)
newxml = ElementTree.tostring(root)
return self._defineXML(newxml)
def get_console_socket(self):
socket = util.get_xml_path(self._XMLDesc(0),
"/domain/devices/graphics/@socket")