Format source code.
This commit is contained in:
parent
b58ca7d22e
commit
bdaea9872e
6 changed files with 101 additions and 22 deletions
|
@ -1,12 +1,30 @@
|
||||||
/*
|
/*
|
||||||
* Telodendria TLS Implementation Template File.
|
* Copyright (C) 2022-2023 Jordan Bancino <@jordan:bancino.net>
|
||||||
*
|
*
|
||||||
* This file can serve as a baseline for new TLS implementations.
|
* Permission is hereby granted, free of charge, to any person
|
||||||
* Please consult the Tls(3) man page for details.
|
* obtaining a copy of this software and associated documentation files
|
||||||
|
* (the "Software"), to deal in the Software without restriction,
|
||||||
|
* including without limitation the rights to use, copy, modify, merge,
|
||||||
|
* publish, distribute, sublicense, and/or sell copies of the Software,
|
||||||
|
* and to permit persons to whom the Software is furnished to do so,
|
||||||
|
* subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be
|
||||||
|
* included in all copies or portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
||||||
|
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
||||||
|
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
* SOFTWARE.
|
||||||
*/
|
*/
|
||||||
#include <Tls.h>
|
#include <Tls.h>
|
||||||
|
|
||||||
#if TLS_IMPL == TLS_TEMPLATE /* Set your TLS_* implementation flag here */
|
#if TLS_IMPL == TLS_TEMPLATE /* Set your TLS_* implementation
|
||||||
|
* flag here */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* #include statements and any implementation structures
|
* #include statements and any implementation structures
|
||||||
|
|
3
src/Io.c
3
src/Io.c
|
@ -159,7 +159,8 @@ IoVprintf(Io * io, const char *fmt, va_list ap)
|
||||||
ret = IoWrite(io, buf, bufSize);
|
ret = IoWrite(io, buf, bufSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
free(buf); /* Allocated by stdlib, not Memory API */
|
free(buf); /* Allocated by stdlib, not Memory
|
||||||
|
* API */
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -275,7 +275,7 @@ main(int argc, char **argv)
|
||||||
|
|
||||||
/* Bind the socket before possibly dropping permissions */
|
/* Bind the socket before possibly dropping permissions */
|
||||||
httpServer = HttpServerCreate(HTTP_FLAG_NONE, tConfig->listenPort, tConfig->threads,
|
httpServer = HttpServerCreate(HTTP_FLAG_NONE, tConfig->listenPort, tConfig->threads,
|
||||||
tConfig->maxConnections, MatrixHttpHandler, &matrixArgs);
|
tConfig->maxConnections, MatrixHttpHandler, &matrixArgs);
|
||||||
if (!httpServer)
|
if (!httpServer)
|
||||||
{
|
{
|
||||||
Log(lc, LOG_ERR, "Unable to create HTTP server on port %d: %s",
|
Log(lc, LOG_ERR, "Unable to create HTTP server on port %d: %s",
|
||||||
|
|
23
src/Tls.c
23
src/Tls.c
|
@ -1,3 +1,26 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2022-2023 Jordan Bancino <@jordan:bancino.net>
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person
|
||||||
|
* obtaining a copy of this software and associated documentation files
|
||||||
|
* (the "Software"), to deal in the Software without restriction,
|
||||||
|
* including without limitation the rights to use, copy, modify, merge,
|
||||||
|
* publish, distribute, sublicense, and/or sell copies of the Software,
|
||||||
|
* and to permit persons to whom the Software is furnished to do so,
|
||||||
|
* subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be
|
||||||
|
* included in all copies or portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
||||||
|
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
||||||
|
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
* SOFTWARE.
|
||||||
|
*/
|
||||||
#include <Tls.h>
|
#include <Tls.h>
|
||||||
|
|
||||||
#ifdef TLS_IMPL
|
#ifdef TLS_IMPL
|
||||||
|
|
|
@ -1,9 +1,32 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2022-2023 Jordan Bancino <@jordan:bancino.net>
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person
|
||||||
|
* obtaining a copy of this software and associated documentation files
|
||||||
|
* (the "Software"), to deal in the Software without restriction,
|
||||||
|
* including without limitation the rights to use, copy, modify, merge,
|
||||||
|
* publish, distribute, sublicense, and/or sell copies of the Software,
|
||||||
|
* and to permit persons to whom the Software is furnished to do so,
|
||||||
|
* subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be
|
||||||
|
* included in all copies or portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
||||||
|
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
||||||
|
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
* SOFTWARE.
|
||||||
|
*/
|
||||||
#include <Tls.h>
|
#include <Tls.h>
|
||||||
|
|
||||||
#if TLS_IMPL == TLS_LIBRESSL
|
#if TLS_IMPL == TLS_LIBRESSL
|
||||||
|
|
||||||
#include <Memory.h>
|
#include <Memory.h>
|
||||||
#include <tls.h> /* LibreSSL TLS */
|
#include <tls.h> /* LibreSSL TLS */
|
||||||
|
|
||||||
typedef struct LibreSSLCookie
|
typedef struct LibreSSLCookie
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,38 +1,52 @@
|
||||||
#ifndef TELODENDRIA_TLS_H
|
|
||||||
#define TELODENDRIA_TLS_H
|
|
||||||
|
|
||||||
#define TLS_LIBRESSL 1
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Other TLS_* macros can be declared here as support
|
* Copyright (C) 2022-2023 Jordan Bancino <@jordan:bancino.net>
|
||||||
* for other implementations is added.
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person
|
||||||
|
* obtaining a copy of this software and associated documentation files
|
||||||
|
* (the "Software"), to deal in the Software without restriction,
|
||||||
|
* including without limitation the rights to use, copy, modify, merge,
|
||||||
|
* publish, distribute, sublicense, and/or sell copies of the Software,
|
||||||
|
* and to permit persons to whom the Software is furnished to do so,
|
||||||
|
* subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be
|
||||||
|
* included in all copies or portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
||||||
|
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
||||||
|
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
* SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <Stream.h>
|
#include <Stream.h>
|
||||||
|
|
||||||
extern Stream *
|
extern Stream *
|
||||||
TlsClientStream(int, const char *);
|
TlsClientStream(int, const char *);
|
||||||
|
|
||||||
extern Stream *
|
extern Stream *
|
||||||
TlsServerStream(int, const char *, const char *);
|
TlsServerStream(int, const char *, const char *);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* These are provided by individual TLS implementations.
|
* These are provided by individual TLS implementations.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
extern void *
|
extern void *
|
||||||
TlsInitClient(int, const char *);
|
TlsInitClient(int, const char *);
|
||||||
|
|
||||||
extern void *
|
extern void *
|
||||||
TlsInitServer(int, const char *, const char *);
|
TlsInitServer(int, const char *, const char *);
|
||||||
|
|
||||||
extern ssize_t
|
extern ssize_t
|
||||||
TlsRead(void *, void *, size_t);
|
TlsRead(void *, void *, size_t);
|
||||||
|
|
||||||
extern ssize_t
|
extern ssize_t
|
||||||
TlsWrite(void *, void *, size_t);
|
TlsWrite(void *, void *, size_t);
|
||||||
|
|
||||||
extern int
|
extern int
|
||||||
TlsClose(void *);
|
TlsClose(void *);
|
||||||
|
|
||||||
#endif /* TELODENDRIA_TLS_H */
|
#endif /* TELODENDRIA_TLS_H */
|
||||||
|
|
Loading…
Reference in a new issue