/*- * Copyright 2016 Vsevolod Stakhov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include "config.h" #include "rspamd.h" #include "util.h" #include "libutil/http.h" #include "libutil/http_private.h" #include "ottery.h" #include "cryptobox.h" #include "unix-std.h" #include #include #ifdef HAVE_SYS_WAIT_H #include #endif static guint port = 43000; static gchar *host = "127.0.0.1"; static gchar *server_key = NULL; static guint cache_size = 10; static guint nworkers = 1; static gboolean openssl_mode = FALSE; static guint file_size = 500; static guint pconns = 100; static gdouble test_time = 10.0; static gchar *latencies_file = NULL; static gboolean csv_output = FALSE; /* Dynamic vars */ static rspamd_inet_addr_t *addr; static guint32 workers_left = 0; static guint32 *conns_done = NULL; static const guint store_latencies = 1000; static guint32 conns_pending = 0; static GOptionEntry entries[] = { {"port", 'p', 0, G_OPTION_ARG_INT, &port, "Port number (default: 43000)", NULL}, {"cache", 'c', 0, G_OPTION_ARG_INT, &cache_size, "Keys cache size (default: 10)", NULL}, {"workers", 'n', 0, G_OPTION_ARG_INT, &nworkers, "Number of workers to start (default: 1)", NULL}, {"size", 's', 0, G_OPTION_ARG_INT, &file_size, "Size of payload to transfer (default: 500)", NULL}, {"conns", 'C', 0, G_OPTION_ARG_INT, &pconns, "Number of parallel connections (default: 100)", NULL}, {"time", 't', 0, G_OPTION_ARG_DOUBLE, &test_time, "Time to run tests (default: 10.0 sec)", NULL}, {"openssl", 'o', 0, G_OPTION_ARG_NONE, &openssl_mode, "Use openssl crypto", NULL}, {"host", 'h', 0, G_OPTION_ARG_STRING, &host, "Connect to the specified host (default: localhost)", NULL}, {"key", 'k', 0, G_OPTION_ARG_STRING, &server_key, "Use the specified key (base32 encoded)", NULL}, {"latency", 'l', 0, G_OPTION_ARG_FILENAME, &latencies_file, "Write latencies to the specified file", NULL}, {"csv", 0, 0, G_OPTION_ARG_NONE, &csv_output, "Output CSV", NULL}, {NULL, 0, 0, G_OPTION_ARG_NONE, NULL, NULL, NULL} }; struct lat_elt { gdouble lat; guchar checked; }; static struct lat_elt *latencies; static gint rspamd_client_body (struct rspamd_http_connection *conn, struct rspamd_http_message *msg, const gchar *chunk, gsize len) { g_assert (chunk[0] == '\0'); return 0; } struct client_cbdata { struct lat_elt *lat; guint32 *wconns; gdouble ts; struct event_base *ev_base; }; static void rspamd_client_err (struct rspamd_http_connection *conn, GError *err) { msg_info ("abnormally closing connection from: error: %s", err->message); g_assert (0); close (conn->fd); rspamd_http_connection_unref (conn); } static gint rspamd_client_finish (struct rspamd_http_connection *conn, struct rspamd_http_message *msg) { struct client_cbdata *cb = conn->ud; cb->lat->lat = rspamd_get_ticks () - cb->ts; cb->lat->checked = TRUE; (*cb->wconns) ++; conns_pending --; close (conn->fd); rspamd_http_connection_unref (conn); g_free (cb); if (conns_pending == 0) { event_base_loopexit (cb->ev_base, NULL); } return 0; } static void rspamd_http_client_func (struct event_base *ev_base, struct lat_elt *latency, guint32 *wconns, struct rspamd_cryptobox_pubkey *peer_key, struct rspamd_cryptobox_keypair* client_key, struct rspamd_keypair_cache *c) { struct rspamd_http_message *msg; struct rspamd_http_connection *conn; gchar urlbuf[PATH_MAX]; struct client_cbdata *cb; gint fd, flags; fd = rspamd_inet_address_connect (addr, SOCK_STREAM, TRUE); g_assert (fd != -1); flags = 1; (void)setsockopt (fd, IPPROTO_TCP, TCP_NODELAY, &flags, sizeof (flags)); conn = rspamd_http_connection_new (rspamd_client_body, rspamd_client_err, rspamd_client_finish, RSPAMD_HTTP_CLIENT_SIMPLE, RSPAMD_HTTP_CLIENT, c, NULL); rspamd_snprintf (urlbuf, sizeof (urlbuf), "http://%s/%d", host, file_size); msg = rspamd_http_message_from_url (urlbuf); g_assert (conn != NULL && msg != NULL); if (peer_key != NULL) { g_assert (client_key != NULL); rspamd_http_c
/*!
 * jQuery UI Resizable @VERSION
 *
 * Copyright 2012, AUTHORS.txt (http://jqueryui.com/about)
 * Dual licensed under the MIT or GPL Version 2 licenses.
 * http://jquery.org/license
 *
 * http://docs.jquery.com/UI/Resizable#theming
 */
.ui-resizable { position: relative;}
.ui-resizable-handle { position: absolute;font-size: 0.1px; display: block; }
.ui-resizable-disabled .ui-resizable-handle, .ui-resizable-autohide .ui-resizable-handle { display: none; }
.ui-resizable-n { cursor: n-resize; height: 7px; width: 100%; top: -5px; left: 0; }
.ui-resizable-s { cursor: s-resize; height: 7px; width: 100%; bottom: -5px; left: 0; }
.ui-resizable-e { cursor: e-resize; width: 7px; right: -5px; top: 0; height: 100%; }
.ui-resizable-w { cursor: w-resize; width: 7px; left: -5px; top: 0; height: 100%; }
.ui-resizable-se { cursor: se-resize; width: 12px; height: 12px; right: 1px; bottom: 1px; }
.ui-resizable-sw { cursor: sw-resize; width: 9px; height: 9px; left: -5px; bottom: -5px; }
.ui-resizable-nw { cursor: nw-resize; width: 9px; height: 9px; left: -5px; top: -5px; }
.ui-resizable-ne { cursor: ne-resize; width: 9px; height: 9px; right: -5px; top: -5px;}