def _setAcceptableProtocols(context, acceptableProtocols):
 def protoSelectCallback(conn, protocols):
  '\n        NPN client-side and ALPN server-side callback used to select\n        the next protocol. Prefers protocols found earlier in\n        C{_acceptableProtocols}.\n\n        @param conn: The context which is set up.\n        @type conn: L{OpenSSL.SSL.Connection}\n\n        @param conn: Protocols advertised by the other side.\n        @type conn: L{list} of L{bytes}\n        '
  overlap = (set(protocols) & set(acceptableProtocols))
  for p in acceptableProtocols:
   if (p in overlap):
    return p
  else:
   return ''
 if (not acceptableProtocols):
  return
 supported = protocolNegotiationMechanisms()
 if (supported & ProtocolNegotiationSupport.NPN):
  def npnAdvertiseCallback(conn):
   return acceptableProtocols
  context.set_npn_advertise_callback(npnAdvertiseCallback)
  context.set_npn_select_callback(protoSelectCallback)
 if (supported & ProtocolNegotiationSupport.ALPN):
  context.set_alpn_select_callback(protoSelectCallback)
  context.set_alpn_protos(acceptableProtocols)

def _setAcceptableProtocols ( context , acceptableProtocols ) : def protoSelectCallback ( conn , protocols ) : overlap = ( set ( protocols ) & set ( acceptableProtocols ) ) for p in acceptableProtocols : if ( p in overlap ) : return p else : return '' if ( not acceptableProtocols ) : return supported = protocolNegotiationMechanisms ( ) if ( supported & ProtocolNegotiationSupport . NPN ) : def npnAdvertiseCallback ( conn ) : return acceptableProtocols context . set_npn_advertise_callback ( npnAdvertiseCallback ) context . set_npn_select_callback ( protoSelectCallback ) if ( supported & ProtocolNegotiationSupport . ALPN ) : context . set_alpn_select_callback ( protoSelectCallback ) context . set_alpn_protos ( acceptableProtocols )
called to set up the l{openssl .