File indexing completed on 2024-05-19 04:42:04

0001 #!/usr/bin/env python3
0002 # -*- coding: utf-8 -*-
0003 #
0004 # SPDX-FileCopyrightText: 2014 Denis Steckelmacher <steckdenis@yahoo.fr>
0005 #
0006 # SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
0007 
0008 from jsgenerator import *
0009 from common import *
0010 
0011 # Print the license of the generated file (the same as the one of this file)
0012 license()
0013 basicTypes(globals())
0014 require('event')
0015 
0016 _object = 'new Object()'
0017 _function = 'function(){}'
0018 _address = '{port: 1, family: "", address: ""}'
0019 
0020 _peer_certificate = """{
0021     subject: {C: "", ST: "", L: "", O: "", OU: "", CN: ""},
0022     issuer: {C: "", ST: "", L: "", O: "", OU: "", CN: ""},
0023     valid_from: "",
0024     valid_to: "",
0025     fingerprint: ""}"""
0026 _cipher = '{name: "", version: ""}'
0027 
0028 Module().members(
0029     F(_array, 'getCiphers'),
0030     F('new Server()', 'createServer', ('options', _object), ('secureConnectionListener', _function)),
0031     Var(_int, 'SLAB_BUFFER_SIZE'),
0032     F('new CleartextStream()', 'connect', ('options', _object), ('callback', _function)),
0033     F('new SecurePair()', 'createSecurePair', ('credentials', _object), ('isServer', _bool), ('requestCert', _bool), ('rejectUnauthorized', _bool)),
0034     Class('SecurePair').prototype('event.EventEmitter'),
0035     Class('Server').prototype('event.EventEmitter').members(
0036         F(_void, 'listen', ('port', _int), ('host', _string), ('callback', _function)),
0037         F(_void, 'close'),
0038         F(_address, 'address'),
0039         F(_void, 'addContext', ('hostname', _string), ('credentials', _object)),
0040         Var(_int, 'maxConnections'),
0041         Var(_int, 'connections')
0042     ),
0043     Class('CryptoStream').members(
0044         Var(_int, 'bytesWritten')
0045     ),
0046     Class('CleartextStream').prototype('event.EventEmitter').members(
0047         Var(_bool, 'authorized'),
0048         Var(_string, 'authorizationError'),
0049         F(_peer_certificate, 'getPeerCertificate'),
0050         F(_cipher, 'getCipher'),
0051         F(_address, 'address'),
0052         Var(_string, 'remoteAddress'),
0053         Var(_int, 'remotePort')
0054     )
0055 ).print()