@@ -238,14 +238,22 @@ def to_wire(self, file, origin=None): # pylint: disable=W0613
238238
239239
240240@dns .immutable .immutable
241- class ALPNParam (Param ):
241+ class _StringList (Param ):
242+ """A comma separated list of strings, possibly empty."""
243+
242244 def __init__ (self , ids ):
243245 self .ids = dns .rdata .Rdata ._as_tuple (
244246 ids , lambda x : dns .rdata .Rdata ._as_bytes (x , True , 255 , False )
245247 )
246248
249+ @classmethod
250+ def emptiness (cls ) -> Emptiness :
251+ return Emptiness .ALLOWED
252+
247253 @classmethod
248254 def from_value (cls , value ):
255+ if value is None or value == "" :
256+ return None
249257 return cls (_split (_unescape (value )))
250258
251259 def to_text (self ):
@@ -254,6 +262,8 @@ def to_text(self):
254262
255263 @classmethod
256264 def from_wire_parser (cls , parser , origin = None ): # pylint: disable=W0613
265+ if parser .remaining () == 0 :
266+ return None
257267 ids = []
258268 while parser .remaining () > 0 :
259269 id = parser .get_counted_bytes ()
@@ -266,6 +276,20 @@ def to_wire(self, file, origin=None): # pylint: disable=W0613
266276 file .write (id )
267277
268278
279+ @dns .immutable .immutable
280+ class ALPNParam (_StringList ):
281+ """The alpn parameter."""
282+
283+ def __init__ (self , ids ):
284+ self .ids = dns .rdata .Rdata ._as_tuple (
285+ ids , lambda x : dns .rdata .Rdata ._as_bytes (x , True , 255 , False )
286+ )
287+
288+ @classmethod
289+ def emptiness (cls ):
290+ return Emptiness .NEVER
291+
292+
269293@dns .immutable .immutable
270294class NoDefaultALPNParam (Param ):
271295 # We don't ever expect to instantiate this class, but we need
@@ -430,22 +454,8 @@ def to_wire(self, file, origin=None): # pylint: disable=W0613
430454
431455
432456@dns .immutable .immutable
433- class DoCPathParam (ALPNParam ):
434- @classmethod
435- def emptiness (cls ):
436- return Emptiness .ALLOWED
437-
438- @classmethod
439- def from_value (cls , value ):
440- if value is None or value == "" :
441- return None
442- return super ().from_value (value )
443-
444- @classmethod
445- def from_wire_parser (cls , parser , origin = None ): # pylint: disable=W0613
446- if parser .remaining () == 0 :
447- return None
448- return super ().from_wire_parser (parser , origin = origin )
457+ class DoCPathParam (_StringList ):
458+ """The docpath parameter."""
449459
450460
451461_class_for_key : dict [ParamKey , Any ] = {
0 commit comments