diff --git a/docs/conf.py b/docs/conf.py index ef94c55..c82a762 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -173,3 +173,106 @@ html_file_suffix = ".html" # Output file base name for HTML help builder. htmlhelp_basename = 'uts-server-docs' + +# Generate the configure.rst file from the default configuration file +def gen_param_table(out_file='./configure.rst'): + tsq_path = os.path.join(os.path.dirname(__file__),'../conf/uts-server.cnf') + + head = """ +Configuration Parameters +======================== +\n +""" + + foot = """ +Full Configuration File +======================= + +.. literalinclude:: ../conf/uts-server.cnf + :language: ini +\n +""" + + docs = {} + + text_buf = "" + cur_section = "" + + out_file = open(out_file, "w") + + + with open(tsq_path) as f: + for line in f.readlines(): + m = re.search('\[ (\w+) \]', line) + if m: + section = m.group(1) + docs[section] = {'text': text_buf, 'vars': {}} + cur_section = section + text_buf = "" + + m = re.search('^#[\s](.*)', line) + if m: + text = m.group(1) + if text_buf: + text_buf += '\n' + text_buf += text + + m = re.search('^#?([^\s]*)\s*=\s*(.*)', line) + if m: + var = m.group(1) + ex_val = m.group(2) + docs[cur_section]['vars'][var] = {'desc': text_buf, 'val': ex_val} + text_buf = "" + + max_var = 0 + max_desc = 0 + max_val = 0 + max_section = 0 + + for section in docs: + max_section = max(len(docs[section]['text']), max_section) + for var in docs[section]['vars']: + if docs[section]['vars'][var]: + max_var = max(len(var), max_var) + for line in docs[section]['vars'][var]['desc'].split('\n'): + max_desc = max(len(line), max_desc) + max_val = max(len(docs[section]['vars'][var]['val']), max_val) + + def print_line(var, desc, val): + out_file.write(\ + '| ' + var + ' ' * (max_var - len(var)) + \ + ' | ' + desc + ' ' * (max_desc - len(desc)) + \ + ' | ' + val + ' ' * (max_val - len(val)) + \ + ' |\n') + + + out_file.write(head) + + for section in sorted(docs): + out_file.write('Section [ ' + section + ' ]\n') + out_file.write('-' * len('Section [ ' + section + ' ]') + '\n') + out_file.write('\n') + out_file.write(docs[section]['text'] + '\n') + out_file.write('\n') + out_file.write('+-' + '-' * max_var + '-+-' + '-' * max_desc + '-+-' + '-' * max_val + '-+\n') + print_line('Parameter', 'Description', 'Example Value') + out_file.write('+=' + '=' * max_var + '=+=' + '=' * max_desc + '=+=' + '=' * max_val + '=+\n') + for var in sorted(docs[section]['vars']): + if docs[section]['vars'][var]: + first = True + for line in docs[section]['vars'][var]['desc'].split('\n'): + if first: + first = False + print_line( + re.sub('\*', '\\*', var), + re.sub('\*', '\\*', line), + re.sub('\*', '\\*', docs[section]['vars'][var]['val']), + ) + else: + print_line('', re.sub('\*', '\\*', line), '') + out_file.write('+-' + '-' * max_var + '-+-' + '-' * max_desc + '-+-' + '-' * max_val + '-+\n') + out_file.write('\n') + out_file.write(foot) + out_file.close() + +gen_param_table() diff --git a/docs/configure.rst b/docs/configure.rst deleted file mode 100644 index 26f7614..0000000 --- a/docs/configure.rst +++ /dev/null @@ -1,145 +0,0 @@ -Configuration Parameters -======================== -Section [ main ] ----------------- - -Main configuration section (mostly http configuration). - -+-----------------------------+---------------------------------------------------------------------+-------------------------------------------+ -| Parameter | Description | Example Value | -+=============================+=====================================================================+===========================================+ -| access_control_allow_origin | Comma separated list of IP subnets to accept/deny | -0.0.0.0/0,+192.168/16 | -| | | | -| | Ex: -0.0.0.0/0,+192.168.0.0/16 | | -| | (deny all accesses, only allow 192.168.0.0/16 subnet) | | -+-----------------------------+---------------------------------------------------------------------+-------------------------------------------+ -| enable_keep_alive | Allows clients to reuse TCP connection for subsequent | no | -| | HTTP requests, which improves performance. | | -+-----------------------------+---------------------------------------------------------------------+-------------------------------------------+ -| listening_ports | Comma-separated list of IP:port tuples to listen on. | 127.0.0.1:2020 | -| | If the port is SSL, a letter s must be appended. | | -| | | | -| | Ex: listening_ports = 80,443s | | -+-----------------------------+---------------------------------------------------------------------+-------------------------------------------+ -| log_level | Loglevel (debug, info, notice, warn, err, emerg, crit) | info | -+-----------------------------+---------------------------------------------------------------------+-------------------------------------------+ -| num_threads | Number of worker threads. | 50 | -+-----------------------------+---------------------------------------------------------------------+-------------------------------------------+ -| request_timeout_ms | Timeout for network read and network write operations. | 30000 | -| | In milliseconds. | | -+-----------------------------+---------------------------------------------------------------------+-------------------------------------------+ -| run_as_user | Switch to given user credentials after startup. | uts-server | -| | Required to run on privileged ports as non root user. | | -+-----------------------------+---------------------------------------------------------------------+-------------------------------------------+ -| ssl_ca_file | Path to a .pem file containing trusted certificates. | /etc/uts-server/ca.pem | -| | The file may contain more than one certificate. | | -+-----------------------------+---------------------------------------------------------------------+-------------------------------------------+ -| ssl_ca_path | Name of a directory containing trusted CA certificates. | /etc/ssl/ca/ | -+-----------------------------+---------------------------------------------------------------------+-------------------------------------------+ -| ssl_certificate | Path to the SSL certificate file . | /etc/uts-server/cert.pem | -| | PEM format must contain private key and certificate. | | -+-----------------------------+---------------------------------------------------------------------+-------------------------------------------+ -| ssl_cipher_list | List of enabled ciphers for ssl. | ALL:!eNULL:!SSLv3 | -| | See https://www.openssl.org/docs/manmaster/apps/ciphers.html | | -| | or 'man ciphers' for more detailed. | | -+-----------------------------+---------------------------------------------------------------------+-------------------------------------------+ -| ssl_default_verify_paths | Loads default trusted certificates | yes | -| | locations set at OpenSSL compile time. | | -+-----------------------------+---------------------------------------------------------------------+-------------------------------------------+ -| ssl_protocol_version | Sets the minimal accepted version of SSL/TLS protocol | 3 | -| | according to the table: | | -| | | | -| | - SSL2+SSL3+TLS1.0+TLS1.1+TLS1.2 -> 0 | | -| | | | -| | - SSL3+TLS1.0+TLS1.1+TLS1.2 -> 1 | | -| | | | -| | - TLS1.0+TLS1.1+TLS1.2 -> 2 | | -| | | | -| | - TLS1.1+TLS1.2 -> 3 | | -| | | | -| | - TLS1.2 -> 4 | | -+-----------------------------+---------------------------------------------------------------------+-------------------------------------------+ -| ssl_short_trust | Enables the use of short lived certificates | no | -+-----------------------------+---------------------------------------------------------------------+-------------------------------------------+ -| ssl_verify_depth | Sets maximum depth of certificate chain. | 9 | -| | If client's certificate chain is longer | | -| | than the depth set here connection is refused. | | -+-----------------------------+---------------------------------------------------------------------+-------------------------------------------+ -| ssl_verify_peer | Enable client's certificate verification by the server. | yes | -+-----------------------------+---------------------------------------------------------------------+-------------------------------------------+ -| tcp_nodelay | Enable TCP_NODELAY socket option on client connections. | 0 | -+-----------------------------+---------------------------------------------------------------------+-------------------------------------------+ -| throttle | Limit download speed for clients. | \*=0 | -| | | | -| | Throttle is a comma-separated list of key=value pairs: | | -| | | | -| | - \* -> limit speed for all connections | | -| | | | -| | - x.x.x.x/mask -> limit speed for specified subnet | | -| | | | -| | The value is a floating-point number of bytes per second, | | -| | optionally followed by a k or m character | | -| | meaning kilobytes and megabytes respectively. | | -| | | | -| | A limit of 0 means unlimited rate. | | -| | | | -| | Ex: throttle = \*=1k,10.10.0.0/16=10m,10.20.0.0/16=0 | | -+-----------------------------+---------------------------------------------------------------------+-------------------------------------------+ - -Section [ oids ] ----------------- - -Section for declaring OID mapping. Just add = pairs. - -+-----------------------------+---------------------------------------------------------------------+-------------------------------------------+ -| Parameter | Description | Example Value | -+=============================+=====================================================================+===========================================+ -| tsa_policy1 | | 1.2.3.4.1 | -+-----------------------------+---------------------------------------------------------------------+-------------------------------------------+ -| tsa_policy2 | | 1.2.3.4.5.6 | -+-----------------------------+---------------------------------------------------------------------+-------------------------------------------+ -| tsa_policy3 | | 1.2.3.4.5.7 | -+-----------------------------+---------------------------------------------------------------------+-------------------------------------------+ - -Section [ tsa ] ---------------- - -TSA configuration parameters. - -+-----------------------------+---------------------------------------------------------------------+-------------------------------------------+ -| Parameter | Description | Example Value | -+=============================+=====================================================================+===========================================+ -| accuracy | Time-Stamp accuracy. (optional) | secs:1, millisecs:500, microsecs:100 | -+-----------------------------+---------------------------------------------------------------------+-------------------------------------------+ -| certs | Certificate chain to include in reply. (optional) | $dir/cacert.pem | -+-----------------------------+---------------------------------------------------------------------+-------------------------------------------+ -| clock_precision_digits | Number of decimals for Time-Stamp. (optional) | 0 | -+-----------------------------+---------------------------------------------------------------------+-------------------------------------------+ -| crypto_device | OpenSSL engine to use for signing. | builtin | -+-----------------------------+---------------------------------------------------------------------+-------------------------------------------+ -| default_policy | Policy if request did not specify it. (optional) | tsa_policy1 | -+-----------------------------+---------------------------------------------------------------------+-------------------------------------------+ -| digests | Acceptable message digests. (mandatory) | md5, sha1, sha224, sha256, sha384, sha512 | -| | See https://www.openssl.org/docs/manmaster/apps/dgst.html | | -| | or 'man dgst' to get the list of available digests | | -+-----------------------------+---------------------------------------------------------------------+-------------------------------------------+ -| dir | TSA root directory. | /etc/uts-server/pki | -+-----------------------------+---------------------------------------------------------------------+-------------------------------------------+ -| ess_cert_id_chain | Must the ESS cert id chain be included? (optional, default: no) | no | -+-----------------------------+---------------------------------------------------------------------+-------------------------------------------+ -| ordering | Is ordering defined for timestamps? (optional, default: no) | yes | -+-----------------------------+---------------------------------------------------------------------+-------------------------------------------+ -| other_policies | Acceptable policies. (optional) | tsa_policy2, tsa_policy3 | -+-----------------------------+---------------------------------------------------------------------+-------------------------------------------+ -| signer_cert | The TSA signing certificat. (optional) | $dir/tsacert.pem | -+-----------------------------+---------------------------------------------------------------------+-------------------------------------------+ -| signer_key | The TSA private key. (optional) | $dir/private/tsakey.pem | -+-----------------------------+---------------------------------------------------------------------+-------------------------------------------+ -| tsa_name | Must the TSA name be included in the reply? (optional, default: no) | yes | -+-----------------------------+---------------------------------------------------------------------+-------------------------------------------+ - -Full Configuration File -======================= - -.. literalinclude:: ../conf/uts-server.cnf - :language: ini diff --git a/goodies/build_param_table.py b/goodies/build_param_table.py deleted file mode 100755 index 9ac12c9..0000000 --- a/goodies/build_param_table.py +++ /dev/null @@ -1,95 +0,0 @@ -#!/usr/bin/env python - -import re -import os - -import pprint - -tsq_path = os.path.join(os.path.dirname(__file__),'../conf/uts-server.cnf') - -docs = {} - -text_buf = "" -cur_section = "" - - - -with open(tsq_path) as f: - for line in f.readlines(): - m = re.search('\[ (\w+) \]', line) - if m: - section = m.group(1) - docs[section] = {'text': text_buf, 'vars': {}} - cur_section = section - text_buf = "" - - m = re.search('^#[\s](.*)', line) - if m: - text = m.group(1) - if text_buf: - text_buf += '\n' - text_buf += text - - m = re.search('^#?([^\s]*)\s*=\s*(.*)', line) - if m: - var = m.group(1) - ex_val = m.group(2) - docs[cur_section]['vars'][var] = {'desc': text_buf, 'val': ex_val} - text_buf = "" - -max_var = 0 -max_desc = 0 -max_val = 0 -max_section = 0 - -for section in docs: - max_section = max(len(docs[section]['text']), max_section) - for var in docs[section]['vars']: - if docs[section]['vars'][var]: - max_var = max(len(var), max_var) - for line in docs[section]['vars'][var]['desc'].split('\n'): - max_desc = max(len(line), max_desc) - max_val = max(len(docs[section]['vars'][var]['val']), max_val) - -def print_line(var, desc, val): - print(\ - '| ' + var + ' ' * (max_var - len(var)) + \ - ' | ' + desc + ' ' * (max_desc - len(desc)) + \ - ' | ' + val + ' ' * (max_val - len(val)) + \ - ' |') - - -print('Configuration Parameters') -print('=' * len('Configuration Parameters')) - - -for section in sorted(docs): - print('Section [ ' + section + ' ]') - print('-' * len('Section [ ' + section + ' ]')) - print('') - print(docs[section]['text']) - print('') - print('+-' + '-' * max_var + '-+-' + '-' * max_desc + '-+-' + '-' * max_val + '-+') - print_line('Parameter', 'Description', 'Example Value') - print('+=' + '=' * max_var + '=+=' + '=' * max_desc + '=+=' + '=' * max_val + '=+') - for var in sorted(docs[section]['vars']): - if docs[section]['vars'][var]: - first = True - for line in docs[section]['vars'][var]['desc'].split('\n'): - if first: - first = False - print_line( - re.sub('\*', '\\*', var), - re.sub('\*', '\\*', line), - re.sub('\*', '\\*', docs[section]['vars'][var]['val']), - ) - else: - print_line('', re.sub('\*', '\\*', line), '') - print('+-' + '-' * max_var + '-+-' + '-' * max_desc + '-+-' + '-' * max_val + '-+') - print('') -print('Full Configuration File') -print('=' * len('Full Configuration File')) -print('') -print('.. literalinclude:: ../conf/uts-server.cnf') -print(' :language: ini') -