openc2lib.types.data.idn_hostname

 1import idna
 2
 3class IDNHostname:
 4	""" A hostname that can be used to connect to this device over a network 
 5		
 6		WARNING: This class has never been tested.
 7	"""
 8		
 9	def __init__(self, hostname):
10		self.set(hostname)
11
12	def set(self, hostname):
13		""" Check hostname fullfils RFC 1123 requirements """
14		try: 
15			idna.encode(hostname)
16			self._hostname = str(hostname)
17		except:
18			raise ValueError("Invalid hostname -- not compliant to RFC 5891")
19
20	def get(self):
21		""" Returns the hostname as string """
22		return self._hostname
23
24	def __str__(self):
25		return self._hostname
class IDNHostname:
 4class IDNHostname:
 5	""" A hostname that can be used to connect to this device over a network 
 6		
 7		WARNING: This class has never been tested.
 8	"""
 9		
10	def __init__(self, hostname):
11		self.set(hostname)
12
13	def set(self, hostname):
14		""" Check hostname fullfils RFC 1123 requirements """
15		try: 
16			idna.encode(hostname)
17			self._hostname = str(hostname)
18		except:
19			raise ValueError("Invalid hostname -- not compliant to RFC 5891")
20
21	def get(self):
22		""" Returns the hostname as string """
23		return self._hostname
24
25	def __str__(self):
26		return self._hostname

A hostname that can be used to connect to this device over a network

WARNING: This class has never been tested.

IDNHostname(hostname)
10	def __init__(self, hostname):
11		self.set(hostname)
def set(self, hostname):
13	def set(self, hostname):
14		""" Check hostname fullfils RFC 1123 requirements """
15		try: 
16			idna.encode(hostname)
17			self._hostname = str(hostname)
18		except:
19			raise ValueError("Invalid hostname -- not compliant to RFC 5891")

Check hostname fullfils RFC 1123 requirements

def get(self):
21	def get(self):
22		""" Returns the hostname as string """
23		return self._hostname

Returns the hostname as string