Skip to content

converts zweipktfkts IRC plaintext logs to HTML5

License

Notifications You must be signed in to change notification settings

matthiasr/logformat

 
 

Repository files navigation

Overview

Logformat is an IRC bot that logs into a database, and a web frontend to show these logs.

History

Logformat is the reincarnation of an earlier, ehrm, system that transformed log files from my irssi setup into something resembling HTML. Along the way, it employed horrible spaghetti code and chains of regular expressions.

Components

All executable components live in bin. They share models and helpers from lib, including the basic configuration logic and database access.

bot.rb

The IRC bot. It will connect to one IRC network, join all channels in the database that have the join flag set, listen for and record all messages.

web.rb

A Sinatra web app that displays the logs, one day at a time, for all channels. It employs a simple ACL scheme to allow restricted access to certain channels.

import.rb

A script to read, parse and store the Irssi logfiles. It tries to avoid duplicates, but since the bot's recorded messages have second precision but the logfiles only minutes, importing logs from times when the bot was listening will lead to duplication.

console.rb

A pry REPL with all libraries preloaded. Currently, this is the only admin interface.

dump.rb

A simplistic script to dump the whole database in plain text format. Note that the format is currently not supported by the parser employed by import.rb.

Configuration

Runtime configuration is performed through environment variables. These are:

  • DB: URI for database access, e.g. postgres://user:pass@localhost/database. Default: sqlite://local.db (i.e. the local.db file in the current directory).
  • PORT: listen port for the web component. The web component will by default only listen on the local interface, use a web server like nginx to proxy. See below for a configuration example.
  • BIND: interface to bind to. Set to 0.0.0.0 to bind to all interfaces. Default: 127.0.0.1
  • SERVER: IRC server to connect to. Default: irc.freenode.net
  • NICK: Nickname to connect with. Default: logformat

nginx configuration example

Proxy to the web interface using proxy_pass, and pass the host header:

location / {
  proxy_pass http://localhost:8080;
  proxy_set_header Host $host;
}

A note about database support

Currently, the default database is SQLite 3. It is also used for tests (as an in-memory databse). However, it is recommended to use Postgres for real use-cases, it is much faster and more stable. I have encountered severe concurrency problems with all but Postgres during multithreaded imports.

It is very likely that sooner or later Postgres will be the only supported database backend.

Access Control Lists

Web access to a channel is controlled by a simple list of yes/no rules (the Permission model). The default is to allow access. Users are authenticated using HTTP Basic authentication. Unauthenticated users are represented by the special "anonymous" user.

To disable anonymous access to a channel, start the console and run

channel = Channel.find(:name => '#mychannel')
channel.deny_anonymous!

To create a user and allow access to the channel for them,

user = User.create(:name => 'joe', :password => 'password', :password_confirmation => 'password')
channel.allow!(user)

Docker

Pre-built Docker images are available. When running, you most likely want to set the DB environment variable. Commands are run in the correct bundler context. The default command is web.rb.

About

converts zweipktfkts IRC plaintext logs to HTML5

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Ruby 97.3%
  • HTML 2.5%
  • Shell 0.2%