<s> import struct <EOL> from handshake import * <EOL> from utils import * <EOL> class ServerNameExtension ( TLSExtension ) : <EOL> HostName = <NUM_LIT:0> <EOL> def __init__ ( self ) : <EOL> TLSExtension . __init__ ( self ) <EOL> @ classmethod <EOL> def create ( cls , hostname , hostnames = [ ] , name_type = HostName ) : <EOL> if len ( hostnames ) == <NUM_LIT:0> : <EOL> hostnames = [ hostname ] <EOL> name_list = '<STR_LIT>' <EOL> for hostname in hostnames : <EOL> name = struct . pack ( '<STR_LIT>' % ( len ( hostname ) ) , <EOL> name_type , <EOL> len ( hostname ) , <EOL> hostname ) <EOL> name_list += name <EOL> data = struct . pack ( '<STR_LIT>' % ( len ( name_list ) ) , <EOL> len ( name_list ) + <NUM_LIT:2> , <EOL> len ( name_list ) , <EOL> name_list ) <EOL> return TLSExtension . create ( TLSExtension . ServerName , data ) </s>
