])
])
-AC_CONFIG_FILES([Makefile src/Makefile src/IOHandler/Makefile src/IOHandler++/Makefile src/IOHandler_test/Makefile src/IOHandler_test/socket/Makefile src/IOHandler_test/socket++/Makefile src/IOHandler_test/timer/Makefile src/IOHandler_test/resolv/Makefile])
+AC_CONFIG_FILES([
+ Makefile
+ src/Makefile
+ src/IOHandler/Makefile
+ src/IOHandler++/Makefile
+ src/IOHandler_test/Makefile
+ src/IOHandler_test/client/Makefile
+ src/IOHandler_test/client++/Makefile
+ src/IOHandler_test/client_ssl/Makefile
+ src/IOHandler_test/server_ssl/Makefile
+ src/IOHandler_test/timer/Makefile
+ src/IOHandler_test/resolv/Makefile
+])
AC_OUTPUT
gnutls_certificate_allocate_credentials(&sslnode->ssl.server.credentials);
int ret = gnutls_certificate_set_x509_key_file(sslnode->ssl.server.credentials, certfile, keyfile, GNUTLS_X509_FMT_PEM);
if (ret < 0) {
- iolog_trigger(IOLOG_ERROR, "SSL: could not load server certificate/key (%s %s)", certfile, keyfile);
+ iolog_trigger(IOLOG_ERROR, "SSL: could not load server certificate/key (%s %s): %d - %s", certfile, keyfile, ret, gnutls_strerror(ret));
goto ssl_listen_err;
}
##Process this file with automake to create Makefile.in
ACLOCAL_AMFLAGS = -I m4
-SUBDIRS = socket socket++ timer resolv
+SUBDIRS = client client++ client_ssl server_ssl timer resolv
--- /dev/null
+.deps
+.libs
+*.o
+*.exe
+iotest
+Makefile
+Makefile.in
--- /dev/null
+##Process this file with automake to create Makefile.in
+ACLOCAL_AMFLAGS = -I m4
+
+noinst_PROGRAMS = iotest
+
+iotest_LDADD = ../../IOHandler++/libiohandler.cpp.la
+iotest_SOURCES = iotest.cpp
--- /dev/null
+/* main.c - IOMultiplexer
+ * Copyright (C) 2012 Philipp Kreil (pk910)
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <stdio.h>
+#include "../../IOHandler++/IOHandler.h"
+#include "../../IOHandler++/IOSocket.h"
+
+class IOTestSocket : public CIOSocket {
+protected:
+ virtual void connectedEvent() {
+ printf("[connect]\n");
+ this->writef("GET / HTTP/1.1\r\n");
+ this->writef("Host: test.pk910.de\r\n");
+ this->writef("\r\n");
+ };
+ virtual void notConnectedEvent(int errid) {
+ printf("[not connected]\n");
+ };
+ virtual void closedEvent(int errid) {
+ printf("[disconnect]\n");
+ };
+ virtual void acceptedEvent(CIOSocket *client) {
+ client->close();
+ };
+ virtual void dnsErrEvent(std::string *errormsg) {
+
+ };
+ virtual int recvEvent(const char *data, int len) {
+ int i;
+ for(i = 0; i < len; i++)
+ putchar(data[i]);
+ return len;
+ };
+};
+
+
+int main(int argc, char *argv[]) {
+ CIOHandler *iohandler = new CIOHandler();
+ IOTestSocket *sock = new IOTestSocket();
+ sock->connect("test.pk910.de", 443, 1, NULL);
+
+ iohandler->start();
+}
--- /dev/null
+.deps
+.libs
+*.o
+*.exe
+iotest
+Makefile
+Makefile.in
--- /dev/null
+##Process this file with automake to create Makefile.in
+ACLOCAL_AMFLAGS = -I m4
+
+noinst_PROGRAMS = iotest
+iotest_LDADD = ../../IOHandler/libiohandler.la
+
+iotest_SOURCES = iotest.c
+
--- /dev/null
+/* main.c - IOMultiplexer
+ * Copyright (C) 2012 Philipp Kreil (pk910)
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <stdio.h>
+#include "../../IOHandler/IOHandler.h"
+#include "../../IOHandler/IOSockets.h"
+#include "../../IOHandler/IOLog.h"
+
+static IOSOCKET_CALLBACK(io_callback);
+static IOLOG_CALLBACK(io_log);
+
+static struct IOSocket *irc_iofd = NULL;
+
+int main(int argc, char *argv[]) {
+ iohandler_init();
+
+ iolog_register_callback(io_log);
+
+ irc_iofd = iosocket_connect("test.pk910.de", 80, 0, NULL, io_callback);
+
+ iohandler_run();
+
+ return 0;
+}
+
+static IOSOCKET_CALLBACK(io_callback) {
+ switch(event->type) {
+ case IOSOCKETEVENT_CONNECTED:
+ printf("[connect]\n");
+ iosocket_printf(event->socket, "GET / HTTP/1.1\r\n");
+ iosocket_printf(event->socket, "Host: test.pk910.de\r\n");
+ iosocket_printf(event->socket, "\r\n");
+ break;
+ case IOSOCKETEVENT_CLOSED:
+ printf("[disconnect]\n");
+ break;
+ case IOSOCKETEVENT_RECV:
+ {
+ struct IOSocketBuffer *recv_buf = event->data.recv_buf;
+ int i;
+ for(i = 0; i < recv_buf->bufpos; i++)
+ putchar(recv_buf->buffer[i]);
+ recv_buf->bufpos = 0;
+ printf("\n");
+ }
+ break;
+
+ default:
+ break;
+ }
+}
+
+static IOLOG_CALLBACK(io_log) {
+ printf("%s", message);
+}
--- /dev/null
+.deps
+.libs
+*.o
+*.exe
+iotest
+Makefile
+Makefile.in
--- /dev/null
+##Process this file with automake to create Makefile.in
+ACLOCAL_AMFLAGS = -I m4
+
+noinst_PROGRAMS = iotest
+iotest_LDADD = ../../IOHandler/libiohandler.la
+
+iotest_SOURCES = iotest.c
+
--- /dev/null
+/* main.c - IOMultiplexer
+ * Copyright (C) 2012 Philipp Kreil (pk910)
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <stdio.h>
+#include "../../IOHandler/IOHandler.h"
+#include "../../IOHandler/IOSockets.h"
+#include "../../IOHandler/IOLog.h"
+
+static IOSOCKET_CALLBACK(io_callback);
+static IOLOG_CALLBACK(io_log);
+
+static struct IOSocket *irc_iofd = NULL;
+
+int main(int argc, char *argv[]) {
+ iohandler_init();
+
+ iolog_register_callback(io_log);
+
+ irc_iofd = iosocket_connect("test.pk910.de", 443, 1, NULL, io_callback);
+
+ iohandler_run();
+
+ return 0;
+}
+
+static IOSOCKET_CALLBACK(io_callback) {
+ switch(event->type) {
+ case IOSOCKETEVENT_CONNECTED:
+ printf("[connect]\n");
+ iosocket_printf(event->socket, "GET / HTTP/1.1\r\n");
+ iosocket_printf(event->socket, "Host: test.pk910.de\r\n");
+ iosocket_printf(event->socket, "\r\n");
+ break;
+ case IOSOCKETEVENT_CLOSED:
+ printf("[disconnect]\n");
+ break;
+ case IOSOCKETEVENT_RECV:
+ {
+ struct IOSocketBuffer *recv_buf = event->data.recv_buf;
+ int i;
+ for(i = 0; i < recv_buf->bufpos; i++)
+ putchar(recv_buf->buffer[i]);
+ recv_buf->bufpos = 0;
+ printf("\n");
+ }
+ break;
+
+ default:
+ break;
+ }
+}
+
+static IOLOG_CALLBACK(io_log) {
+ printf("%s", message);
+}
--- /dev/null
+.deps
+.libs
+*.o
+*.exe
+iotest
+Makefile
+Makefile.in
--- /dev/null
+##Process this file with automake to create Makefile.in
+ACLOCAL_AMFLAGS = -I m4
+
+noinst_PROGRAMS = iotest
+iotest_LDADD = ../../IOHandler/libiohandler.la
+
+iotest_SOURCES = iotest.c
+
--- /dev/null
+-----B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IZjw3
+sXKMN1PuCvuWz8Wlff4xgO3VgnshXn51KhGfasK4KVD6yWFfG6noBZ9lH5EuaqJr
+VjrOdMP0cUP2vKv3bswfV4rVy1fJz3g+Sw==
+-----END CERTIFICATE-----
--- /dev/null
+/* main.c - IOMultiplexer
+ * Copyright (C) 2012 Philipp Kreil (pk910)
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include "../../IOHandler/IOHandler.h"
+#include "../../IOHandler/IOSockets.h"
+#include "../../IOHandler/IOLog.h"
+
+#define CERTFILE "cert.pem"
+#define KEYFILE "key.pen"
+
+static IOSOCKET_CALLBACK(io_callback);
+static IOLOG_CALLBACK(io_log);
+
+static struct IOSocket *irc_iofd = NULL;
+
+int main(int argc, char *argv[]) {
+ iohandler_init();
+
+ iolog_register_callback(io_log);
+
+ irc_iofd = iosocket_listen_ssl("0.0.0.0", 12345, CERTFILE, KEYFILE, io_callback);
+
+ iohandler_run();
+
+ return 0;
+}
+
+static IOSOCKET_CALLBACK(io_callback) {
+ switch(event->type) {
+ case IOSOCKETEVENT_ACCEPT:
+ printf("[client accepted]\n");
+ struct IOSocket *client = event->data.accept_socket;
+ client->callback = io_callback;
+
+ char *html = "<html><head><title>Test Page</title></head><body><h1>IOHandler SSL Test</h1></body></html>";
+ iosocket_printf(client, "HTTP/1.1 200 OK\r\n");
+ iosocket_printf(client, "Server: Apache\r\n");
+ iosocket_printf(client, "Content-Length: %d\r\n", strlen(html));
+ iosocket_printf(client, "Content-Type: text/html\r\n");
+ iosocket_printf(client, "\r\n");
+ iosocket_printf(client, "%s", html);
+
+ break;
+ case IOSOCKETEVENT_CLOSED:
+ if(event->socket->listening)
+ printf("[server closed]\n");
+ else
+ printf("[client disconnect]\n");
+ break;
+ case IOSOCKETEVENT_RECV:
+ {
+ struct IOSocketBuffer *recv_buf = event->data.recv_buf;
+ int i;
+ for(i = 0; i < recv_buf->bufpos; i++)
+ putchar(recv_buf->buffer[i]);
+ recv_buf->bufpos = 0;
+ printf("\n");
+ }
+ break;
+
+ default:
+ break;
+ }
+}
+
+static IOLOG_CALLBACK(io_log) {
+ printf("%s", message);
+}
--- /dev/null
+-----BEGIN PRIVATE KEY-----
+MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCbY6vEmGl9wkqR
+cNZ4JJ0XkpLM54I2D+R6HJxSOG9WHCbNMLvYmTg6VHFp0A2EpoyijJ+SqrKbCFnz
+7uoIvvo3p7dh5+vQROFobT1R6vAWucZC3Cgz8XYXsKdmHz4Wie+wjb/gEFYKmZaK
+yLEXu4KP572tCVuya3NBWDtVu+/30V0F6GJYRvYejFecLe97b5/Lu0FG9DX2oFex
+MaeNlua/oxT6KB770i//g/yiNqDo2OvVy4tNtSAvmzVVVJNtJL7uFb7GYbpLki4/
+PfLUhchGybKx/b69LYJzDGTA3FK/CsWqwliwSr836xDytX06eWdr2Ti8NiMw/MHB
+b/FKSmHzAgMBAAECggEAHHHxdqqj3QadGeS7DgE91JvbTbEvj+/21je4kgCMuQms
+PLGoIW1i8qKUpFcWsmq+od72MyYWTfUIanQY2YMEUP3dvwlyjIyfartcl0tXqgFV
+/tVIcsHH6WxIKJSdjAiyHPLF5iF3brdQ7JTyfjKwIuG8QhnNdGrhDVw2eGpP8mBT
+DRL8qX1KrAvZLGzDq19kX4o49oPfq+eXXZVB+xgAmyT+YtD4tVi0fvDW5J6nET3s
+/qxvx5No35HD3f1V9Xjth4DRIr2eUDqTVVqZ2sTMGF4kbDcdxZl4iOORJO2VhcQC
+UUXxt038NkHAom0vT6GFJQbPLb6b8obBxz2KyYp7AQKBgQDJ3O9kEOGtaymojkq1
+y1MEyYLyk0FCdjCTMcbK8A3455ZyhQiNKNiDcZy9WUaZBppDpSJ1RjCaUL+4QX51
+BbK18W1YO2INR/DMhyZEmLnPbqubqoVLIGz/LBW44BPwz8jjvZT13yiFL0Afa4xi
+vRvdYAju+f28rmpswtvG3Im3gQKBgQDFEAxaY0PSTnwzPdDJZqQyYvpkqj/eJXxP
+FrH+LHC3Ug0SRrQ/C223kpc1m9OivaCz/7jCozjNws4Dus6hRzn6d6r4ChjatBqC
+Y97EE5SvvAJrDaA6J0GQ8paaoDe9TJ+/4qFiG4FdYwmrCuNU5cdypbWGaaXlTTBG
+OmfSyf5zcwKBgBwWeNzkmHJH6fkBK5YWH4wX+feE09zKk0G3+GA+fMM4fi+bITB7
+EX1grp2OMYuTZp2o+Z110cd3GuYpfs4Lp+03Fa7kPGV6sB/VYlbDJX+ed5Rmaruk
+XGY5HSCnVT75uost0u9PSNUXWQXGMjd+9sSb20JdWJgLcNWHW4tVHniBAoGBAJh0
+l/n9veSgT7oc4sBNpk5NAMaMaCjm+0r8leu8Wd+ZnP88sAnuP4273TveOFc5OXDI
+MBp0yGd3hIaiKWXggtxhZGXM+fmJSNEDjr5HH8rtOzmzKviSkkkfRKCPv0+2TgjX
+vl72RJkJG9u16rYtpqXtyYgZh/zkQKq0WMpc93w9AoGALWfwrj5eSDi5EDWbjgBF
+zm87FoDcIvMDpTsw4xA/o9JpDLLVdsJYf/uwLPDUkMHWy0w2dioQu+VoLu480l1K
+27a3jvIIWClV3xVulm9abLY//79eARDG+bwXC30e7z6wduw8LtJsOfWD9nFd9ggt
+rT1g4c/bHYflEb2MieXZ4UQ=
+-----END PRIVATE KEY-----
+++ /dev/null
-.deps
-.libs
-*.o
-*.exe
-iotest
-Makefile
-Makefile.in
+++ /dev/null
-##Process this file with automake to create Makefile.in
-ACLOCAL_AMFLAGS = -I m4
-
-noinst_PROGRAMS = iotest
-
-iotest_LDADD = ../../IOHandler++/libiohandler.cpp.la
-iotest_SOURCES = iotest.cpp
+++ /dev/null
-/* main.c - IOMultiplexer
- * Copyright (C) 2012 Philipp Kreil (pk910)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include <stdio.h>
-#include "../../IOHandler++/IOHandler.h"
-#include "../../IOHandler++/IOSocket.h"
-
-class IOTestSocket : public CIOSocket {
-protected:
- virtual void connectedEvent() {
- printf("[connect]\n");
- this->writef("GET / HTTP/1.1\r\n");
- this->writef("Host: test.pk910.de\r\n");
- this->writef("\r\n");
- };
- virtual void notConnectedEvent(int errid) {
- printf("[not connected]\n");
- };
- virtual void closedEvent(int errid) {
- printf("[disconnect]\n");
- };
- virtual void acceptedEvent(CIOSocket *client) {
- client->close();
- };
- virtual void dnsErrEvent(std::string *errormsg) {
-
- };
- virtual int recvEvent(const char *data, int len) {
- int i;
- for(i = 0; i < len; i++)
- putchar(data[i]);
- return len;
- };
-};
-
-
-int main(int argc, char *argv[]) {
- CIOHandler *iohandler = new CIOHandler();
- IOTestSocket *sock = new IOTestSocket();
- sock->connect("test.pk910.de", 443, 1, NULL);
-
- iohandler->start();
-}
+++ /dev/null
-.deps
-.libs
-*.o
-*.exe
-iotest
-Makefile
-Makefile.in
+++ /dev/null
-##Process this file with automake to create Makefile.in
-ACLOCAL_AMFLAGS = -I m4
-
-noinst_PROGRAMS = iotest
-iotest_LDADD = ../../IOHandler/libiohandler.la
-
-iotest_SOURCES = iotest.c
-
+++ /dev/null
-/* main.c - IOMultiplexer
- * Copyright (C) 2012 Philipp Kreil (pk910)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include <stdio.h>
-#include "../../IOHandler/IOHandler.h"
-#include "../../IOHandler/IOSockets.h"
-#include "../../IOHandler/IOLog.h"
-
-static IOSOCKET_CALLBACK(io_callback);
-static IOLOG_CALLBACK(io_log);
-
-static struct IOSocket *irc_iofd = NULL;
-
-int main(int argc, char *argv[]) {
- iohandler_init();
-
- iolog_register_callback(io_log);
-
- irc_iofd = iosocket_connect("test.pk910.de", 443, 1, NULL, io_callback);
-
- iohandler_run();
-
- return 0;
-}
-
-static IOSOCKET_CALLBACK(io_callback) {
- switch(event->type) {
- case IOSOCKETEVENT_CONNECTED:
- printf("[connect]\n");
- iosocket_printf(event->socket, "GET / HTTP/1.1\r\n");
- iosocket_printf(event->socket, "Host: test.pk910.de\r\n");
- iosocket_printf(event->socket, "\r\n");
- break;
- case IOSOCKETEVENT_CLOSED:
- printf("[disconnect]\n");
- break;
- case IOSOCKETEVENT_RECV:
- {
- struct IOSocketBuffer *recv_buf = event->data.recv_buf;
- int i;
- for(i = 0; i < recv_buf->bufpos; i++)
- putchar(recv_buf->buffer[i]);
- recv_buf->bufpos = 0;
- printf("\n");
- }
- break;
-
- default:
- break;
- }
-}
-
-static IOLOG_CALLBACK(io_log) {
- printf("%s", message);
-}