2004-01-28 20:02:12 -05:00
|
|
|
/* Icecast
|
|
|
|
*
|
|
|
|
* This program is distributed under the GNU General Public License, version 2.
|
|
|
|
* A copy of this license is included with this source.
|
|
|
|
*
|
2015-01-10 13:53:44 -05:00
|
|
|
* Copyright 2000-2004, Jack Moffitt <jack@xiph.org,
|
2004-01-28 20:02:12 -05:00
|
|
|
* Michael Smith <msmith@xiph.org>,
|
|
|
|
* oddsock <oddsock@xiph.org>,
|
|
|
|
* Karl Heyes <karl@xiph.org>
|
|
|
|
* and others (see AUTHORS for details).
|
Wow. Mega patch!
This patch *replaces* the authentication system completly.
What is new:
- <authentication> in mount section is now a container object.
- <authentication> in root and mount section may hold any number of <role>-Tags.
- <role> tags:
Those tags define a 'role' and it's ACL rules.
A role is a instance of an authentication module (see below).
<role> takes the following options. All but type are optional.
- authentication related:
- type: Type of the authentication module (values: anonymous, static, legacy-password, url or htpasswd;
symbolic constants in auth.h)
- name: Name for the role. For later matching. (values: any string; default: (none))
- method: This rule is only active on the given list of HTTP methods.
(list of enum values: methods as recognized by httpp/ (e.g: get,post); default: *)
- ACL related:
- allow-method: Allowed HTTP methods.
(list of enum values: methods as recognized by httpp/ (e.g: get,post); default: get)
- deny-method: Rejected HTTP methods.
(list of enum values: methods as recognized by httpp/ (e.g: get,post); default: *)
- allow-admin: Allowed admin commands. (list of enum values: admin command; default: buildm3u)
- deny-admin: Rejected admin commands. (list of enum values: admin command; default: *)
- allow-web: Allowed web pages. (values: empty or *; default: *)
- deny-web: Rejected web pages. (values: empty or *; default: (empty))
- connections-per-user: maximum number of simultaneous connections per role and username.
This is only active on active sources. (values: unlimited or number of connections; default: unlimited)
- connection-duration: maximum time of a connection. This is only active on active sources.
(values: unlimited or number of secounds; default: unlimited)
<role> takes <option> child tags. <option> tags contain a name and a value option.
Meaning of <option> tags is up to the authentication module.
- <role>s are considered to build a stack. If a role returns with AUTH_NOMATCH the next one will be tried.
- <role>s are tested in this order: mount specific, default mount specific, global, internal fallback.
Internal fallback is set to allow web/ access via GET, POST and HEAD (only GET supported by this time)
and rejects all other requests.
- New authentication module: anonymous
This module matches all requests. No options taken.
- New authentication module: static
This module matches with a static username and password.
It takes two <option>s. One with name="username" and one with name="password" to set username and password.
This replaces old style <*-username> and <*-password> tags.
- New authentication module: legacy-password
This module matches with a statich password.
It takes one <option> with name="password" to set password.
This replaces old ICE and ICY (shoutcast compat mode) authentication.
- Parsing <authentication> in <mount> with a type set in a special way to allow 100% backward compatibility.
- Parsing of <source-password>, <admin-password>, <admin-user>, <relay-password> and <relay-user> in global
<authentication> for 100% backward compatibility.
- <alias> is now proccessed very early. This enables them to be used for all kinds of requests.
To Do List & What does not yet work:
- type="url" auth: mount_add and mount_remove.
This should be replaced by an unique feature I would call '<event>'.
- Admin commands manageauth and manageauth.xsl are disabled as they need more review:
This code needs to be ported to support multiple <role>s per <mount>.
- url authentication module can not yet return AUTH_NOMATCH.
This needs to be reviewed and discussed on how to handle this case best way.
- Default config files needs to be updated to reflect the changes.
As this is quite some political act it should be done in dicussion with the whole team
and permission of the release manager.
- Docs need to be updated to reflect the changes.
How does it work:
Code has been changed so that authentification is done early for all clients.
This allows accessing the ACL data (client->acl) from nearly everywhere in the code.
After accept() and initial client setup the request is parsed. In the next step
all <alias>es are resolved. After this the client is passed for authentication.
After authentication it is passed to the corresponding subsystem depending on kind of request.
All authentication instances have a thread running for doing the authentication.
This thread works on a queue of clients.
Hints for testers:
- Test with default config.
- Test with diffrent authentication modules in <mount>.
- Test shoutcast compatibility mode.
- Test with new style <authentication> and any amount of <role> (zero to quite some).
- Test <alias> lookup on all kinds of objects.
- Test source level credential login into the admin interface.
- Test shoucast style meta data updates.
- Test playlist generation.
Thank you for reading this long commit message. Have fun reading the full patch!
svn path=/icecast/trunk/icecast/; revision=19358
2014-11-28 18:46:08 -05:00
|
|
|
* Copyright 2011, Dave 'justdave' Miller <justdave@mozilla.com>,
|
2022-03-01 06:17:28 -05:00
|
|
|
* Copyright 2011-2022, Philipp "ph3-der-loewe" Schafft <lion@lion.leolix.org>,
|
2004-01-28 20:02:12 -05:00
|
|
|
*/
|
|
|
|
|
2003-03-27 12:10:14 -05:00
|
|
|
/* -*- c-basic-offset: 4; indent-tabs-mode: nil; -*- */
|
2003-07-20 21:58:54 -04:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include <config.h>
|
|
|
|
#endif
|
|
|
|
|
2001-09-09 22:21:46 -04:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
2022-03-01 03:43:47 -05:00
|
|
|
#include <stdbool.h>
|
2007-11-15 10:12:21 -05:00
|
|
|
#include <errno.h>
|
2001-09-09 22:21:46 -04:00
|
|
|
#include <string.h>
|
2003-03-09 06:27:06 -05:00
|
|
|
#ifdef HAVE_POLL
|
2018-08-14 14:03:01 -04:00
|
|
|
#include <poll.h>
|
2003-03-09 06:27:06 -05:00
|
|
|
#endif
|
2007-10-23 18:25:31 -04:00
|
|
|
#include <sys/types.h>
|
2001-10-20 02:43:04 -04:00
|
|
|
|
|
|
|
#ifndef _WIN32
|
2001-09-09 22:21:46 -04:00
|
|
|
#include <sys/socket.h>
|
|
|
|
#include <netinet/in.h>
|
2001-10-20 02:43:04 -04:00
|
|
|
#else
|
2002-02-06 20:04:09 -05:00
|
|
|
#include <winsock2.h>
|
2001-10-20 02:43:04 -04:00
|
|
|
#endif
|
2001-09-09 22:21:46 -04:00
|
|
|
|
2014-12-02 16:50:57 -05:00
|
|
|
#include "common/thread/thread.h"
|
|
|
|
#include "common/avl/avl.h"
|
|
|
|
#include "common/net/sock.h"
|
|
|
|
#include "common/httpp/httpp.h"
|
2001-09-09 22:21:46 -04:00
|
|
|
|
2018-06-17 08:47:35 -04:00
|
|
|
#include "compat.h"
|
|
|
|
#include "connection.h"
|
2022-03-19 08:46:28 -04:00
|
|
|
#include "connection_handle.h"
|
2003-07-20 21:58:54 -04:00
|
|
|
#include "cfgfile.h"
|
2001-09-09 22:21:46 -04:00
|
|
|
#include "global.h"
|
|
|
|
#include "util.h"
|
2018-05-28 10:04:07 -04:00
|
|
|
#include "refobject.h"
|
2001-09-09 22:21:46 -04:00
|
|
|
#include "refbuf.h"
|
|
|
|
#include "client.h"
|
2018-04-28 09:49:36 -04:00
|
|
|
#include "errors.h"
|
2001-09-09 22:21:46 -04:00
|
|
|
#include "stats.h"
|
|
|
|
#include "logging.h"
|
2002-08-18 01:06:58 -04:00
|
|
|
#include "fserve.h"
|
2018-06-17 08:28:38 -04:00
|
|
|
#include "slave.h"
|
2003-02-02 09:33:47 -05:00
|
|
|
|
2001-09-09 22:21:46 -04:00
|
|
|
#include "source.h"
|
2003-03-06 09:17:33 -05:00
|
|
|
#include "admin.h"
|
2004-01-14 20:01:09 -05:00
|
|
|
#include "auth.h"
|
2015-01-05 17:06:53 -05:00
|
|
|
#include "matchfile.h"
|
2016-10-20 04:24:52 -04:00
|
|
|
#include "tls.h"
|
2018-06-17 08:28:38 -04:00
|
|
|
#include "acl.h"
|
2018-04-18 01:43:46 -04:00
|
|
|
#include "refobject.h"
|
|
|
|
#include "listensocket.h"
|
2018-07-05 06:49:59 -04:00
|
|
|
#include "fastevent.h"
|
2020-10-24 07:25:42 -04:00
|
|
|
#include "navigation.h"
|
2001-09-09 22:21:46 -04:00
|
|
|
|
|
|
|
#define CATMODULE "connection"
|
|
|
|
|
2004-11-11 10:47:33 -05:00
|
|
|
/* Two different major types of source authentication.
|
|
|
|
Shoutcast style is used only by the Shoutcast DSP
|
|
|
|
and is a crazy version of HTTP. It looks like :
|
|
|
|
Source Client -> Connects to port + 1
|
|
|
|
Source Client -> sends encoder password (plaintext)\r\n
|
|
|
|
Icecast -> reads encoder password, if ok, sends OK2\r\n, else disconnects
|
|
|
|
Source Client -> reads OK2\r\n, then sends http-type request headers
|
|
|
|
that contain the stream details (icy-name, etc..)
|
|
|
|
Icecast -> reads headers, stores them
|
|
|
|
Source Client -> starts sending MP3 data
|
|
|
|
Source Client -> periodically updates metadata via admin.cgi call
|
|
|
|
|
|
|
|
Icecast auth style uses HTTP and Basic Authorization.
|
|
|
|
*/
|
|
|
|
|
2005-08-11 19:29:58 -04:00
|
|
|
typedef struct client_queue_tag {
|
|
|
|
client_t *client;
|
|
|
|
int offset;
|
|
|
|
int shoutcast;
|
2007-10-24 22:25:49 -04:00
|
|
|
char *shoutcast_mount;
|
2018-06-18 17:40:47 -04:00
|
|
|
char *bodybuffer;
|
|
|
|
size_t bodybufferlen;
|
2018-06-18 17:08:17 -04:00
|
|
|
int tried_body;
|
2022-03-19 17:50:42 -04:00
|
|
|
bool ready;
|
2005-08-11 19:29:58 -04:00
|
|
|
struct client_queue_tag *next;
|
2022-03-19 13:38:12 -04:00
|
|
|
} client_queue_entry_t;
|
2001-09-09 22:21:46 -04:00
|
|
|
|
2022-03-19 15:05:53 -04:00
|
|
|
typedef struct {
|
|
|
|
client_queue_entry_t *head;
|
|
|
|
client_queue_entry_t **tail;
|
|
|
|
mutex_t mutex;
|
2022-03-20 07:10:17 -04:00
|
|
|
cond_t cond;
|
|
|
|
thread_type *thread;
|
|
|
|
bool running;
|
2022-03-19 17:50:42 -04:00
|
|
|
#ifdef HAVE_POLL
|
|
|
|
struct pollfd *pollfds;
|
|
|
|
size_t pollfds_len;
|
|
|
|
#endif
|
2022-03-19 15:05:53 -04:00
|
|
|
} client_queue_t;
|
|
|
|
|
2022-03-20 09:15:31 -04:00
|
|
|
#define QUEUE_READY_TIMEOUT 50
|
2022-03-20 07:10:17 -04:00
|
|
|
|
2022-03-19 15:05:53 -04:00
|
|
|
static spin_t _connection_lock; // protects _current_id
|
2018-07-06 09:55:39 -04:00
|
|
|
static volatile connection_id_t _current_id = 0;
|
2001-09-09 22:21:46 -04:00
|
|
|
static int _initialized = 0;
|
|
|
|
|
2022-03-19 15:05:53 -04:00
|
|
|
static client_queue_t _request_queue;
|
|
|
|
static client_queue_t _connection_queue;
|
|
|
|
static client_queue_t _body_queue;
|
2022-03-01 03:43:47 -05:00
|
|
|
static bool tls_ok = false;
|
2016-10-20 04:24:52 -04:00
|
|
|
static tls_ctx_t *tls_ctx;
|
2007-08-28 23:51:22 -04:00
|
|
|
|
2007-10-23 18:25:31 -04:00
|
|
|
/* filtering client connection based on IP */
|
2015-01-05 17:06:53 -05:00
|
|
|
static matchfile_t *banned_ip, *allowed_ip;
|
2007-10-23 18:25:31 -04:00
|
|
|
|
2002-08-05 10:48:04 -04:00
|
|
|
rwlock_t _source_shutdown_rwlock;
|
2001-09-09 22:21:46 -04:00
|
|
|
|
2008-07-21 22:24:30 -04:00
|
|
|
static void _handle_connection(void);
|
2016-11-06 05:59:15 -05:00
|
|
|
static void get_tls_certificate(ice_config_t *config);
|
2022-03-19 15:15:34 -04:00
|
|
|
static void free_client_node(client_queue_entry_t *node);
|
2022-03-20 07:10:17 -04:00
|
|
|
static void * process_request_queue (client_queue_t *queue);
|
|
|
|
static void * process_request_body_queue (client_queue_t *queue);
|
2001-09-09 22:21:46 -04:00
|
|
|
|
2022-03-19 15:05:53 -04:00
|
|
|
static void client_queue_init(client_queue_t *queue)
|
|
|
|
{
|
|
|
|
memset(queue, 0, sizeof(*queue));
|
|
|
|
queue->tail = &(queue->head);
|
|
|
|
thread_mutex_create(&(queue->mutex));
|
2022-03-20 07:10:17 -04:00
|
|
|
thread_cond_create(&(queue->cond));
|
2022-03-19 15:05:53 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void client_queue_destroy(client_queue_t *queue)
|
|
|
|
{
|
2022-03-20 07:10:17 -04:00
|
|
|
if (queue->thread) {
|
|
|
|
queue->running = false;
|
|
|
|
thread_cond_broadcast(&(queue->cond));
|
|
|
|
thread_join(queue->thread);
|
|
|
|
}
|
|
|
|
thread_cond_destroy(&(queue->cond));
|
2022-03-19 15:05:53 -04:00
|
|
|
thread_mutex_destroy(&(queue->mutex));
|
2022-03-19 17:50:42 -04:00
|
|
|
#ifdef HAVE_POLL
|
|
|
|
free(queue->pollfds);
|
|
|
|
#endif
|
2022-03-19 15:05:53 -04:00
|
|
|
}
|
|
|
|
|
2022-03-20 07:10:17 -04:00
|
|
|
static void client_queue_start_thread(client_queue_t *queue, void *(*func)(client_queue_t *))
|
|
|
|
{
|
|
|
|
if (queue->thread)
|
|
|
|
return;
|
|
|
|
queue->running = true;
|
|
|
|
queue->thread = thread_create("queue thread", (void*(*)(void*))func, queue, THREAD_ATTACHED);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline bool client_queue_running(client_queue_t *queue)
|
|
|
|
{
|
|
|
|
return queue->running;
|
|
|
|
}
|
|
|
|
|
2022-03-19 15:05:53 -04:00
|
|
|
static void client_queue_add(client_queue_t *queue, client_queue_entry_t *entry)
|
|
|
|
{
|
|
|
|
thread_mutex_lock(&(queue->mutex));
|
|
|
|
*(queue->tail) = entry;
|
|
|
|
queue->tail = &(entry->next);
|
|
|
|
thread_mutex_unlock(&(queue->mutex));
|
2022-03-20 07:10:17 -04:00
|
|
|
thread_cond_broadcast(&(queue->cond));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void client_queue_wait(client_queue_t *queue)
|
|
|
|
{
|
|
|
|
thread_cond_wait(&(queue->cond));
|
2022-03-19 15:05:53 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static client_queue_entry_t * client_queue_shift(client_queue_t *queue, client_queue_entry_t *stop)
|
|
|
|
{
|
|
|
|
client_queue_entry_t *ret;
|
|
|
|
|
|
|
|
thread_mutex_lock(&(queue->mutex));
|
|
|
|
ret = queue->head;
|
|
|
|
if (ret) {
|
|
|
|
if (ret == stop) {
|
|
|
|
ret = NULL;
|
|
|
|
} else {
|
|
|
|
queue->head = ret->next;
|
|
|
|
if (!queue->head) {
|
|
|
|
queue->tail = &(queue->head);
|
|
|
|
}
|
|
|
|
ret->next = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
thread_mutex_unlock(&(queue->mutex));
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2022-03-20 07:10:17 -04:00
|
|
|
static bool client_queue_check_ready(client_queue_t *queue, int timeout, time_t connection_timeout)
|
2022-03-19 17:50:42 -04:00
|
|
|
{
|
|
|
|
if (!queue->head)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
#ifdef HAVE_POLL
|
|
|
|
if (true) {
|
2022-03-20 07:10:17 -04:00
|
|
|
bool had_timeout = false;
|
2022-03-19 17:50:42 -04:00
|
|
|
size_t count = 0;
|
|
|
|
size_t i;
|
|
|
|
client_queue_entry_t *cur;
|
|
|
|
|
|
|
|
thread_mutex_lock(&(queue->mutex));
|
|
|
|
for (cur = queue->head; cur; cur = cur->next) {
|
|
|
|
count++;
|
2022-03-20 07:10:17 -04:00
|
|
|
if (cur->client->con->con_time <= connection_timeout) {
|
|
|
|
cur->ready = true;
|
|
|
|
had_timeout = true;
|
|
|
|
} else {
|
|
|
|
cur->ready = false;
|
|
|
|
}
|
2022-03-19 17:50:42 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (queue->pollfds_len < count) {
|
|
|
|
free(queue->pollfds);
|
|
|
|
queue->pollfds = calloc(count, sizeof(*queue->pollfds));
|
|
|
|
if (queue->pollfds) {
|
|
|
|
queue->pollfds_len = count;
|
|
|
|
} else {
|
|
|
|
ICECAST_LOG_ERROR("Allocation of queue->pollfds failed. BAD.");
|
|
|
|
queue->pollfds_len = 0;
|
|
|
|
thread_mutex_unlock(&(queue->mutex));
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
memset(queue->pollfds, 0, sizeof(*queue->pollfds)*count);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (cur = queue->head, i = 0; cur && i < count; cur = cur->next, i++) {
|
|
|
|
queue->pollfds[i].fd = cur->client->con->sock;
|
|
|
|
queue->pollfds[i].events = POLLIN;
|
|
|
|
}
|
|
|
|
thread_mutex_unlock(&(queue->mutex));
|
|
|
|
|
2022-03-20 07:10:17 -04:00
|
|
|
if (had_timeout)
|
|
|
|
return true;
|
|
|
|
|
2022-03-19 17:50:42 -04:00
|
|
|
if (poll(queue->pollfds, count, timeout) < 1)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
thread_mutex_lock(&(queue->mutex));
|
|
|
|
for (cur = queue->head; cur; cur = cur->next) {
|
|
|
|
for (i = 0; i < count; i++) {
|
|
|
|
if (queue->pollfds[i].fd == cur->client->con->sock) {
|
|
|
|
if (queue->pollfds[i].revents) {
|
|
|
|
cur->ready = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
thread_mutex_unlock(&(queue->mutex));
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2022-03-20 07:15:09 -04:00
|
|
|
static bool client_queue_check_ready_wait(client_queue_t *queue, int timeout, time_t connection_timeout)
|
|
|
|
{
|
|
|
|
while (queue->running) {
|
|
|
|
if (client_queue_check_ready(queue, timeout, connection_timeout))
|
|
|
|
return true;
|
|
|
|
|
|
|
|
if (!queue->head)
|
|
|
|
thread_cond_wait(&(queue->cond));
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2022-03-19 17:50:42 -04:00
|
|
|
static client_queue_entry_t * client_queue_shift_ready(client_queue_t *queue, client_queue_entry_t *stop)
|
|
|
|
{
|
|
|
|
#ifdef HAVE_POLL
|
|
|
|
client_queue_entry_t *cur;
|
|
|
|
client_queue_entry_t *last = NULL;
|
|
|
|
|
|
|
|
if (!queue->head)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
thread_mutex_lock(&(queue->mutex));
|
|
|
|
for (cur = queue->head; cur && cur != stop; cur = cur->next) {
|
|
|
|
if (cur->ready) {
|
|
|
|
// use this one.
|
|
|
|
if (last == NULL) {
|
|
|
|
/* we are the head */
|
|
|
|
queue->head = cur->next;
|
|
|
|
if (!queue->head) {
|
|
|
|
queue->tail = &(queue->head);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
last->next = cur->next;
|
|
|
|
if (queue->tail == &(cur->next)) {
|
|
|
|
queue->tail = &(last->next);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
cur->next = NULL;
|
|
|
|
thread_mutex_unlock(&(queue->mutex));
|
|
|
|
return cur;
|
|
|
|
}
|
|
|
|
last = cur;
|
|
|
|
}
|
|
|
|
thread_mutex_unlock(&(queue->mutex));
|
|
|
|
return NULL;
|
|
|
|
#else
|
|
|
|
/* just return any */
|
|
|
|
return client_queue_shift(queue, stop);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2001-09-09 22:21:46 -04:00
|
|
|
void connection_initialize(void)
|
|
|
|
{
|
2015-01-25 13:57:27 -05:00
|
|
|
if (_initialized)
|
|
|
|
return;
|
2015-01-10 13:53:44 -05:00
|
|
|
|
2009-01-08 22:18:03 -05:00
|
|
|
thread_spin_create (&_connection_lock);
|
2004-01-29 11:46:54 -05:00
|
|
|
thread_mutex_create(&move_clients_mutex);
|
2003-03-14 21:10:19 -05:00
|
|
|
thread_rwlock_create(&_source_shutdown_rwlock);
|
2022-03-19 15:05:53 -04:00
|
|
|
client_queue_init(&_request_queue);
|
|
|
|
client_queue_init(&_connection_queue);
|
|
|
|
client_queue_init(&_body_queue);
|
2001-09-09 22:21:46 -04:00
|
|
|
|
2022-03-20 07:10:17 -04:00
|
|
|
client_queue_start_thread(&_request_queue, process_request_queue);
|
|
|
|
client_queue_start_thread(&_body_queue, process_request_body_queue);
|
|
|
|
|
2003-03-14 21:10:19 -05:00
|
|
|
_initialized = 1;
|
2001-09-09 22:21:46 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void connection_shutdown(void)
|
|
|
|
{
|
2015-01-25 13:57:27 -05:00
|
|
|
if (!_initialized)
|
|
|
|
return;
|
2015-01-10 13:53:44 -05:00
|
|
|
|
2016-10-20 04:24:52 -04:00
|
|
|
tls_ctx_unref(tls_ctx);
|
2015-01-05 17:06:53 -05:00
|
|
|
matchfile_release(banned_ip);
|
|
|
|
matchfile_release(allowed_ip);
|
2022-03-20 07:10:17 -04:00
|
|
|
|
2003-03-14 21:10:19 -05:00
|
|
|
thread_rwlock_destroy(&_source_shutdown_rwlock);
|
2009-01-08 22:18:03 -05:00
|
|
|
thread_spin_destroy (&_connection_lock);
|
2004-01-29 11:46:54 -05:00
|
|
|
thread_mutex_destroy(&move_clients_mutex);
|
2022-03-19 15:05:53 -04:00
|
|
|
client_queue_destroy(&_request_queue);
|
|
|
|
client_queue_destroy(&_connection_queue);
|
|
|
|
client_queue_destroy(&_body_queue);
|
2001-09-09 22:21:46 -04:00
|
|
|
|
2003-03-14 21:10:19 -05:00
|
|
|
_initialized = 0;
|
2001-09-09 22:21:46 -04:00
|
|
|
}
|
|
|
|
|
2018-06-17 06:22:17 -04:00
|
|
|
void connection_reread_config(ice_config_t *config)
|
2016-10-20 05:38:53 -04:00
|
|
|
{
|
2016-11-06 05:59:15 -05:00
|
|
|
get_tls_certificate(config);
|
2018-05-11 02:52:03 -04:00
|
|
|
listensocket_container_configure_and_setup(global.listensockets, config);
|
2016-10-20 05:38:53 -04:00
|
|
|
}
|
|
|
|
|
2018-07-06 09:55:39 -04:00
|
|
|
static connection_id_t _next_connection_id(void)
|
2001-09-09 22:21:46 -04:00
|
|
|
{
|
2018-07-06 09:55:39 -04:00
|
|
|
connection_id_t id;
|
2001-09-09 22:21:46 -04:00
|
|
|
|
2014-11-30 15:32:30 -05:00
|
|
|
thread_spin_lock(&_connection_lock);
|
2003-03-14 21:10:19 -05:00
|
|
|
id = _current_id++;
|
2014-11-30 15:32:30 -05:00
|
|
|
thread_spin_unlock(&_connection_lock);
|
2001-09-09 22:21:46 -04:00
|
|
|
|
2003-03-14 21:10:19 -05:00
|
|
|
return id;
|
2001-09-09 22:21:46 -04:00
|
|
|
}
|
|
|
|
|
2007-08-28 23:51:22 -04:00
|
|
|
|
2016-11-06 05:48:41 -05:00
|
|
|
#ifdef ICECAST_CAP_TLS
|
2016-11-06 05:59:15 -05:00
|
|
|
static void get_tls_certificate(ice_config_t *config)
|
2007-08-28 23:51:22 -04:00
|
|
|
{
|
2017-05-18 04:02:41 -04:00
|
|
|
const char *keyfile;
|
|
|
|
|
2022-03-01 03:43:47 -05:00
|
|
|
tls_ok = false;
|
2007-08-28 23:51:22 -04:00
|
|
|
|
2017-05-18 04:02:41 -04:00
|
|
|
keyfile = config->tls_context.key_file;
|
|
|
|
if (!keyfile)
|
|
|
|
keyfile = config->tls_context.cert_file;
|
|
|
|
|
2016-10-20 04:24:52 -04:00
|
|
|
tls_ctx_unref(tls_ctx);
|
2017-05-18 04:02:41 -04:00
|
|
|
tls_ctx = tls_ctx_new(config->tls_context.cert_file, keyfile, config->tls_context.cipher_list);
|
2016-10-20 04:24:52 -04:00
|
|
|
if (!tls_ctx) {
|
|
|
|
ICECAST_LOG_INFO("No TLS capability on any configured ports");
|
2007-10-21 22:29:49 -04:00
|
|
|
return;
|
2016-10-20 04:24:52 -04:00
|
|
|
}
|
|
|
|
|
2022-03-01 03:43:47 -05:00
|
|
|
tls_ok = true;
|
2007-08-28 23:51:22 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-11-06 05:59:15 -05:00
|
|
|
/* handlers for reading and writing a connection_t when there is TLS
|
2007-08-28 23:51:22 -04:00
|
|
|
* configured on the listening port
|
|
|
|
*/
|
2016-11-06 05:59:15 -05:00
|
|
|
static int connection_read_tls(connection_t *con, void *buf, size_t len)
|
2007-08-28 23:51:22 -04:00
|
|
|
{
|
2016-10-20 05:06:28 -04:00
|
|
|
ssize_t bytes = tls_read(con->tls, buf, len);
|
2007-08-28 23:51:22 -04:00
|
|
|
|
2018-11-13 03:25:01 -05:00
|
|
|
if (bytes <= 0) {
|
2016-10-20 05:06:28 -04:00
|
|
|
if (tls_want_io(con->tls) > 0)
|
2014-11-30 15:32:30 -05:00
|
|
|
return -1;
|
2007-08-28 23:51:22 -04:00
|
|
|
con->error = 1;
|
|
|
|
}
|
|
|
|
return bytes;
|
|
|
|
}
|
|
|
|
|
2016-11-06 05:59:15 -05:00
|
|
|
static int connection_send_tls(connection_t *con, const void *buf, size_t len)
|
2007-08-28 23:51:22 -04:00
|
|
|
{
|
2016-10-20 05:06:28 -04:00
|
|
|
ssize_t bytes = tls_write(con->tls, buf, len);
|
2007-08-28 23:51:22 -04:00
|
|
|
|
2015-01-25 13:57:27 -05:00
|
|
|
if (bytes < 0) {
|
2007-08-28 23:51:22 -04:00
|
|
|
con->error = 1;
|
2015-01-25 13:57:27 -05:00
|
|
|
} else {
|
2007-08-28 23:51:22 -04:00
|
|
|
con->sent_bytes += bytes;
|
2015-01-25 13:57:27 -05:00
|
|
|
}
|
2018-07-05 06:49:59 -04:00
|
|
|
|
2007-08-28 23:51:22 -04:00
|
|
|
return bytes;
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
|
2016-11-06 05:59:15 -05:00
|
|
|
/* TLS not compiled in, so at least log it */
|
|
|
|
static void get_tls_certificate(ice_config_t *config)
|
2007-08-28 23:51:22 -04:00
|
|
|
{
|
2022-03-01 03:43:47 -05:00
|
|
|
tls_ok = false;
|
2015-03-01 11:51:09 -05:00
|
|
|
ICECAST_LOG_INFO("No TLS capability. "
|
2016-11-06 05:49:47 -05:00
|
|
|
"Rebuild Icecast with OpenSSL support to enable this.");
|
2007-08-28 23:51:22 -04:00
|
|
|
}
|
2016-11-06 05:48:41 -05:00
|
|
|
#endif /* ICECAST_CAP_TLS */
|
2007-08-28 23:51:22 -04:00
|
|
|
|
|
|
|
|
|
|
|
/* handlers (default) for reading and writing a connection_t, no encrpytion
|
|
|
|
* used just straight access to the socket
|
|
|
|
*/
|
2015-01-25 13:57:27 -05:00
|
|
|
static int connection_read(connection_t *con, void *buf, size_t len)
|
2007-08-28 23:51:22 -04:00
|
|
|
{
|
2015-01-25 13:57:27 -05:00
|
|
|
int bytes = sock_read_bytes(con->sock, buf, len);
|
2007-08-28 23:51:22 -04:00
|
|
|
if (bytes == 0)
|
|
|
|
con->error = 1;
|
2015-01-25 13:57:27 -05:00
|
|
|
if (bytes == -1 && !sock_recoverable(sock_error()))
|
2007-08-28 23:51:22 -04:00
|
|
|
con->error = 1;
|
|
|
|
return bytes;
|
|
|
|
}
|
|
|
|
|
2015-01-25 13:57:27 -05:00
|
|
|
static int connection_send(connection_t *con, const void *buf, size_t len)
|
2007-08-28 23:51:22 -04:00
|
|
|
{
|
2015-01-25 13:57:27 -05:00
|
|
|
int bytes = sock_write_bytes(con->sock, buf, len);
|
|
|
|
if (bytes < 0) {
|
|
|
|
if (!sock_recoverable(sock_error()))
|
2007-08-28 23:51:22 -04:00
|
|
|
con->error = 1;
|
2015-01-25 13:57:27 -05:00
|
|
|
} else {
|
2007-08-28 23:51:22 -04:00
|
|
|
con->sent_bytes += bytes;
|
2015-01-25 13:57:27 -05:00
|
|
|
}
|
2018-07-05 06:49:59 -04:00
|
|
|
|
2007-08-28 23:51:22 -04:00
|
|
|
return bytes;
|
|
|
|
}
|
|
|
|
|
2018-04-18 01:43:46 -04:00
|
|
|
connection_t *connection_create(sock_t sock, listensocket_t *listensocket_real, listensocket_t* listensocket_effective, char *ip)
|
2005-08-11 19:29:58 -04:00
|
|
|
{
|
2003-03-14 21:10:19 -05:00
|
|
|
connection_t *con;
|
2018-04-18 01:43:46 -04:00
|
|
|
|
|
|
|
if (!matchfile_match_allow_deny(allowed_ip, banned_ip, ip))
|
|
|
|
return NULL;
|
|
|
|
|
2005-08-11 19:29:58 -04:00
|
|
|
con = (connection_t *)calloc(1, sizeof(connection_t));
|
2015-01-25 13:57:27 -05:00
|
|
|
if (con) {
|
2018-04-18 01:43:46 -04:00
|
|
|
refobject_ref(listensocket_real);
|
|
|
|
refobject_ref(listensocket_effective);
|
|
|
|
|
2015-01-25 13:57:27 -05:00
|
|
|
con->sock = sock;
|
2018-04-18 01:43:46 -04:00
|
|
|
con->listensocket_real = listensocket_real;
|
|
|
|
con->listensocket_effective = listensocket_effective;
|
2015-01-25 13:57:27 -05:00
|
|
|
con->con_time = time(NULL);
|
|
|
|
con->id = _next_connection_id();
|
|
|
|
con->ip = ip;
|
2016-10-20 07:20:25 -04:00
|
|
|
con->tlsmode = ICECAST_TLSMODE_AUTO;
|
2015-01-25 13:57:27 -05:00
|
|
|
con->read = connection_read;
|
|
|
|
con->send = connection_send;
|
2005-08-11 19:29:58 -04:00
|
|
|
}
|
2003-03-05 08:03:35 -05:00
|
|
|
|
2018-07-05 06:49:59 -04:00
|
|
|
fastevent_emit(FASTEVENT_TYPE_CONNECTION_CREATE, FASTEVENT_FLAG_MODIFICATION_ALLOWED, FASTEVENT_DATATYPE_CONNECTION, con);
|
|
|
|
|
2003-03-14 21:10:19 -05:00
|
|
|
return con;
|
2002-08-05 10:48:04 -04:00
|
|
|
}
|
|
|
|
|
2016-11-06 05:59:15 -05:00
|
|
|
/* prepare connection for interacting over a TLS connection
|
2007-08-28 23:51:22 -04:00
|
|
|
*/
|
2016-11-06 05:59:15 -05:00
|
|
|
void connection_uses_tls(connection_t *con)
|
2007-08-28 23:51:22 -04:00
|
|
|
{
|
2016-11-06 05:48:41 -05:00
|
|
|
#ifdef ICECAST_CAP_TLS
|
2016-10-20 05:06:28 -04:00
|
|
|
if (con->tls)
|
2015-02-06 05:25:40 -05:00
|
|
|
return;
|
|
|
|
|
2018-06-18 05:34:27 -04:00
|
|
|
if (con->readbufferlen) {
|
|
|
|
ICECAST_LOG_ERROR("Connection is now using TLS but has data put back. BAD. Discarding putback data.");
|
|
|
|
free(con->readbuffer);
|
|
|
|
con->readbufferlen = 0;
|
|
|
|
}
|
|
|
|
|
2016-10-20 07:20:25 -04:00
|
|
|
con->tlsmode = ICECAST_TLSMODE_RFC2818;
|
2016-11-06 05:59:15 -05:00
|
|
|
con->read = connection_read_tls;
|
|
|
|
con->send = connection_send_tls;
|
2016-10-20 05:06:28 -04:00
|
|
|
con->tls = tls_new(tls_ctx);
|
|
|
|
tls_set_incoming(con->tls);
|
|
|
|
tls_set_socket(con->tls, con->sock);
|
2007-08-28 23:51:22 -04:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2018-07-26 06:37:12 -04:00
|
|
|
ssize_t connection_send_bytes(connection_t *con, const void *buf, size_t len)
|
|
|
|
{
|
2018-07-05 06:49:59 -04:00
|
|
|
ssize_t ret = con->send(con, buf, len);
|
|
|
|
|
|
|
|
fastevent_emit(FASTEVENT_TYPE_CONNECTION_WRITE, FASTEVENT_FLAG_MODIFICATION_ALLOWED, FASTEVENT_DATATYPE_OBRD, con, buf, len, ret);
|
|
|
|
|
|
|
|
return ret;
|
2018-07-26 06:37:12 -04:00
|
|
|
}
|
|
|
|
|
2018-07-05 06:49:59 -04:00
|
|
|
static inline ssize_t connection_read_bytes_real(connection_t *con, void *buf, size_t len)
|
2015-02-10 16:18:52 -05:00
|
|
|
{
|
2018-06-18 05:34:27 -04:00
|
|
|
ssize_t done = 0;
|
|
|
|
ssize_t ret;
|
|
|
|
|
|
|
|
if (con->readbufferlen) {
|
|
|
|
ICECAST_LOG_DEBUG("On connection %p we read from putback buffer, filled with %zu bytes, requested are %zu bytes", con, con->readbufferlen, len);
|
|
|
|
if (len >= con->readbufferlen) {
|
|
|
|
memcpy(buf, con->readbuffer, con->readbufferlen);
|
|
|
|
free(con->readbuffer);
|
2018-08-02 05:08:53 -04:00
|
|
|
con->readbuffer = NULL;
|
2018-06-18 12:57:36 -04:00
|
|
|
ICECAST_LOG_DEBUG("New fill in buffer=<empty>");
|
2018-06-18 05:34:27 -04:00
|
|
|
if (len == con->readbufferlen) {
|
|
|
|
con->readbufferlen = 0;
|
|
|
|
return len;
|
|
|
|
} else {
|
|
|
|
len -= con->readbufferlen;
|
|
|
|
buf += con->readbufferlen;
|
|
|
|
done = con->readbufferlen;
|
|
|
|
con->readbufferlen = 0;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
memcpy(buf, con->readbuffer, len);
|
|
|
|
memmove(con->readbuffer, con->readbuffer+len, con->readbufferlen-len);
|
|
|
|
con->readbufferlen -= len;
|
|
|
|
return len;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = con->read(con, buf, len);
|
|
|
|
|
|
|
|
if (ret < 0) {
|
|
|
|
if (done == 0) {
|
|
|
|
return ret;
|
|
|
|
} else {
|
|
|
|
return done;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return done + ret;
|
|
|
|
}
|
|
|
|
|
2018-07-05 06:49:59 -04:00
|
|
|
ssize_t connection_read_bytes(connection_t *con, void *buf, size_t len)
|
|
|
|
{
|
|
|
|
ssize_t ret = connection_read_bytes_real(con, buf, len);
|
|
|
|
|
|
|
|
fastevent_emit(FASTEVENT_TYPE_CONNECTION_READ, FASTEVENT_FLAG_MODIFICATION_ALLOWED, FASTEVENT_DATATYPE_OBRD, con, buf, len, ret);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2018-06-18 05:34:27 -04:00
|
|
|
int connection_read_put_back(connection_t *con, const void *buf, size_t len)
|
|
|
|
{
|
|
|
|
void *n;
|
|
|
|
|
2018-07-05 06:49:59 -04:00
|
|
|
fastevent_emit(FASTEVENT_TYPE_CONNECTION_PUTBACK, FASTEVENT_FLAG_MODIFICATION_ALLOWED, FASTEVENT_DATATYPE_OBR, con, buf, len);
|
|
|
|
|
2018-06-18 05:34:27 -04:00
|
|
|
if (con->readbufferlen) {
|
|
|
|
n = realloc(con->readbuffer, con->readbufferlen + len);
|
|
|
|
if (!n)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
memcpy(n + con->readbufferlen, buf, len);
|
|
|
|
con->readbuffer = n;
|
|
|
|
con->readbufferlen += len;
|
|
|
|
|
|
|
|
ICECAST_LOG_DEBUG("On connection %p %zu bytes have been put back.", con, len);
|
|
|
|
return 0;
|
|
|
|
} else {
|
|
|
|
n = malloc(len);
|
|
|
|
if (!n)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
memcpy(n, buf, len);
|
|
|
|
con->readbuffer = n;
|
|
|
|
con->readbufferlen = len;
|
|
|
|
ICECAST_LOG_DEBUG("On connection %p %zu bytes have been put back.", con, len);
|
|
|
|
return 0;
|
|
|
|
}
|
2015-02-10 16:18:52 -05:00
|
|
|
}
|
|
|
|
|
2005-08-11 19:29:58 -04:00
|
|
|
/* run along queue checking for any data that has come in or a timeout */
|
2022-03-20 07:10:17 -04:00
|
|
|
static bool process_request_queue_one (client_queue_entry_t *node, time_t timeout)
|
2005-08-11 19:29:58 -04:00
|
|
|
{
|
2022-03-19 15:05:53 -04:00
|
|
|
client_t *client = node->client;
|
|
|
|
int len = PER_CLIENT_REFBUF_SIZE - 1 - node->offset;
|
|
|
|
char *buf = client->refbuf->data + node->offset;
|
2001-09-09 22:21:46 -04:00
|
|
|
|
2022-03-19 15:05:53 -04:00
|
|
|
ICECAST_LOG_DDEBUG("Checking on client %p", client);
|
2019-09-17 13:32:00 -04:00
|
|
|
|
2022-03-19 15:05:53 -04:00
|
|
|
if (client->con->tlsmode == ICECAST_TLSMODE_AUTO || client->con->tlsmode == ICECAST_TLSMODE_AUTO_NO_PLAIN) {
|
|
|
|
char peak;
|
|
|
|
if (recv(client->con->sock, &peak, 1, MSG_PEEK) == 1) {
|
|
|
|
if (peak == 0x16) { /* TLS Record Protocol Content type 0x16 == Handshake */
|
|
|
|
connection_uses_tls(client->con);
|
2016-10-20 07:20:25 -04:00
|
|
|
}
|
|
|
|
}
|
2022-03-19 15:05:53 -04:00
|
|
|
}
|
2016-10-20 07:20:25 -04:00
|
|
|
|
2022-03-19 15:05:53 -04:00
|
|
|
if (len > 0) {
|
2022-03-20 07:10:17 -04:00
|
|
|
if (client->con->con_time <= timeout) {
|
2022-03-19 15:05:53 -04:00
|
|
|
len = 0;
|
|
|
|
} else {
|
|
|
|
len = client_read_bytes(client, buf, len);
|
2005-08-11 19:29:58 -04:00
|
|
|
}
|
2022-03-19 15:05:53 -04:00
|
|
|
}
|
2001-09-09 22:21:46 -04:00
|
|
|
|
2022-03-19 15:05:53 -04:00
|
|
|
if (len > 0 || node->shoutcast > 1) {
|
|
|
|
ssize_t stream_offset = -1;
|
|
|
|
int pass_it = 1;
|
|
|
|
char *ptr;
|
|
|
|
|
|
|
|
if (len < 0 && node->shoutcast > 1)
|
|
|
|
len = 0;
|
|
|
|
|
|
|
|
/* handle \n, \r\n and nsvcap which for some strange reason has
|
|
|
|
* EOL as \r\r\n */
|
|
|
|
node->offset += len;
|
|
|
|
client->refbuf->data[node->offset] = '\000';
|
|
|
|
do {
|
|
|
|
if (node->shoutcast == 1) {
|
|
|
|
/* password line */
|
|
|
|
if (strstr (client->refbuf->data, "\r\r\n") != NULL)
|
2005-10-01 10:08:36 -04:00
|
|
|
break;
|
2022-03-19 15:05:53 -04:00
|
|
|
if (strstr (client->refbuf->data, "\r\n") != NULL)
|
2005-08-11 19:29:58 -04:00
|
|
|
break;
|
2022-03-19 15:05:53 -04:00
|
|
|
if (strstr (client->refbuf->data, "\n") != NULL)
|
2005-08-11 19:29:58 -04:00
|
|
|
break;
|
2022-03-19 15:05:53 -04:00
|
|
|
}
|
|
|
|
/* stream_offset refers to the start of any data sent after the
|
|
|
|
* http style headers, we don't want to lose those */
|
|
|
|
ptr = strstr(client->refbuf->data, "\r\r\n\r\r\n");
|
|
|
|
if (ptr) {
|
|
|
|
stream_offset = (ptr+6) - client->refbuf->data;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
ptr = strstr(client->refbuf->data, "\r\n\r\n");
|
|
|
|
if (ptr) {
|
|
|
|
stream_offset = (ptr+4) - client->refbuf->data;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
ptr = strstr(client->refbuf->data, "\n\n");
|
|
|
|
if (ptr) {
|
|
|
|
stream_offset = (ptr+2) - client->refbuf->data;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
pass_it = 0;
|
|
|
|
} while (0);
|
2001-09-09 22:21:46 -04:00
|
|
|
|
2022-03-19 15:05:53 -04:00
|
|
|
ICECAST_LOG_DDEBUG("pass_it=%i, len=%i", pass_it, (int)len);
|
|
|
|
ICECAST_LOG_DDEBUG("Client %p has buffer: %H", client, client->refbuf->data);
|
2019-09-17 13:32:00 -04:00
|
|
|
|
2022-03-19 15:05:53 -04:00
|
|
|
if (pass_it) {
|
|
|
|
if (stream_offset != -1) {
|
|
|
|
connection_read_put_back(client->con, client->refbuf->data + stream_offset, node->offset - stream_offset);
|
|
|
|
node->offset = stream_offset;
|
2005-08-11 19:29:58 -04:00
|
|
|
}
|
2022-03-19 15:05:53 -04:00
|
|
|
client_queue_add(&_connection_queue, node);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (len == 0 || client->con->error) {
|
|
|
|
client_destroy(client);
|
2022-03-19 15:15:34 -04:00
|
|
|
free_client_node(node);
|
2022-03-19 15:05:53 -04:00
|
|
|
return true;
|
2005-08-11 19:29:58 -04:00
|
|
|
}
|
2003-03-14 21:10:19 -05:00
|
|
|
}
|
2022-03-19 15:05:53 -04:00
|
|
|
|
|
|
|
return false;
|
2001-09-09 22:21:46 -04:00
|
|
|
}
|
|
|
|
|
2022-03-20 07:10:17 -04:00
|
|
|
static void * process_request_queue (client_queue_t *queue)
|
2018-06-18 12:57:36 -04:00
|
|
|
{
|
2022-03-20 07:10:17 -04:00
|
|
|
while (client_queue_running(queue)) {
|
|
|
|
client_queue_entry_t *stop = NULL;
|
|
|
|
client_queue_entry_t *node;
|
|
|
|
ice_config_t *config;
|
|
|
|
time_t timeout;
|
2018-06-18 12:57:36 -04:00
|
|
|
|
2022-03-20 07:10:17 -04:00
|
|
|
config = config_get_config();
|
|
|
|
timeout = time(NULL) - config->header_timeout;
|
|
|
|
config_release_config();
|
2022-03-19 15:05:53 -04:00
|
|
|
|
2022-03-20 07:15:09 -04:00
|
|
|
client_queue_check_ready_wait(queue, QUEUE_READY_TIMEOUT, timeout);
|
2022-03-19 17:50:42 -04:00
|
|
|
|
2022-03-20 07:10:17 -04:00
|
|
|
while ((node = client_queue_shift_ready(queue, stop))) {
|
|
|
|
if (!process_request_queue_one(node, timeout)) {
|
|
|
|
client_queue_add(queue, node);
|
|
|
|
if (!stop)
|
|
|
|
stop = node;
|
|
|
|
}
|
2022-03-19 15:05:53 -04:00
|
|
|
}
|
2022-03-20 07:10:17 -04:00
|
|
|
|
|
|
|
_handle_connection();
|
2022-03-19 15:05:53 -04:00
|
|
|
}
|
|
|
|
|
2022-03-20 07:10:17 -04:00
|
|
|
return NULL;
|
2018-06-18 12:57:36 -04:00
|
|
|
}
|
|
|
|
|
2022-03-19 13:38:12 -04:00
|
|
|
static client_slurp_result_t process_request_body_queue_one(client_queue_entry_t *node, time_t timeout, size_t body_size_limit)
|
2018-06-19 04:08:39 -04:00
|
|
|
{
|
|
|
|
client_t *client = node->client;
|
|
|
|
client_slurp_result_t res;
|
|
|
|
|
|
|
|
if (client->parser->req_type == httpp_req_post) {
|
|
|
|
if (node->bodybuffer == NULL && client->request_body_read == 0) {
|
|
|
|
if (client->request_body_length < 0) {
|
|
|
|
node->bodybufferlen = body_size_limit;
|
|
|
|
node->bodybuffer = malloc(node->bodybufferlen);
|
|
|
|
} else if (client->request_body_length <= (ssize_t)body_size_limit) {
|
|
|
|
node->bodybufferlen = client->request_body_length;
|
|
|
|
node->bodybuffer = malloc(node->bodybufferlen);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (node->bodybuffer) {
|
|
|
|
res = client_body_slurp(client, node->bodybuffer, &(node->bodybufferlen));
|
|
|
|
if (res == CLIENT_SLURP_SUCCESS) {
|
|
|
|
httpp_parse_postdata(client->parser, node->bodybuffer, node->bodybufferlen);
|
|
|
|
free(node->bodybuffer);
|
|
|
|
node->bodybuffer = NULL;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
res = client_body_skip(client);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (res != CLIENT_SLURP_SUCCESS) {
|
|
|
|
if (client->con->con_time <= timeout || client->request_body_read >= body_size_limit) {
|
|
|
|
return CLIENT_SLURP_ERROR;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
2018-06-18 12:57:36 -04:00
|
|
|
|
|
|
|
/* This queue reads data from the body of clients. */
|
2022-03-20 07:10:17 -04:00
|
|
|
static void * process_request_body_queue (client_queue_t *queue)
|
2018-06-18 12:57:36 -04:00
|
|
|
{
|
2022-03-20 07:10:17 -04:00
|
|
|
while (client_queue_running(queue)) {
|
|
|
|
client_queue_entry_t *stop = NULL;
|
|
|
|
client_queue_entry_t *node;
|
|
|
|
ice_config_t *config;
|
|
|
|
time_t timeout;
|
|
|
|
size_t body_size_limit;
|
2018-06-18 12:57:36 -04:00
|
|
|
|
2022-03-20 07:10:17 -04:00
|
|
|
ICECAST_LOG_DDEBUG("Processing body queue.");
|
2018-06-18 12:57:36 -04:00
|
|
|
|
2022-03-20 07:10:17 -04:00
|
|
|
config = config_get_config();
|
|
|
|
timeout = time(NULL) - config->body_timeout;
|
|
|
|
body_size_limit = config->body_size_limit;
|
|
|
|
config_release_config();
|
2018-06-18 13:34:18 -04:00
|
|
|
|
2022-03-20 07:15:09 -04:00
|
|
|
client_queue_check_ready_wait(queue, QUEUE_READY_TIMEOUT, timeout);
|
2018-06-18 12:57:36 -04:00
|
|
|
|
2022-03-20 07:10:17 -04:00
|
|
|
while ((node = client_queue_shift(queue, stop))) {
|
|
|
|
client_t *client = node->client;
|
|
|
|
client_slurp_result_t res;
|
2018-06-18 17:08:17 -04:00
|
|
|
|
2022-03-20 07:10:17 -04:00
|
|
|
node->tried_body = 1;
|
2018-06-18 12:57:36 -04:00
|
|
|
|
2022-03-20 07:10:17 -04:00
|
|
|
ICECAST_LOG_DEBUG("Got client %p in body queue.", client);
|
2018-06-18 17:40:47 -04:00
|
|
|
|
2022-03-20 07:10:17 -04:00
|
|
|
res = process_request_body_queue_one(node, timeout, body_size_limit);
|
2018-06-18 12:57:36 -04:00
|
|
|
|
2022-03-20 07:10:17 -04:00
|
|
|
if (res == CLIENT_SLURP_NEEDS_MORE_DATA) {
|
|
|
|
client_queue_add(queue, node);
|
|
|
|
if (!stop)
|
|
|
|
stop = node;
|
|
|
|
} else {
|
|
|
|
ICECAST_LOG_DEBUG("Putting client %p back in connection queue.", client);
|
|
|
|
|
|
|
|
client_queue_add(&_connection_queue, node);
|
|
|
|
continue;
|
|
|
|
}
|
2018-06-18 12:57:36 -04:00
|
|
|
}
|
|
|
|
}
|
2022-03-20 07:10:17 -04:00
|
|
|
|
|
|
|
return NULL;
|
2018-06-18 12:57:36 -04:00
|
|
|
}
|
2003-03-14 21:10:19 -05:00
|
|
|
|
2022-03-19 13:38:12 -04:00
|
|
|
static client_queue_entry_t *create_client_node(client_t *client)
|
2015-02-01 16:01:01 -05:00
|
|
|
{
|
2022-03-19 13:38:12 -04:00
|
|
|
client_queue_entry_t *node = calloc (1, sizeof (client_queue_entry_t));
|
2018-04-18 01:43:46 -04:00
|
|
|
const listener_t *listener;
|
2015-02-01 16:01:01 -05:00
|
|
|
|
|
|
|
if (!node)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
node->client = client;
|
|
|
|
|
2018-04-18 01:43:46 -04:00
|
|
|
listener = listensocket_get_listener(client->con->listensocket_effective);
|
2015-02-01 16:01:01 -05:00
|
|
|
|
|
|
|
if (listener) {
|
|
|
|
if (listener->shoutcast_compat)
|
|
|
|
node->shoutcast = 1;
|
2016-11-06 11:02:11 -05:00
|
|
|
client->con->tlsmode = listener->tls;
|
|
|
|
if (listener->tls == ICECAST_TLSMODE_RFC2818 && tls_ok)
|
2016-11-06 05:59:15 -05:00
|
|
|
connection_uses_tls(client->con);
|
2015-02-01 16:01:01 -05:00
|
|
|
if (listener->shoutcast_mount)
|
|
|
|
node->shoutcast_mount = strdup(listener->shoutcast_mount);
|
|
|
|
}
|
|
|
|
|
2018-05-11 04:08:38 -04:00
|
|
|
listensocket_release_listener(client->con->listensocket_effective);
|
|
|
|
|
2015-02-01 16:01:01 -05:00
|
|
|
return node;
|
|
|
|
}
|
2005-08-11 19:29:58 -04:00
|
|
|
|
2022-03-19 15:15:34 -04:00
|
|
|
static void free_client_node(client_queue_entry_t *node)
|
|
|
|
{
|
|
|
|
free(node->shoutcast_mount);
|
|
|
|
free(node->bodybuffer);
|
|
|
|
free(node);
|
|
|
|
}
|
|
|
|
|
2015-02-01 18:04:54 -05:00
|
|
|
void connection_queue(connection_t *con)
|
|
|
|
{
|
2022-03-19 13:38:12 -04:00
|
|
|
client_queue_entry_t *node;
|
2015-02-01 18:04:54 -05:00
|
|
|
client_t *client = NULL;
|
|
|
|
|
|
|
|
global_lock();
|
|
|
|
if (client_create(&client, con, NULL) < 0) {
|
|
|
|
global_unlock();
|
2018-04-28 09:49:36 -04:00
|
|
|
client_send_error_by_id(client, ICECAST_ERROR_GEN_CLIENT_LIMIT);
|
2015-02-01 18:04:54 -05:00
|
|
|
/* don't be too eager as this is an imposed hard limit */
|
|
|
|
thread_sleep(400000);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* setup client for reading incoming http */
|
|
|
|
client->refbuf->data[PER_CLIENT_REFBUF_SIZE-1] = '\000';
|
|
|
|
|
|
|
|
if (sock_set_blocking(client->con->sock, 0) || sock_set_nodelay(client->con->sock)) {
|
|
|
|
global_unlock();
|
2015-03-01 11:51:09 -05:00
|
|
|
ICECAST_LOG_WARN("Failed to set tcp options on client connection, dropping");
|
2015-02-01 18:04:54 -05:00
|
|
|
client_destroy(client);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
node = create_client_node(client);
|
|
|
|
global_unlock();
|
|
|
|
|
|
|
|
if (node == NULL) {
|
|
|
|
client_destroy(client);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-03-19 15:05:53 -04:00
|
|
|
client_queue_add(&_request_queue, node);
|
2015-02-01 18:04:54 -05:00
|
|
|
stats_event_inc(NULL, "connections");
|
|
|
|
}
|
|
|
|
|
2015-01-25 13:57:27 -05:00
|
|
|
void connection_accept_loop(void)
|
2001-09-09 22:21:46 -04:00
|
|
|
{
|
2007-10-21 22:29:49 -04:00
|
|
|
ice_config_t *config;
|
|
|
|
|
2015-01-25 13:57:27 -05:00
|
|
|
config = config_get_config();
|
2016-11-06 05:59:15 -05:00
|
|
|
get_tls_certificate(config);
|
2015-01-25 13:57:27 -05:00
|
|
|
config_release_config();
|
2001-09-09 22:21:46 -04:00
|
|
|
|
2015-01-25 13:57:27 -05:00
|
|
|
while (global.running == ICECAST_RUNNING) {
|
2022-03-20 09:15:31 -04:00
|
|
|
connection_t *con = listensocket_container_accept(global.listensockets, 800);
|
2005-08-11 19:29:58 -04:00
|
|
|
|
2015-01-25 13:57:27 -05:00
|
|
|
if (con) {
|
2015-02-01 18:04:54 -05:00
|
|
|
connection_queue(con);
|
2003-03-14 21:10:19 -05:00
|
|
|
}
|
|
|
|
}
|
2001-09-09 22:21:46 -04:00
|
|
|
|
2002-08-05 10:48:04 -04:00
|
|
|
/* Give all the other threads notification to shut down */
|
|
|
|
|
2003-03-14 21:10:19 -05:00
|
|
|
/* wait for all the sources to shutdown */
|
|
|
|
thread_rwlock_wlock(&_source_shutdown_rwlock);
|
|
|
|
thread_rwlock_unlock(&_source_shutdown_rwlock);
|
2001-09-09 22:21:46 -04:00
|
|
|
}
|
|
|
|
|
2004-02-19 11:32:26 -05:00
|
|
|
|
|
|
|
/* Called when activating a source. Verifies that the source count is not
|
|
|
|
* exceeded and applies any initial parameters.
|
2003-02-17 06:56:12 -05:00
|
|
|
*/
|
2015-01-25 13:57:27 -05:00
|
|
|
int connection_complete_source(source_t *source, int response)
|
2004-02-19 11:32:26 -05:00
|
|
|
{
|
2009-01-11 11:46:08 -05:00
|
|
|
ice_config_t *config;
|
2004-02-19 11:32:26 -05:00
|
|
|
|
2015-01-25 13:57:27 -05:00
|
|
|
global_lock();
|
2014-10-31 04:46:58 -04:00
|
|
|
ICECAST_LOG_DEBUG("sources count is %d", global.sources);
|
2004-02-19 11:32:26 -05:00
|
|
|
|
2009-01-11 11:46:08 -05:00
|
|
|
config = config_get_config();
|
2015-01-25 13:57:27 -05:00
|
|
|
if (global.sources < config->source_limit) {
|
2007-08-16 18:49:13 -04:00
|
|
|
const char *contenttype;
|
2005-05-30 10:50:57 -04:00
|
|
|
mount_proxy *mountinfo;
|
2004-02-19 11:32:26 -05:00
|
|
|
format_type_t format_type;
|
|
|
|
|
|
|
|
/* setup format handler */
|
|
|
|
contenttype = httpp_getvar (source->parser, "content-type");
|
2015-01-25 13:57:27 -05:00
|
|
|
if (contenttype != NULL) {
|
|
|
|
format_type = format_get_type(contenttype);
|
2004-02-19 11:32:26 -05:00
|
|
|
|
2015-01-25 13:57:27 -05:00
|
|
|
if (format_type == FORMAT_ERROR) {
|
2004-02-19 11:32:26 -05:00
|
|
|
config_release_config();
|
2009-01-11 11:46:08 -05:00
|
|
|
global_unlock();
|
2014-11-08 11:23:26 -05:00
|
|
|
if (response) {
|
2018-04-28 09:49:36 -04:00
|
|
|
client_send_error_by_id(source->client, ICECAST_ERROR_CON_CONTENT_TYPE_NOSYS);
|
2005-08-24 20:07:17 -04:00
|
|
|
source->client = NULL;
|
|
|
|
}
|
2014-10-31 04:46:58 -04:00
|
|
|
ICECAST_LOG_WARN("Content-type \"%s\" not supported, dropping source", contenttype);
|
2004-02-19 11:32:26 -05:00
|
|
|
return -1;
|
|
|
|
}
|
2014-11-08 11:23:26 -05:00
|
|
|
} else if (source->parser->req_type == httpp_req_put) {
|
|
|
|
config_release_config();
|
|
|
|
global_unlock();
|
|
|
|
if (response) {
|
2018-04-28 09:49:36 -04:00
|
|
|
client_send_error_by_id(source->client, ICECAST_ERROR_CON_NO_CONTENT_TYPE_GIVEN);
|
2014-11-08 11:23:26 -05:00
|
|
|
source->client = NULL;
|
|
|
|
}
|
|
|
|
ICECAST_LOG_ERROR("Content-type not given in PUT request, dropping source");
|
|
|
|
return -1;
|
|
|
|
} else {
|
|
|
|
ICECAST_LOG_ERROR("No content-type header, falling back to backwards compatibility mode "
|
|
|
|
"for icecast 1.x relays. Assuming content is mp3. This behaviour is deprecated "
|
|
|
|
"and the source client will NOT work with future Icecast versions!");
|
2004-11-18 18:49:59 -05:00
|
|
|
format_type = FORMAT_TYPE_GENERIC;
|
2004-02-19 11:32:26 -05:00
|
|
|
}
|
|
|
|
|
2015-01-25 13:57:27 -05:00
|
|
|
if (format_get_plugin (format_type, source) < 0) {
|
2004-02-19 11:32:26 -05:00
|
|
|
global_unlock();
|
|
|
|
config_release_config();
|
2015-01-25 13:57:27 -05:00
|
|
|
if (response) {
|
2018-04-28 09:49:36 -04:00
|
|
|
client_send_error_by_id(source->client, ICECAST_ERROR_CON_INTERNAL_FORMAT_ALLOC_ERROR);
|
2005-08-24 20:07:17 -04:00
|
|
|
source->client = NULL;
|
|
|
|
}
|
2014-10-31 04:46:58 -04:00
|
|
|
ICECAST_LOG_WARN("plugin format failed for \"%s\"", source->mount);
|
2004-02-19 11:32:26 -05:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2005-08-11 19:29:58 -04:00
|
|
|
global.sources++;
|
2015-01-25 13:57:27 -05:00
|
|
|
stats_event_args(NULL, "sources", "%d", global.sources);
|
2005-08-11 19:29:58 -04:00
|
|
|
global_unlock();
|
2004-02-19 11:32:26 -05:00
|
|
|
|
2005-05-30 10:50:57 -04:00
|
|
|
source->running = 1;
|
2015-01-25 13:57:27 -05:00
|
|
|
mountinfo = config_find_mount(config, source->mount, MOUNT_TYPE_NORMAL);
|
|
|
|
source_update_settings(config, source, mountinfo);
|
2004-02-19 11:32:26 -05:00
|
|
|
config_release_config();
|
2007-08-11 13:44:45 -04:00
|
|
|
slave_rebuild_mounts();
|
2004-02-19 11:32:26 -05:00
|
|
|
|
|
|
|
source->shutdown_rwlock = &_source_shutdown_rwlock;
|
2014-10-31 04:46:58 -04:00
|
|
|
ICECAST_LOG_DEBUG("source is ready to start");
|
2004-02-19 11:32:26 -05:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2014-10-31 04:46:58 -04:00
|
|
|
ICECAST_LOG_WARN("Request to add source when maximum source limit "
|
2015-01-25 13:57:27 -05:00
|
|
|
"reached %d", global.sources);
|
2004-02-19 11:32:26 -05:00
|
|
|
|
|
|
|
global_unlock();
|
|
|
|
config_release_config();
|
|
|
|
|
2015-01-25 13:57:27 -05:00
|
|
|
if (response) {
|
2018-04-28 09:49:36 -04:00
|
|
|
client_send_error_by_id(source->client, ICECAST_ERROR_CON_SOURCE_CLIENT_LIMIT);
|
2005-08-24 20:07:17 -04:00
|
|
|
source->client = NULL;
|
|
|
|
}
|
2004-02-19 11:32:26 -05:00
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2022-03-19 13:38:12 -04:00
|
|
|
static void _handle_shoutcast_compatible(client_queue_entry_t *node)
|
2005-08-11 19:29:58 -04:00
|
|
|
{
|
2004-11-11 10:47:33 -05:00
|
|
|
char *http_compliant;
|
|
|
|
int http_compliant_len = 0;
|
|
|
|
http_parser_t *parser;
|
Wow. Mega patch!
This patch *replaces* the authentication system completly.
What is new:
- <authentication> in mount section is now a container object.
- <authentication> in root and mount section may hold any number of <role>-Tags.
- <role> tags:
Those tags define a 'role' and it's ACL rules.
A role is a instance of an authentication module (see below).
<role> takes the following options. All but type are optional.
- authentication related:
- type: Type of the authentication module (values: anonymous, static, legacy-password, url or htpasswd;
symbolic constants in auth.h)
- name: Name for the role. For later matching. (values: any string; default: (none))
- method: This rule is only active on the given list of HTTP methods.
(list of enum values: methods as recognized by httpp/ (e.g: get,post); default: *)
- ACL related:
- allow-method: Allowed HTTP methods.
(list of enum values: methods as recognized by httpp/ (e.g: get,post); default: get)
- deny-method: Rejected HTTP methods.
(list of enum values: methods as recognized by httpp/ (e.g: get,post); default: *)
- allow-admin: Allowed admin commands. (list of enum values: admin command; default: buildm3u)
- deny-admin: Rejected admin commands. (list of enum values: admin command; default: *)
- allow-web: Allowed web pages. (values: empty or *; default: *)
- deny-web: Rejected web pages. (values: empty or *; default: (empty))
- connections-per-user: maximum number of simultaneous connections per role and username.
This is only active on active sources. (values: unlimited or number of connections; default: unlimited)
- connection-duration: maximum time of a connection. This is only active on active sources.
(values: unlimited or number of secounds; default: unlimited)
<role> takes <option> child tags. <option> tags contain a name and a value option.
Meaning of <option> tags is up to the authentication module.
- <role>s are considered to build a stack. If a role returns with AUTH_NOMATCH the next one will be tried.
- <role>s are tested in this order: mount specific, default mount specific, global, internal fallback.
Internal fallback is set to allow web/ access via GET, POST and HEAD (only GET supported by this time)
and rejects all other requests.
- New authentication module: anonymous
This module matches all requests. No options taken.
- New authentication module: static
This module matches with a static username and password.
It takes two <option>s. One with name="username" and one with name="password" to set username and password.
This replaces old style <*-username> and <*-password> tags.
- New authentication module: legacy-password
This module matches with a statich password.
It takes one <option> with name="password" to set password.
This replaces old ICE and ICY (shoutcast compat mode) authentication.
- Parsing <authentication> in <mount> with a type set in a special way to allow 100% backward compatibility.
- Parsing of <source-password>, <admin-password>, <admin-user>, <relay-password> and <relay-user> in global
<authentication> for 100% backward compatibility.
- <alias> is now proccessed very early. This enables them to be used for all kinds of requests.
To Do List & What does not yet work:
- type="url" auth: mount_add and mount_remove.
This should be replaced by an unique feature I would call '<event>'.
- Admin commands manageauth and manageauth.xsl are disabled as they need more review:
This code needs to be ported to support multiple <role>s per <mount>.
- url authentication module can not yet return AUTH_NOMATCH.
This needs to be reviewed and discussed on how to handle this case best way.
- Default config files needs to be updated to reflect the changes.
As this is quite some political act it should be done in dicussion with the whole team
and permission of the release manager.
- Docs need to be updated to reflect the changes.
How does it work:
Code has been changed so that authentification is done early for all clients.
This allows accessing the ACL data (client->acl) from nearly everywhere in the code.
After accept() and initial client setup the request is parsed. In the next step
all <alias>es are resolved. After this the client is passed for authentication.
After authentication it is passed to the corresponding subsystem depending on kind of request.
All authentication instances have a thread running for doing the authentication.
This thread works on a queue of clients.
Hints for testers:
- Test with default config.
- Test with diffrent authentication modules in <mount>.
- Test shoutcast compatibility mode.
- Test with new style <authentication> and any amount of <role> (zero to quite some).
- Test <alias> lookup on all kinds of objects.
- Test source level credential login into the admin interface.
- Test shoucast style meta data updates.
- Test playlist generation.
Thank you for reading this long commit message. Have fun reading the full patch!
svn path=/icecast/trunk/icecast/; revision=19358
2014-11-28 18:46:08 -05:00
|
|
|
const char *shoutcast_mount;
|
2005-08-11 19:29:58 -04:00
|
|
|
client_t *client = node->client;
|
Wow. Mega patch!
This patch *replaces* the authentication system completly.
What is new:
- <authentication> in mount section is now a container object.
- <authentication> in root and mount section may hold any number of <role>-Tags.
- <role> tags:
Those tags define a 'role' and it's ACL rules.
A role is a instance of an authentication module (see below).
<role> takes the following options. All but type are optional.
- authentication related:
- type: Type of the authentication module (values: anonymous, static, legacy-password, url or htpasswd;
symbolic constants in auth.h)
- name: Name for the role. For later matching. (values: any string; default: (none))
- method: This rule is only active on the given list of HTTP methods.
(list of enum values: methods as recognized by httpp/ (e.g: get,post); default: *)
- ACL related:
- allow-method: Allowed HTTP methods.
(list of enum values: methods as recognized by httpp/ (e.g: get,post); default: get)
- deny-method: Rejected HTTP methods.
(list of enum values: methods as recognized by httpp/ (e.g: get,post); default: *)
- allow-admin: Allowed admin commands. (list of enum values: admin command; default: buildm3u)
- deny-admin: Rejected admin commands. (list of enum values: admin command; default: *)
- allow-web: Allowed web pages. (values: empty or *; default: *)
- deny-web: Rejected web pages. (values: empty or *; default: (empty))
- connections-per-user: maximum number of simultaneous connections per role and username.
This is only active on active sources. (values: unlimited or number of connections; default: unlimited)
- connection-duration: maximum time of a connection. This is only active on active sources.
(values: unlimited or number of secounds; default: unlimited)
<role> takes <option> child tags. <option> tags contain a name and a value option.
Meaning of <option> tags is up to the authentication module.
- <role>s are considered to build a stack. If a role returns with AUTH_NOMATCH the next one will be tried.
- <role>s are tested in this order: mount specific, default mount specific, global, internal fallback.
Internal fallback is set to allow web/ access via GET, POST and HEAD (only GET supported by this time)
and rejects all other requests.
- New authentication module: anonymous
This module matches all requests. No options taken.
- New authentication module: static
This module matches with a static username and password.
It takes two <option>s. One with name="username" and one with name="password" to set username and password.
This replaces old style <*-username> and <*-password> tags.
- New authentication module: legacy-password
This module matches with a statich password.
It takes one <option> with name="password" to set password.
This replaces old ICE and ICY (shoutcast compat mode) authentication.
- Parsing <authentication> in <mount> with a type set in a special way to allow 100% backward compatibility.
- Parsing of <source-password>, <admin-password>, <admin-user>, <relay-password> and <relay-user> in global
<authentication> for 100% backward compatibility.
- <alias> is now proccessed very early. This enables them to be used for all kinds of requests.
To Do List & What does not yet work:
- type="url" auth: mount_add and mount_remove.
This should be replaced by an unique feature I would call '<event>'.
- Admin commands manageauth and manageauth.xsl are disabled as they need more review:
This code needs to be ported to support multiple <role>s per <mount>.
- url authentication module can not yet return AUTH_NOMATCH.
This needs to be reviewed and discussed on how to handle this case best way.
- Default config files needs to be updated to reflect the changes.
As this is quite some political act it should be done in dicussion with the whole team
and permission of the release manager.
- Docs need to be updated to reflect the changes.
How does it work:
Code has been changed so that authentification is done early for all clients.
This allows accessing the ACL data (client->acl) from nearly everywhere in the code.
After accept() and initial client setup the request is parsed. In the next step
all <alias>es are resolved. After this the client is passed for authentication.
After authentication it is passed to the corresponding subsystem depending on kind of request.
All authentication instances have a thread running for doing the authentication.
This thread works on a queue of clients.
Hints for testers:
- Test with default config.
- Test with diffrent authentication modules in <mount>.
- Test shoutcast compatibility mode.
- Test with new style <authentication> and any amount of <role> (zero to quite some).
- Test <alias> lookup on all kinds of objects.
- Test source level credential login into the admin interface.
- Test shoucast style meta data updates.
- Test playlist generation.
Thank you for reading this long commit message. Have fun reading the full patch!
svn path=/icecast/trunk/icecast/; revision=19358
2014-11-28 18:46:08 -05:00
|
|
|
ice_config_t *config;
|
2007-10-24 22:25:49 -04:00
|
|
|
|
2019-09-17 13:32:00 -04:00
|
|
|
ICECAST_LOG_DDEBUG("Client %p is a shoutcast client of stage %i", client, (int)node->shoutcast);
|
|
|
|
|
2005-08-11 19:29:58 -04:00
|
|
|
if (node->shoutcast == 1)
|
|
|
|
{
|
Wow. Mega patch!
This patch *replaces* the authentication system completly.
What is new:
- <authentication> in mount section is now a container object.
- <authentication> in root and mount section may hold any number of <role>-Tags.
- <role> tags:
Those tags define a 'role' and it's ACL rules.
A role is a instance of an authentication module (see below).
<role> takes the following options. All but type are optional.
- authentication related:
- type: Type of the authentication module (values: anonymous, static, legacy-password, url or htpasswd;
symbolic constants in auth.h)
- name: Name for the role. For later matching. (values: any string; default: (none))
- method: This rule is only active on the given list of HTTP methods.
(list of enum values: methods as recognized by httpp/ (e.g: get,post); default: *)
- ACL related:
- allow-method: Allowed HTTP methods.
(list of enum values: methods as recognized by httpp/ (e.g: get,post); default: get)
- deny-method: Rejected HTTP methods.
(list of enum values: methods as recognized by httpp/ (e.g: get,post); default: *)
- allow-admin: Allowed admin commands. (list of enum values: admin command; default: buildm3u)
- deny-admin: Rejected admin commands. (list of enum values: admin command; default: *)
- allow-web: Allowed web pages. (values: empty or *; default: *)
- deny-web: Rejected web pages. (values: empty or *; default: (empty))
- connections-per-user: maximum number of simultaneous connections per role and username.
This is only active on active sources. (values: unlimited or number of connections; default: unlimited)
- connection-duration: maximum time of a connection. This is only active on active sources.
(values: unlimited or number of secounds; default: unlimited)
<role> takes <option> child tags. <option> tags contain a name and a value option.
Meaning of <option> tags is up to the authentication module.
- <role>s are considered to build a stack. If a role returns with AUTH_NOMATCH the next one will be tried.
- <role>s are tested in this order: mount specific, default mount specific, global, internal fallback.
Internal fallback is set to allow web/ access via GET, POST and HEAD (only GET supported by this time)
and rejects all other requests.
- New authentication module: anonymous
This module matches all requests. No options taken.
- New authentication module: static
This module matches with a static username and password.
It takes two <option>s. One with name="username" and one with name="password" to set username and password.
This replaces old style <*-username> and <*-password> tags.
- New authentication module: legacy-password
This module matches with a statich password.
It takes one <option> with name="password" to set password.
This replaces old ICE and ICY (shoutcast compat mode) authentication.
- Parsing <authentication> in <mount> with a type set in a special way to allow 100% backward compatibility.
- Parsing of <source-password>, <admin-password>, <admin-user>, <relay-password> and <relay-user> in global
<authentication> for 100% backward compatibility.
- <alias> is now proccessed very early. This enables them to be used for all kinds of requests.
To Do List & What does not yet work:
- type="url" auth: mount_add and mount_remove.
This should be replaced by an unique feature I would call '<event>'.
- Admin commands manageauth and manageauth.xsl are disabled as they need more review:
This code needs to be ported to support multiple <role>s per <mount>.
- url authentication module can not yet return AUTH_NOMATCH.
This needs to be reviewed and discussed on how to handle this case best way.
- Default config files needs to be updated to reflect the changes.
As this is quite some political act it should be done in dicussion with the whole team
and permission of the release manager.
- Docs need to be updated to reflect the changes.
How does it work:
Code has been changed so that authentification is done early for all clients.
This allows accessing the ACL data (client->acl) from nearly everywhere in the code.
After accept() and initial client setup the request is parsed. In the next step
all <alias>es are resolved. After this the client is passed for authentication.
After authentication it is passed to the corresponding subsystem depending on kind of request.
All authentication instances have a thread running for doing the authentication.
This thread works on a queue of clients.
Hints for testers:
- Test with default config.
- Test with diffrent authentication modules in <mount>.
- Test shoutcast compatibility mode.
- Test with new style <authentication> and any amount of <role> (zero to quite some).
- Test <alias> lookup on all kinds of objects.
- Test source level credential login into the admin interface.
- Test shoucast style meta data updates.
- Test playlist generation.
Thank you for reading this long commit message. Have fun reading the full patch!
svn path=/icecast/trunk/icecast/; revision=19358
2014-11-28 18:46:08 -05:00
|
|
|
char *ptr, *headers;
|
2005-08-11 19:29:58 -04:00
|
|
|
|
2019-09-17 13:32:00 -04:00
|
|
|
ICECAST_LOG_DDEBUG("Client %p has buffer: %H", client, client->refbuf->data);
|
|
|
|
|
2005-08-11 19:29:58 -04:00
|
|
|
/* Get rid of trailing \r\n or \n after password */
|
2015-01-25 13:57:27 -05:00
|
|
|
ptr = strstr(client->refbuf->data, "\r\r\n");
|
|
|
|
if (ptr) {
|
2005-10-01 10:08:36 -04:00
|
|
|
headers = ptr+3;
|
2015-01-25 13:57:27 -05:00
|
|
|
} else {
|
|
|
|
ptr = strstr(client->refbuf->data, "\r\n");
|
|
|
|
if (ptr) {
|
2005-10-01 10:08:36 -04:00
|
|
|
headers = ptr+2;
|
2015-01-25 13:57:27 -05:00
|
|
|
} else {
|
|
|
|
ptr = strstr(client->refbuf->data, "\n");
|
2005-10-01 10:08:36 -04:00
|
|
|
if (ptr)
|
|
|
|
headers = ptr+1;
|
|
|
|
}
|
2005-09-26 12:34:51 -04:00
|
|
|
}
|
2005-08-11 19:29:58 -04:00
|
|
|
|
2015-01-25 13:57:27 -05:00
|
|
|
if (ptr == NULL){
|
|
|
|
client_destroy(client);
|
2022-03-19 15:15:34 -04:00
|
|
|
free_client_node(node);
|
2005-08-11 19:29:58 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
*ptr = '\0';
|
|
|
|
|
Wow. Mega patch!
This patch *replaces* the authentication system completly.
What is new:
- <authentication> in mount section is now a container object.
- <authentication> in root and mount section may hold any number of <role>-Tags.
- <role> tags:
Those tags define a 'role' and it's ACL rules.
A role is a instance of an authentication module (see below).
<role> takes the following options. All but type are optional.
- authentication related:
- type: Type of the authentication module (values: anonymous, static, legacy-password, url or htpasswd;
symbolic constants in auth.h)
- name: Name for the role. For later matching. (values: any string; default: (none))
- method: This rule is only active on the given list of HTTP methods.
(list of enum values: methods as recognized by httpp/ (e.g: get,post); default: *)
- ACL related:
- allow-method: Allowed HTTP methods.
(list of enum values: methods as recognized by httpp/ (e.g: get,post); default: get)
- deny-method: Rejected HTTP methods.
(list of enum values: methods as recognized by httpp/ (e.g: get,post); default: *)
- allow-admin: Allowed admin commands. (list of enum values: admin command; default: buildm3u)
- deny-admin: Rejected admin commands. (list of enum values: admin command; default: *)
- allow-web: Allowed web pages. (values: empty or *; default: *)
- deny-web: Rejected web pages. (values: empty or *; default: (empty))
- connections-per-user: maximum number of simultaneous connections per role and username.
This is only active on active sources. (values: unlimited or number of connections; default: unlimited)
- connection-duration: maximum time of a connection. This is only active on active sources.
(values: unlimited or number of secounds; default: unlimited)
<role> takes <option> child tags. <option> tags contain a name and a value option.
Meaning of <option> tags is up to the authentication module.
- <role>s are considered to build a stack. If a role returns with AUTH_NOMATCH the next one will be tried.
- <role>s are tested in this order: mount specific, default mount specific, global, internal fallback.
Internal fallback is set to allow web/ access via GET, POST and HEAD (only GET supported by this time)
and rejects all other requests.
- New authentication module: anonymous
This module matches all requests. No options taken.
- New authentication module: static
This module matches with a static username and password.
It takes two <option>s. One with name="username" and one with name="password" to set username and password.
This replaces old style <*-username> and <*-password> tags.
- New authentication module: legacy-password
This module matches with a statich password.
It takes one <option> with name="password" to set password.
This replaces old ICE and ICY (shoutcast compat mode) authentication.
- Parsing <authentication> in <mount> with a type set in a special way to allow 100% backward compatibility.
- Parsing of <source-password>, <admin-password>, <admin-user>, <relay-password> and <relay-user> in global
<authentication> for 100% backward compatibility.
- <alias> is now proccessed very early. This enables them to be used for all kinds of requests.
To Do List & What does not yet work:
- type="url" auth: mount_add and mount_remove.
This should be replaced by an unique feature I would call '<event>'.
- Admin commands manageauth and manageauth.xsl are disabled as they need more review:
This code needs to be ported to support multiple <role>s per <mount>.
- url authentication module can not yet return AUTH_NOMATCH.
This needs to be reviewed and discussed on how to handle this case best way.
- Default config files needs to be updated to reflect the changes.
As this is quite some political act it should be done in dicussion with the whole team
and permission of the release manager.
- Docs need to be updated to reflect the changes.
How does it work:
Code has been changed so that authentification is done early for all clients.
This allows accessing the ACL data (client->acl) from nearly everywhere in the code.
After accept() and initial client setup the request is parsed. In the next step
all <alias>es are resolved. After this the client is passed for authentication.
After authentication it is passed to the corresponding subsystem depending on kind of request.
All authentication instances have a thread running for doing the authentication.
This thread works on a queue of clients.
Hints for testers:
- Test with default config.
- Test with diffrent authentication modules in <mount>.
- Test shoutcast compatibility mode.
- Test with new style <authentication> and any amount of <role> (zero to quite some).
- Test <alias> lookup on all kinds of objects.
- Test source level credential login into the admin interface.
- Test shoucast style meta data updates.
- Test playlist generation.
Thank you for reading this long commit message. Have fun reading the full patch!
svn path=/icecast/trunk/icecast/; revision=19358
2014-11-28 18:46:08 -05:00
|
|
|
client->password = strdup(client->refbuf->data);
|
2018-04-21 07:03:18 -04:00
|
|
|
config = config_get_config();
|
|
|
|
client->username = strdup(config->shoutcast_user);
|
|
|
|
config_release_config();
|
Wow. Mega patch!
This patch *replaces* the authentication system completly.
What is new:
- <authentication> in mount section is now a container object.
- <authentication> in root and mount section may hold any number of <role>-Tags.
- <role> tags:
Those tags define a 'role' and it's ACL rules.
A role is a instance of an authentication module (see below).
<role> takes the following options. All but type are optional.
- authentication related:
- type: Type of the authentication module (values: anonymous, static, legacy-password, url or htpasswd;
symbolic constants in auth.h)
- name: Name for the role. For later matching. (values: any string; default: (none))
- method: This rule is only active on the given list of HTTP methods.
(list of enum values: methods as recognized by httpp/ (e.g: get,post); default: *)
- ACL related:
- allow-method: Allowed HTTP methods.
(list of enum values: methods as recognized by httpp/ (e.g: get,post); default: get)
- deny-method: Rejected HTTP methods.
(list of enum values: methods as recognized by httpp/ (e.g: get,post); default: *)
- allow-admin: Allowed admin commands. (list of enum values: admin command; default: buildm3u)
- deny-admin: Rejected admin commands. (list of enum values: admin command; default: *)
- allow-web: Allowed web pages. (values: empty or *; default: *)
- deny-web: Rejected web pages. (values: empty or *; default: (empty))
- connections-per-user: maximum number of simultaneous connections per role and username.
This is only active on active sources. (values: unlimited or number of connections; default: unlimited)
- connection-duration: maximum time of a connection. This is only active on active sources.
(values: unlimited or number of secounds; default: unlimited)
<role> takes <option> child tags. <option> tags contain a name and a value option.
Meaning of <option> tags is up to the authentication module.
- <role>s are considered to build a stack. If a role returns with AUTH_NOMATCH the next one will be tried.
- <role>s are tested in this order: mount specific, default mount specific, global, internal fallback.
Internal fallback is set to allow web/ access via GET, POST and HEAD (only GET supported by this time)
and rejects all other requests.
- New authentication module: anonymous
This module matches all requests. No options taken.
- New authentication module: static
This module matches with a static username and password.
It takes two <option>s. One with name="username" and one with name="password" to set username and password.
This replaces old style <*-username> and <*-password> tags.
- New authentication module: legacy-password
This module matches with a statich password.
It takes one <option> with name="password" to set password.
This replaces old ICE and ICY (shoutcast compat mode) authentication.
- Parsing <authentication> in <mount> with a type set in a special way to allow 100% backward compatibility.
- Parsing of <source-password>, <admin-password>, <admin-user>, <relay-password> and <relay-user> in global
<authentication> for 100% backward compatibility.
- <alias> is now proccessed very early. This enables them to be used for all kinds of requests.
To Do List & What does not yet work:
- type="url" auth: mount_add and mount_remove.
This should be replaced by an unique feature I would call '<event>'.
- Admin commands manageauth and manageauth.xsl are disabled as they need more review:
This code needs to be ported to support multiple <role>s per <mount>.
- url authentication module can not yet return AUTH_NOMATCH.
This needs to be reviewed and discussed on how to handle this case best way.
- Default config files needs to be updated to reflect the changes.
As this is quite some political act it should be done in dicussion with the whole team
and permission of the release manager.
- Docs need to be updated to reflect the changes.
How does it work:
Code has been changed so that authentification is done early for all clients.
This allows accessing the ACL data (client->acl) from nearly everywhere in the code.
After accept() and initial client setup the request is parsed. In the next step
all <alias>es are resolved. After this the client is passed for authentication.
After authentication it is passed to the corresponding subsystem depending on kind of request.
All authentication instances have a thread running for doing the authentication.
This thread works on a queue of clients.
Hints for testers:
- Test with default config.
- Test with diffrent authentication modules in <mount>.
- Test shoutcast compatibility mode.
- Test with new style <authentication> and any amount of <role> (zero to quite some).
- Test <alias> lookup on all kinds of objects.
- Test source level credential login into the admin interface.
- Test shoucast style meta data updates.
- Test playlist generation.
Thank you for reading this long commit message. Have fun reading the full patch!
svn path=/icecast/trunk/icecast/; revision=19358
2014-11-28 18:46:08 -05:00
|
|
|
node->offset -= (headers - client->refbuf->data);
|
2015-01-25 13:57:27 -05:00
|
|
|
memmove(client->refbuf->data, headers, node->offset+1);
|
Wow. Mega patch!
This patch *replaces* the authentication system completly.
What is new:
- <authentication> in mount section is now a container object.
- <authentication> in root and mount section may hold any number of <role>-Tags.
- <role> tags:
Those tags define a 'role' and it's ACL rules.
A role is a instance of an authentication module (see below).
<role> takes the following options. All but type are optional.
- authentication related:
- type: Type of the authentication module (values: anonymous, static, legacy-password, url or htpasswd;
symbolic constants in auth.h)
- name: Name for the role. For later matching. (values: any string; default: (none))
- method: This rule is only active on the given list of HTTP methods.
(list of enum values: methods as recognized by httpp/ (e.g: get,post); default: *)
- ACL related:
- allow-method: Allowed HTTP methods.
(list of enum values: methods as recognized by httpp/ (e.g: get,post); default: get)
- deny-method: Rejected HTTP methods.
(list of enum values: methods as recognized by httpp/ (e.g: get,post); default: *)
- allow-admin: Allowed admin commands. (list of enum values: admin command; default: buildm3u)
- deny-admin: Rejected admin commands. (list of enum values: admin command; default: *)
- allow-web: Allowed web pages. (values: empty or *; default: *)
- deny-web: Rejected web pages. (values: empty or *; default: (empty))
- connections-per-user: maximum number of simultaneous connections per role and username.
This is only active on active sources. (values: unlimited or number of connections; default: unlimited)
- connection-duration: maximum time of a connection. This is only active on active sources.
(values: unlimited or number of secounds; default: unlimited)
<role> takes <option> child tags. <option> tags contain a name and a value option.
Meaning of <option> tags is up to the authentication module.
- <role>s are considered to build a stack. If a role returns with AUTH_NOMATCH the next one will be tried.
- <role>s are tested in this order: mount specific, default mount specific, global, internal fallback.
Internal fallback is set to allow web/ access via GET, POST and HEAD (only GET supported by this time)
and rejects all other requests.
- New authentication module: anonymous
This module matches all requests. No options taken.
- New authentication module: static
This module matches with a static username and password.
It takes two <option>s. One with name="username" and one with name="password" to set username and password.
This replaces old style <*-username> and <*-password> tags.
- New authentication module: legacy-password
This module matches with a statich password.
It takes one <option> with name="password" to set password.
This replaces old ICE and ICY (shoutcast compat mode) authentication.
- Parsing <authentication> in <mount> with a type set in a special way to allow 100% backward compatibility.
- Parsing of <source-password>, <admin-password>, <admin-user>, <relay-password> and <relay-user> in global
<authentication> for 100% backward compatibility.
- <alias> is now proccessed very early. This enables them to be used for all kinds of requests.
To Do List & What does not yet work:
- type="url" auth: mount_add and mount_remove.
This should be replaced by an unique feature I would call '<event>'.
- Admin commands manageauth and manageauth.xsl are disabled as they need more review:
This code needs to be ported to support multiple <role>s per <mount>.
- url authentication module can not yet return AUTH_NOMATCH.
This needs to be reviewed and discussed on how to handle this case best way.
- Default config files needs to be updated to reflect the changes.
As this is quite some political act it should be done in dicussion with the whole team
and permission of the release manager.
- Docs need to be updated to reflect the changes.
How does it work:
Code has been changed so that authentification is done early for all clients.
This allows accessing the ACL data (client->acl) from nearly everywhere in the code.
After accept() and initial client setup the request is parsed. In the next step
all <alias>es are resolved. After this the client is passed for authentication.
After authentication it is passed to the corresponding subsystem depending on kind of request.
All authentication instances have a thread running for doing the authentication.
This thread works on a queue of clients.
Hints for testers:
- Test with default config.
- Test with diffrent authentication modules in <mount>.
- Test shoutcast compatibility mode.
- Test with new style <authentication> and any amount of <role> (zero to quite some).
- Test <alias> lookup on all kinds of objects.
- Test source level credential login into the admin interface.
- Test shoucast style meta data updates.
- Test playlist generation.
Thank you for reading this long commit message. Have fun reading the full patch!
svn path=/icecast/trunk/icecast/; revision=19358
2014-11-28 18:46:08 -05:00
|
|
|
node->shoutcast = 2;
|
|
|
|
/* we've checked the password, now send it back for reading headers */
|
2022-03-19 15:05:53 -04:00
|
|
|
client_queue_add(&_request_queue, node);
|
2019-09-17 13:32:00 -04:00
|
|
|
ICECAST_LOG_DDEBUG("Client %p re-added to request queue", client);
|
2004-11-11 10:47:33 -05:00
|
|
|
return;
|
|
|
|
}
|
2007-10-24 22:25:49 -04:00
|
|
|
/* actually make a copy as we are dropping the config lock */
|
2004-11-11 10:47:33 -05:00
|
|
|
/* Here we create a valid HTTP request based of the information
|
|
|
|
that was passed in via the non-HTTP style protocol above. This
|
|
|
|
means we can use some of our existing code to handle this case */
|
Wow. Mega patch!
This patch *replaces* the authentication system completly.
What is new:
- <authentication> in mount section is now a container object.
- <authentication> in root and mount section may hold any number of <role>-Tags.
- <role> tags:
Those tags define a 'role' and it's ACL rules.
A role is a instance of an authentication module (see below).
<role> takes the following options. All but type are optional.
- authentication related:
- type: Type of the authentication module (values: anonymous, static, legacy-password, url or htpasswd;
symbolic constants in auth.h)
- name: Name for the role. For later matching. (values: any string; default: (none))
- method: This rule is only active on the given list of HTTP methods.
(list of enum values: methods as recognized by httpp/ (e.g: get,post); default: *)
- ACL related:
- allow-method: Allowed HTTP methods.
(list of enum values: methods as recognized by httpp/ (e.g: get,post); default: get)
- deny-method: Rejected HTTP methods.
(list of enum values: methods as recognized by httpp/ (e.g: get,post); default: *)
- allow-admin: Allowed admin commands. (list of enum values: admin command; default: buildm3u)
- deny-admin: Rejected admin commands. (list of enum values: admin command; default: *)
- allow-web: Allowed web pages. (values: empty or *; default: *)
- deny-web: Rejected web pages. (values: empty or *; default: (empty))
- connections-per-user: maximum number of simultaneous connections per role and username.
This is only active on active sources. (values: unlimited or number of connections; default: unlimited)
- connection-duration: maximum time of a connection. This is only active on active sources.
(values: unlimited or number of secounds; default: unlimited)
<role> takes <option> child tags. <option> tags contain a name and a value option.
Meaning of <option> tags is up to the authentication module.
- <role>s are considered to build a stack. If a role returns with AUTH_NOMATCH the next one will be tried.
- <role>s are tested in this order: mount specific, default mount specific, global, internal fallback.
Internal fallback is set to allow web/ access via GET, POST and HEAD (only GET supported by this time)
and rejects all other requests.
- New authentication module: anonymous
This module matches all requests. No options taken.
- New authentication module: static
This module matches with a static username and password.
It takes two <option>s. One with name="username" and one with name="password" to set username and password.
This replaces old style <*-username> and <*-password> tags.
- New authentication module: legacy-password
This module matches with a statich password.
It takes one <option> with name="password" to set password.
This replaces old ICE and ICY (shoutcast compat mode) authentication.
- Parsing <authentication> in <mount> with a type set in a special way to allow 100% backward compatibility.
- Parsing of <source-password>, <admin-password>, <admin-user>, <relay-password> and <relay-user> in global
<authentication> for 100% backward compatibility.
- <alias> is now proccessed very early. This enables them to be used for all kinds of requests.
To Do List & What does not yet work:
- type="url" auth: mount_add and mount_remove.
This should be replaced by an unique feature I would call '<event>'.
- Admin commands manageauth and manageauth.xsl are disabled as they need more review:
This code needs to be ported to support multiple <role>s per <mount>.
- url authentication module can not yet return AUTH_NOMATCH.
This needs to be reviewed and discussed on how to handle this case best way.
- Default config files needs to be updated to reflect the changes.
As this is quite some political act it should be done in dicussion with the whole team
and permission of the release manager.
- Docs need to be updated to reflect the changes.
How does it work:
Code has been changed so that authentification is done early for all clients.
This allows accessing the ACL data (client->acl) from nearly everywhere in the code.
After accept() and initial client setup the request is parsed. In the next step
all <alias>es are resolved. After this the client is passed for authentication.
After authentication it is passed to the corresponding subsystem depending on kind of request.
All authentication instances have a thread running for doing the authentication.
This thread works on a queue of clients.
Hints for testers:
- Test with default config.
- Test with diffrent authentication modules in <mount>.
- Test shoutcast compatibility mode.
- Test with new style <authentication> and any amount of <role> (zero to quite some).
- Test <alias> lookup on all kinds of objects.
- Test source level credential login into the admin interface.
- Test shoucast style meta data updates.
- Test playlist generation.
Thank you for reading this long commit message. Have fun reading the full patch!
svn path=/icecast/trunk/icecast/; revision=19358
2014-11-28 18:46:08 -05:00
|
|
|
config = config_get_config();
|
|
|
|
if (node->shoutcast_mount) {
|
|
|
|
shoutcast_mount = node->shoutcast_mount;
|
|
|
|
} else {
|
|
|
|
shoutcast_mount = config->shoutcast_mount;
|
|
|
|
}
|
|
|
|
http_compliant_len = 20 + strlen(shoutcast_mount) + node->offset;
|
2004-11-11 10:47:33 -05:00
|
|
|
http_compliant = (char *)calloc(1, http_compliant_len);
|
Wow. Mega patch!
This patch *replaces* the authentication system completly.
What is new:
- <authentication> in mount section is now a container object.
- <authentication> in root and mount section may hold any number of <role>-Tags.
- <role> tags:
Those tags define a 'role' and it's ACL rules.
A role is a instance of an authentication module (see below).
<role> takes the following options. All but type are optional.
- authentication related:
- type: Type of the authentication module (values: anonymous, static, legacy-password, url or htpasswd;
symbolic constants in auth.h)
- name: Name for the role. For later matching. (values: any string; default: (none))
- method: This rule is only active on the given list of HTTP methods.
(list of enum values: methods as recognized by httpp/ (e.g: get,post); default: *)
- ACL related:
- allow-method: Allowed HTTP methods.
(list of enum values: methods as recognized by httpp/ (e.g: get,post); default: get)
- deny-method: Rejected HTTP methods.
(list of enum values: methods as recognized by httpp/ (e.g: get,post); default: *)
- allow-admin: Allowed admin commands. (list of enum values: admin command; default: buildm3u)
- deny-admin: Rejected admin commands. (list of enum values: admin command; default: *)
- allow-web: Allowed web pages. (values: empty or *; default: *)
- deny-web: Rejected web pages. (values: empty or *; default: (empty))
- connections-per-user: maximum number of simultaneous connections per role and username.
This is only active on active sources. (values: unlimited or number of connections; default: unlimited)
- connection-duration: maximum time of a connection. This is only active on active sources.
(values: unlimited or number of secounds; default: unlimited)
<role> takes <option> child tags. <option> tags contain a name and a value option.
Meaning of <option> tags is up to the authentication module.
- <role>s are considered to build a stack. If a role returns with AUTH_NOMATCH the next one will be tried.
- <role>s are tested in this order: mount specific, default mount specific, global, internal fallback.
Internal fallback is set to allow web/ access via GET, POST and HEAD (only GET supported by this time)
and rejects all other requests.
- New authentication module: anonymous
This module matches all requests. No options taken.
- New authentication module: static
This module matches with a static username and password.
It takes two <option>s. One with name="username" and one with name="password" to set username and password.
This replaces old style <*-username> and <*-password> tags.
- New authentication module: legacy-password
This module matches with a statich password.
It takes one <option> with name="password" to set password.
This replaces old ICE and ICY (shoutcast compat mode) authentication.
- Parsing <authentication> in <mount> with a type set in a special way to allow 100% backward compatibility.
- Parsing of <source-password>, <admin-password>, <admin-user>, <relay-password> and <relay-user> in global
<authentication> for 100% backward compatibility.
- <alias> is now proccessed very early. This enables them to be used for all kinds of requests.
To Do List & What does not yet work:
- type="url" auth: mount_add and mount_remove.
This should be replaced by an unique feature I would call '<event>'.
- Admin commands manageauth and manageauth.xsl are disabled as they need more review:
This code needs to be ported to support multiple <role>s per <mount>.
- url authentication module can not yet return AUTH_NOMATCH.
This needs to be reviewed and discussed on how to handle this case best way.
- Default config files needs to be updated to reflect the changes.
As this is quite some political act it should be done in dicussion with the whole team
and permission of the release manager.
- Docs need to be updated to reflect the changes.
How does it work:
Code has been changed so that authentification is done early for all clients.
This allows accessing the ACL data (client->acl) from nearly everywhere in the code.
After accept() and initial client setup the request is parsed. In the next step
all <alias>es are resolved. After this the client is passed for authentication.
After authentication it is passed to the corresponding subsystem depending on kind of request.
All authentication instances have a thread running for doing the authentication.
This thread works on a queue of clients.
Hints for testers:
- Test with default config.
- Test with diffrent authentication modules in <mount>.
- Test shoutcast compatibility mode.
- Test with new style <authentication> and any amount of <role> (zero to quite some).
- Test <alias> lookup on all kinds of objects.
- Test source level credential login into the admin interface.
- Test shoucast style meta data updates.
- Test playlist generation.
Thank you for reading this long commit message. Have fun reading the full patch!
svn path=/icecast/trunk/icecast/; revision=19358
2014-11-28 18:46:08 -05:00
|
|
|
snprintf(http_compliant, http_compliant_len,
|
2005-08-11 19:29:58 -04:00
|
|
|
"SOURCE %s HTTP/1.0\r\n%s", shoutcast_mount, client->refbuf->data);
|
Wow. Mega patch!
This patch *replaces* the authentication system completly.
What is new:
- <authentication> in mount section is now a container object.
- <authentication> in root and mount section may hold any number of <role>-Tags.
- <role> tags:
Those tags define a 'role' and it's ACL rules.
A role is a instance of an authentication module (see below).
<role> takes the following options. All but type are optional.
- authentication related:
- type: Type of the authentication module (values: anonymous, static, legacy-password, url or htpasswd;
symbolic constants in auth.h)
- name: Name for the role. For later matching. (values: any string; default: (none))
- method: This rule is only active on the given list of HTTP methods.
(list of enum values: methods as recognized by httpp/ (e.g: get,post); default: *)
- ACL related:
- allow-method: Allowed HTTP methods.
(list of enum values: methods as recognized by httpp/ (e.g: get,post); default: get)
- deny-method: Rejected HTTP methods.
(list of enum values: methods as recognized by httpp/ (e.g: get,post); default: *)
- allow-admin: Allowed admin commands. (list of enum values: admin command; default: buildm3u)
- deny-admin: Rejected admin commands. (list of enum values: admin command; default: *)
- allow-web: Allowed web pages. (values: empty or *; default: *)
- deny-web: Rejected web pages. (values: empty or *; default: (empty))
- connections-per-user: maximum number of simultaneous connections per role and username.
This is only active on active sources. (values: unlimited or number of connections; default: unlimited)
- connection-duration: maximum time of a connection. This is only active on active sources.
(values: unlimited or number of secounds; default: unlimited)
<role> takes <option> child tags. <option> tags contain a name and a value option.
Meaning of <option> tags is up to the authentication module.
- <role>s are considered to build a stack. If a role returns with AUTH_NOMATCH the next one will be tried.
- <role>s are tested in this order: mount specific, default mount specific, global, internal fallback.
Internal fallback is set to allow web/ access via GET, POST and HEAD (only GET supported by this time)
and rejects all other requests.
- New authentication module: anonymous
This module matches all requests. No options taken.
- New authentication module: static
This module matches with a static username and password.
It takes two <option>s. One with name="username" and one with name="password" to set username and password.
This replaces old style <*-username> and <*-password> tags.
- New authentication module: legacy-password
This module matches with a statich password.
It takes one <option> with name="password" to set password.
This replaces old ICE and ICY (shoutcast compat mode) authentication.
- Parsing <authentication> in <mount> with a type set in a special way to allow 100% backward compatibility.
- Parsing of <source-password>, <admin-password>, <admin-user>, <relay-password> and <relay-user> in global
<authentication> for 100% backward compatibility.
- <alias> is now proccessed very early. This enables them to be used for all kinds of requests.
To Do List & What does not yet work:
- type="url" auth: mount_add and mount_remove.
This should be replaced by an unique feature I would call '<event>'.
- Admin commands manageauth and manageauth.xsl are disabled as they need more review:
This code needs to be ported to support multiple <role>s per <mount>.
- url authentication module can not yet return AUTH_NOMATCH.
This needs to be reviewed and discussed on how to handle this case best way.
- Default config files needs to be updated to reflect the changes.
As this is quite some political act it should be done in dicussion with the whole team
and permission of the release manager.
- Docs need to be updated to reflect the changes.
How does it work:
Code has been changed so that authentification is done early for all clients.
This allows accessing the ACL data (client->acl) from nearly everywhere in the code.
After accept() and initial client setup the request is parsed. In the next step
all <alias>es are resolved. After this the client is passed for authentication.
After authentication it is passed to the corresponding subsystem depending on kind of request.
All authentication instances have a thread running for doing the authentication.
This thread works on a queue of clients.
Hints for testers:
- Test with default config.
- Test with diffrent authentication modules in <mount>.
- Test shoutcast compatibility mode.
- Test with new style <authentication> and any amount of <role> (zero to quite some).
- Test <alias> lookup on all kinds of objects.
- Test source level credential login into the admin interface.
- Test shoucast style meta data updates.
- Test playlist generation.
Thank you for reading this long commit message. Have fun reading the full patch!
svn path=/icecast/trunk/icecast/; revision=19358
2014-11-28 18:46:08 -05:00
|
|
|
config_release_config();
|
|
|
|
|
2004-11-11 10:47:33 -05:00
|
|
|
parser = httpp_create_parser();
|
|
|
|
httpp_initialize(parser, NULL);
|
2015-01-25 13:57:27 -05:00
|
|
|
if (httpp_parse(parser, http_compliant, strlen(http_compliant))) {
|
2018-06-18 05:34:27 -04:00
|
|
|
client->refbuf->len = 0;
|
2005-08-11 19:29:58 -04:00
|
|
|
client->parser = parser;
|
Wow. Mega patch!
This patch *replaces* the authentication system completly.
What is new:
- <authentication> in mount section is now a container object.
- <authentication> in root and mount section may hold any number of <role>-Tags.
- <role> tags:
Those tags define a 'role' and it's ACL rules.
A role is a instance of an authentication module (see below).
<role> takes the following options. All but type are optional.
- authentication related:
- type: Type of the authentication module (values: anonymous, static, legacy-password, url or htpasswd;
symbolic constants in auth.h)
- name: Name for the role. For later matching. (values: any string; default: (none))
- method: This rule is only active on the given list of HTTP methods.
(list of enum values: methods as recognized by httpp/ (e.g: get,post); default: *)
- ACL related:
- allow-method: Allowed HTTP methods.
(list of enum values: methods as recognized by httpp/ (e.g: get,post); default: get)
- deny-method: Rejected HTTP methods.
(list of enum values: methods as recognized by httpp/ (e.g: get,post); default: *)
- allow-admin: Allowed admin commands. (list of enum values: admin command; default: buildm3u)
- deny-admin: Rejected admin commands. (list of enum values: admin command; default: *)
- allow-web: Allowed web pages. (values: empty or *; default: *)
- deny-web: Rejected web pages. (values: empty or *; default: (empty))
- connections-per-user: maximum number of simultaneous connections per role and username.
This is only active on active sources. (values: unlimited or number of connections; default: unlimited)
- connection-duration: maximum time of a connection. This is only active on active sources.
(values: unlimited or number of secounds; default: unlimited)
<role> takes <option> child tags. <option> tags contain a name and a value option.
Meaning of <option> tags is up to the authentication module.
- <role>s are considered to build a stack. If a role returns with AUTH_NOMATCH the next one will be tried.
- <role>s are tested in this order: mount specific, default mount specific, global, internal fallback.
Internal fallback is set to allow web/ access via GET, POST and HEAD (only GET supported by this time)
and rejects all other requests.
- New authentication module: anonymous
This module matches all requests. No options taken.
- New authentication module: static
This module matches with a static username and password.
It takes two <option>s. One with name="username" and one with name="password" to set username and password.
This replaces old style <*-username> and <*-password> tags.
- New authentication module: legacy-password
This module matches with a statich password.
It takes one <option> with name="password" to set password.
This replaces old ICE and ICY (shoutcast compat mode) authentication.
- Parsing <authentication> in <mount> with a type set in a special way to allow 100% backward compatibility.
- Parsing of <source-password>, <admin-password>, <admin-user>, <relay-password> and <relay-user> in global
<authentication> for 100% backward compatibility.
- <alias> is now proccessed very early. This enables them to be used for all kinds of requests.
To Do List & What does not yet work:
- type="url" auth: mount_add and mount_remove.
This should be replaced by an unique feature I would call '<event>'.
- Admin commands manageauth and manageauth.xsl are disabled as they need more review:
This code needs to be ported to support multiple <role>s per <mount>.
- url authentication module can not yet return AUTH_NOMATCH.
This needs to be reviewed and discussed on how to handle this case best way.
- Default config files needs to be updated to reflect the changes.
As this is quite some political act it should be done in dicussion with the whole team
and permission of the release manager.
- Docs need to be updated to reflect the changes.
How does it work:
Code has been changed so that authentification is done early for all clients.
This allows accessing the ACL data (client->acl) from nearly everywhere in the code.
After accept() and initial client setup the request is parsed. In the next step
all <alias>es are resolved. After this the client is passed for authentication.
After authentication it is passed to the corresponding subsystem depending on kind of request.
All authentication instances have a thread running for doing the authentication.
This thread works on a queue of clients.
Hints for testers:
- Test with default config.
- Test with diffrent authentication modules in <mount>.
- Test shoutcast compatibility mode.
- Test with new style <authentication> and any amount of <role> (zero to quite some).
- Test <alias> lookup on all kinds of objects.
- Test source level credential login into the admin interface.
- Test shoucast style meta data updates.
- Test playlist generation.
Thank you for reading this long commit message. Have fun reading the full patch!
svn path=/icecast/trunk/icecast/; revision=19358
2014-11-28 18:46:08 -05:00
|
|
|
client->protocol = ICECAST_PROTOCOL_SHOUTCAST;
|
|
|
|
node->shoutcast = 0;
|
|
|
|
return;
|
2015-01-25 13:57:27 -05:00
|
|
|
} else {
|
|
|
|
httpp_destroy(parser);
|
|
|
|
client_destroy(client);
|
2004-11-11 10:47:33 -05:00
|
|
|
}
|
2015-01-25 13:57:27 -05:00
|
|
|
free(http_compliant);
|
2022-03-19 15:15:34 -04:00
|
|
|
free_client_node(node);
|
2005-08-11 19:29:58 -04:00
|
|
|
return;
|
2004-11-11 10:47:33 -05:00
|
|
|
}
|
|
|
|
|
2018-06-18 12:57:36 -04:00
|
|
|
/* Check if we need body of client */
|
2022-03-19 13:38:12 -04:00
|
|
|
static int _need_body(client_queue_entry_t *node)
|
2018-06-18 12:57:36 -04:00
|
|
|
{
|
2018-06-18 17:08:17 -04:00
|
|
|
client_t *client = node->client;
|
|
|
|
|
|
|
|
if (node->tried_body)
|
|
|
|
return 0;
|
|
|
|
|
2018-06-18 12:57:36 -04:00
|
|
|
if (client->parser->req_type == httpp_req_source) {
|
|
|
|
/* SOURCE connection. */
|
|
|
|
return 0;
|
|
|
|
} else if (client->parser->req_type == httpp_req_put) {
|
|
|
|
/* PUT connection.
|
|
|
|
* TODO: We may need body for /admin/ but we do not know if it's an admin request yet.
|
|
|
|
*/
|
|
|
|
return 0;
|
|
|
|
} else if (client->request_body_length != -1 && (size_t)client->request_body_length != client->request_body_read) {
|
|
|
|
return 1;
|
|
|
|
} else if (client->request_body_length == -1 && client_body_eof(client) == 0) {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-08-11 19:29:58 -04:00
|
|
|
/* Connection thread. Here we take clients off the connection queue and check
|
|
|
|
* the contents provided. We set up the parser then hand off to the specific
|
|
|
|
* request handler.
|
|
|
|
*/
|
2008-07-21 22:24:30 -04:00
|
|
|
static void _handle_connection(void)
|
2002-08-12 10:48:31 -04:00
|
|
|
{
|
2003-03-14 21:10:19 -05:00
|
|
|
http_parser_t *parser;
|
2007-08-16 18:49:13 -04:00
|
|
|
const char *rawuri;
|
2022-03-19 13:38:12 -04:00
|
|
|
client_queue_entry_t *node;
|
2001-09-09 22:21:46 -04:00
|
|
|
|
2022-03-19 17:50:42 -04:00
|
|
|
while ((node = client_queue_shift(&_connection_queue, NULL))) {
|
|
|
|
client_t *client = node->client;
|
|
|
|
int already_parsed = 0;
|
2001-09-09 22:21:46 -04:00
|
|
|
|
2022-03-19 17:50:42 -04:00
|
|
|
/* Check for special shoutcast compatability processing */
|
|
|
|
if (node->shoutcast) {
|
|
|
|
_handle_shoutcast_compatible (node);
|
|
|
|
if (node->shoutcast)
|
|
|
|
continue;
|
|
|
|
}
|
2001-09-09 22:21:46 -04:00
|
|
|
|
2022-03-19 17:50:42 -04:00
|
|
|
/* process normal HTTP headers */
|
|
|
|
if (client->parser) {
|
|
|
|
already_parsed = 1;
|
|
|
|
parser = client->parser;
|
|
|
|
} else {
|
|
|
|
parser = httpp_create_parser();
|
|
|
|
httpp_initialize(parser, NULL);
|
|
|
|
client->parser = parser;
|
|
|
|
}
|
|
|
|
if (already_parsed || httpp_parse (parser, client->refbuf->data, node->offset)) {
|
|
|
|
client->refbuf->len = 0;
|
|
|
|
|
|
|
|
/* early check if we need more data */
|
|
|
|
client_complete(client);
|
|
|
|
if (_need_body(node)) {
|
|
|
|
/* Just calling client_queue_add(&_body_queue, node) would do the job.
|
|
|
|
* However, if the client only has a small body this might work without moving it between queues.
|
|
|
|
* -> much faster.
|
|
|
|
*/
|
|
|
|
client_slurp_result_t res;
|
|
|
|
ice_config_t *config;
|
|
|
|
time_t timeout;
|
|
|
|
size_t body_size_limit;
|
|
|
|
|
|
|
|
config = config_get_config();
|
|
|
|
timeout = time(NULL) - config->body_timeout;
|
|
|
|
body_size_limit = config->body_size_limit;
|
|
|
|
config_release_config();
|
|
|
|
|
|
|
|
res = process_request_body_queue_one(node, timeout, body_size_limit);
|
|
|
|
if (res != CLIENT_SLURP_SUCCESS) {
|
|
|
|
ICECAST_LOG_DEBUG("Putting client %p in body queue.", client);
|
|
|
|
client_queue_add(&_body_queue, node);
|
|
|
|
continue;
|
|
|
|
} else {
|
|
|
|
ICECAST_LOG_DEBUG("Success on fast lane");
|
2018-06-18 12:57:36 -04:00
|
|
|
}
|
2022-03-19 17:50:42 -04:00
|
|
|
}
|
2018-06-18 12:57:36 -04:00
|
|
|
|
2022-03-19 17:50:42 -04:00
|
|
|
rawuri = httpp_getvar(parser, HTTPP_VAR_URI);
|
2007-10-24 22:25:49 -04:00
|
|
|
|
2022-03-19 17:50:42 -04:00
|
|
|
/* assign a port-based shoutcast mountpoint if required */
|
|
|
|
if (node->shoutcast_mount && strcmp (rawuri, "/admin.cgi") == 0)
|
|
|
|
httpp_set_query_param (client->parser, "mount", node->shoutcast_mount);
|
2007-10-24 22:25:49 -04:00
|
|
|
|
2022-03-19 17:50:42 -04:00
|
|
|
free_client_node(node);
|
2008-07-21 22:24:30 -04:00
|
|
|
|
2022-03-19 17:50:42 -04:00
|
|
|
connection_handle_client(client);
|
|
|
|
} else {
|
|
|
|
free_client_node(node);
|
|
|
|
ICECAST_LOG_ERROR("HTTP request parsing failed");
|
|
|
|
client_destroy (client);
|
2003-03-14 21:10:19 -05:00
|
|
|
}
|
|
|
|
}
|
2001-09-09 22:21:46 -04:00
|
|
|
}
|
|
|
|
|
2007-10-15 21:53:06 -04:00
|
|
|
|
2018-05-09 09:48:32 -04:00
|
|
|
static void __on_sock_count(size_t count, void *userdata)
|
|
|
|
{
|
|
|
|
(void)userdata;
|
|
|
|
|
|
|
|
ICECAST_LOG_DEBUG("Listen socket count is now %zu.", count);
|
|
|
|
|
|
|
|
if (count == 0 && global.running == ICECAST_RUNNING) {
|
|
|
|
ICECAST_LOG_INFO("No more listen sockets. Exiting.");
|
|
|
|
global.running = ICECAST_HALTING;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-10-15 21:53:06 -04:00
|
|
|
/* called when listening thread is not checking for incoming connections */
|
2018-04-18 01:43:46 -04:00
|
|
|
void connection_setup_sockets (ice_config_t *config)
|
2007-10-15 21:53:06 -04:00
|
|
|
{
|
|
|
|
global_lock();
|
2018-04-18 01:43:46 -04:00
|
|
|
refobject_unref(global.listensockets);
|
|
|
|
|
2015-01-25 13:57:27 -05:00
|
|
|
if (config == NULL) {
|
2007-10-15 21:53:06 -04:00
|
|
|
global_unlock();
|
2018-04-18 01:43:46 -04:00
|
|
|
return;
|
2007-10-15 21:53:06 -04:00
|
|
|
}
|
|
|
|
|
2007-10-23 18:25:31 -04:00
|
|
|
/* setup the banned/allowed IP filenames from the xml */
|
2015-01-05 17:06:53 -05:00
|
|
|
if (config->banfile) {
|
|
|
|
matchfile_release(banned_ip);
|
|
|
|
banned_ip = matchfile_new(config->banfile);
|
|
|
|
if (!banned_ip)
|
|
|
|
ICECAST_LOG_ERROR("Can not create ban object, bad!");
|
|
|
|
}
|
2007-10-23 18:25:31 -04:00
|
|
|
|
2015-01-05 17:06:53 -05:00
|
|
|
if (config->allowfile) {
|
|
|
|
matchfile_release(allowed_ip);
|
|
|
|
allowed_ip = matchfile_new(config->allowfile);
|
|
|
|
}
|
2007-10-23 18:25:31 -04:00
|
|
|
|
2018-10-10 11:06:45 -04:00
|
|
|
global.listensockets = refobject_new(listensocket_container_t);
|
2018-04-18 01:43:46 -04:00
|
|
|
listensocket_container_configure(global.listensockets, config);
|
2007-10-15 21:53:06 -04:00
|
|
|
|
2018-04-18 01:43:46 -04:00
|
|
|
global_unlock();
|
2007-10-15 21:53:06 -04:00
|
|
|
|
2018-05-09 09:48:32 -04:00
|
|
|
listensocket_container_set_sockcount_cb(global.listensockets, __on_sock_count, NULL);
|
2018-04-18 01:43:46 -04:00
|
|
|
listensocket_container_setup(global.listensockets);;
|
2007-10-15 21:53:06 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-09-09 22:21:46 -04:00
|
|
|
void connection_close(connection_t *con)
|
|
|
|
{
|
2015-02-01 18:04:54 -05:00
|
|
|
if (!con)
|
|
|
|
return;
|
|
|
|
|
2022-03-07 06:19:21 -05:00
|
|
|
ICECAST_LOG_DEBUG("Closing connection %p (connection ID: %llu, sock=%R)", con, (long long unsigned int)con->id, con->sock);
|
|
|
|
|
2018-07-05 06:49:59 -04:00
|
|
|
fastevent_emit(FASTEVENT_TYPE_CONNECTION_DESTROY, FASTEVENT_FLAG_MODIFICATION_ALLOWED, FASTEVENT_DATATYPE_CONNECTION, con);
|
|
|
|
|
2018-05-19 04:13:05 -04:00
|
|
|
tls_unref(con->tls);
|
2022-03-07 06:19:21 -05:00
|
|
|
if (con->sock != SOCK_ERROR)
|
2015-03-01 11:53:17 -05:00
|
|
|
sock_close(con->sock);
|
2015-01-25 13:57:27 -05:00
|
|
|
if (con->ip)
|
|
|
|
free(con->ip);
|
2018-07-19 05:36:05 -04:00
|
|
|
if (con->readbuffer)
|
2018-06-18 05:34:27 -04:00
|
|
|
free(con->readbuffer);
|
2018-04-18 01:43:46 -04:00
|
|
|
refobject_unref(con->listensocket_real);
|
|
|
|
refobject_unref(con->listensocket_effective);
|
2003-03-14 21:10:19 -05:00
|
|
|
free(con);
|
2001-09-09 22:21:46 -04:00
|
|
|
}
|
2018-11-13 03:51:02 -05:00
|
|
|
|
|
|
|
void connection_queue_client(client_t *client)
|
|
|
|
{
|
2022-03-19 13:38:12 -04:00
|
|
|
client_queue_entry_t *node = create_client_node(client);
|
2022-03-19 15:05:53 -04:00
|
|
|
client_queue_add(&_connection_queue, node);
|
2018-11-13 03:51:02 -05:00
|
|
|
}
|