Beispiel #1
0
/* This function will provide a log of metadata for each
   mountpoint.  The metadata *must* be in UTF-8, and thus
   you can assume that the log itself is UTF-8 encoded */
void logging_playlist(const char *mount, const char *metadata, long listeners)
{
    char datebuf[128];
    struct tm thetime;
    time_t now;

    if (playlistlog == -1) {
        return;
    }

    now = time(NULL);

    localtime_r (&now, &thetime);
    /* build the data */
#ifdef _WIN32
    memset(datebuf, '\000', sizeof(datebuf));
    get_clf_time(datebuf, sizeof(datebuf)-1, &thetime);
#else
    strftime (datebuf, sizeof(datebuf), LOGGING_FORMAT_CLF, &thetime);
#endif
    /* This format MAY CHANGE OVER TIME.  We are looking into finding a good
       standard format for this, if you have any ideas, please let us know */
    log_write_direct (playlistlog, "%s|%s|%ld|%s",
             datebuf,
             mount,
             listeners,
             metadata);
}
Beispiel #2
0
/* 
** ADDR IDENT USER DATE REQUEST CODE BYTES REFERER AGENT [TIME]
**
** ADDR = client->con->ip
** IDENT = always - , we don't support it because it's useless
** USER = client->username
** DATE = _make_date(client->con->con_time)
** REQUEST = build from client->parser
** CODE = client->respcode
** BYTES = client->con->sent_bytes
** REFERER = get from client->parser
** AGENT = get from client->parser
** TIME = timing_get_time() - client->con->con_time
*/
void logging_access(client_t *client)
{
    char datebuf[128];
    char reqbuf[1024];
    struct tm thetime;
    time_t now;
    time_t stayed;
    const char *referrer, *user_agent, *username;

    now = time(NULL);

    localtime_r (&now, &thetime);
    /* build the data */
#ifdef _WIN32
    memset(datebuf, '\000', sizeof(datebuf));
    get_clf_time(datebuf, sizeof(datebuf)-1, &thetime);
#else
    strftime (datebuf, sizeof(datebuf), LOGGING_FORMAT_CLF, &thetime);
#endif
    /* build the request */
    snprintf (reqbuf, sizeof(reqbuf), "%s %s %s/%s",
            httpp_getvar (client->parser, HTTPP_VAR_REQ_TYPE),
            httpp_getvar (client->parser, HTTPP_VAR_URI),
            httpp_getvar (client->parser, HTTPP_VAR_PROTOCOL),
            httpp_getvar (client->parser, HTTPP_VAR_VERSION));

    stayed = now - client->con->con_time;

    if (client->username == NULL)
        username = "******"; 
    else
        username = client->username;

    referrer = httpp_getvar (client->parser, "referer");
    if (referrer == NULL)
        referrer = "-";

    user_agent = httpp_getvar (client->parser, "user-agent");
    if (user_agent == NULL)
        user_agent = "-";

    log_write_direct (accesslog,
            "%s - %s [%s] \"%s\" %d %" PRIu64 " \"%s\" \"%s\" %lu",
            client->con->ip,
            username,
            datebuf,
            reqbuf,
            client->respcode,
            client->con->sent_bytes,
            referrer,
            user_agent,
            (unsigned long)stayed);
}
Beispiel #3
0
/* This function will provide a log of metadata for each
   mountpoint.  The metadata *must* be in UTF-8, and thus
   you can assume that the log itself is UTF-8 encoded */
void logging_playlist(const char *mount, const char *metadata, long listeners)
{
    time_t now;
    char datebuf[128];

    if (playlistlog == -1) {
        return;
    }

    now = time(NULL);

    util_get_clf_time (datebuf, sizeof(datebuf), now);
    /* This format MAY CHANGE OVER TIME.  We are looking into finding a good
       standard format for this, if you have any ideas, please let us know */
    log_write_direct (playlistlog, "%s|%s|%ld|%s",
             datebuf,
             mount,
             listeners,
             metadata);
}
Beispiel #4
0
/* 
** ADDR IDENT USER DATE REQUEST CODE BYTES REFERER AGENT [TIME]
**
** ADDR = client->con->ip
** IDENT = always - , we don't support it because it's useless
** USER = client->username
** DATE = _make_date(client->con->con_time)
** REQUEST = build from client->parser
** CODE = client->respcode
** BYTES = client->con->sent_bytes
** REFERER = get from client->parser
** AGENT = get from client->parser
** TIME = timing_get_time() - client->con->con_time
*/
void logging_access_id (access_log *accesslog, client_t *client)
{
    const char *req = NULL;
    time_t now;
    time_t stayed;
    const char *referrer, *user_agent, *username, *ip = "-";
    char datebuf[50];
    char reqbuf[256];

    if (client->flags & CLIENT_SKIP_ACCESSLOG)
        return;

    now = time(NULL);

    /* build the data */
    util_get_clf_time (datebuf, sizeof(datebuf), now);
    if (accesslog->qstr)
        req = httpp_getvar (client->parser, HTTPP_VAR_RAWURI);
    if (req == NULL)
        req = httpp_getvar (client->parser, HTTPP_VAR_URI);
    /* build the request */
    snprintf (reqbuf, sizeof(reqbuf), "%s %s %s/%s",
            httpp_getvar (client->parser, HTTPP_VAR_REQ_TYPE), req,
            httpp_getvar (client->parser, HTTPP_VAR_PROTOCOL),
            httpp_getvar (client->parser, HTTPP_VAR_VERSION));

    stayed = now - client->connection.con_time;
    username = client->username;
    referrer = httpp_getvar (client->parser, "referer");
    user_agent = httpp_getvar (client->parser, "user-agent");

    if (accesslog->log_ip)
        ip = client->connection.ip;

    if (accesslog->type == LOG_ACCESS_CLF_ESC)
    {
        char *un = client->username ? util_url_escape (username) : strdup ("-"),
             *rq = util_url_escape (reqbuf),
             *rf = referrer ? util_url_escape (referrer) : strdup ("-"),
             *ua = user_agent ? util_url_escape (user_agent) : strdup ("-");

        log_write_direct (accesslog->logid,
                "%s - %s %s %s %d %" PRIu64 " %.150s %.150s %lu",
                ip, un, datebuf, rq, client->respcode, client->connection.sent_bytes,
                rf, ua, (unsigned long)stayed);
        free (ua);
        free (rf);
        free (rq);
        free (un);
    }
    else
    {
        if (client->username == NULL)   username = "******"; 
        if (referrer == NULL)           referrer = "-";
        if (user_agent == NULL)         user_agent = "-";

        log_write_direct (accesslog->logid,
                "%s - %s [%s] \"%s\" %d %" PRIu64 " \"%.150s\" \"%.150s\" %lu",
                ip, username, datebuf, reqbuf, client->respcode, client->connection.sent_bytes,
                referrer, user_agent, (unsigned long)stayed);
    }
    client->respcode = -1;
}