Permalink
Browse files

Ditch config file in favor of a config DSL. Also clean up.

Get rid of bundler. It doesn't really serve a purpose for now. Going to
try to work on this more, but I really need to refactor some stuff
before I get started on new code. We'll see how it goes...
  • Loading branch information...
1 parent 9201707 commit 9be60a378bac7139da64d7ed0100249596d7c707 @rakaur rakaur committed Apr 26, 2011
Showing with 239 additions and 176 deletions.
  1. +2 −0 .gitignore
  2. +0 −5 Gemfile
  3. +4 −3 README.md
  4. +82 −8 bin/kintara
  5. +0 −86 etc/config.yml
  6. +48 −74 lib/kintara.rb
  7. +103 −0 lib/kintara/config.rb
View
@@ -1,5 +1,7 @@
+*.rbc
var
etc/kintara.db
etc/server.crt
etc/server.key
Gemfile.lock
+doc/dsl.txt
View
@@ -1,5 +0,0 @@
-source "http://rubygems.org"
-
-gem 'sqlite3-ruby', '1.3.2'
-gem 'sequel', '3.17.0'
-
View
@@ -9,14 +9,15 @@ Information and repositories can be found on [GitHub][].
This application requires the following to be installed:
- - ruby (>= 1.8.6, >= 1.9.1)
+ - ruby (>= 1.8.7, >= 1.9.2) (MRI and rbx known to work)
- openssl
- rake (`gem install --remote rake`)
- sequel (`gem install --remote sequel`)
OpenSSL is required for TLS encrypted streams. Rake is required for unit tests
-and package management. Sequel is required for database management. Once all
-dependicies are met, edit `etc/config.yml` to your liking and go!
+and package management. Sequel is required for database management. If you want
+to run the tests, you'll also need bacon. Once all the dependencies are met,
+edit `bin/kintara` to your liking and go!
TABLE OF CONTENTS
-----------------
View
@@ -1,25 +1,99 @@
#!/usr/bin/env ruby
+#
# kintara: malkier xmpp server
# bin/kintara: instantiates a new +Kintara+ object
#
# Copyright (c) 2003-2011 Eric Will <rakaur@malkier.net>
#
# encoding: utf-8
+#
+# DO NOT EDIT YET!
+#
+
# Prepare the environment
$: << File.join(Dir.getwd, 'lib')
$0 = 'kintara'
# Import required application modules
require 'kintara'
-# Start a new instance of the application
-begin
- Kintara.new
-rescue Exception => err
- # XXX - eventually put logging and such here.
- raise
-end
+#
+# This is the configuration. Edit from here down.
+#
+# HOW TO USE THIS FILE:
+#
+# This file is, strictly speaking, a Ruby script. We've provided
+# methods that allow the configuration to be simple and human-readable.
+# Anything that works in Ruby will technically work here, but we
+# suggest sticking with the basics unless you know what you're doing.
+#
+# Unquoted strings are interpreted as Ruby statements. Numbers do not
+# need to be encapsulted within quotes. If your string is basic alphanumeric
+# you can use a :symbol (prefixing your string with a colon instead of
+# encapsulting it with quotations) as it is less noisy.
+#
+configure do
+
+ # How much logging should we do?
+ # In order of least verbose to most verbose:
+ # none, fatal, error, warning, info, debug
+ #
+ logging :info
+
+ # Define ports the daemon should listen on for incoming connections.
+ # You may optionally provide an IP/host to bind to. The default
+ # is to bind to all hosts. All ports serve all virtual hosts.
+ #
+ # We use a different port to talk to other servers. Omit this if you
+ # want to disable federation.
+ #
+ listen_for_clients 5222
+ listen_for_servers 5269, '127.0.0.1'
+
+ # Virtual hosts specify the domain names the daemon will serve.
+ # All other settings are vhost-specific. The `virtual_hosts` directive
+ # applies these settings to all virtual hosts.
+ #
+ virtual_hosts do
+
+ # Define who may connect to this service. The default allows everyone.
+ #
+ # Other examples:
+ # authorize '10.0.1.1', '127.0.0.1', /192\.168\.1\.(\d+)/
+ #
+ authorize /(.*)/
-exit 0
+ # Define who may NOT connect to this service. You may provide a reason.
+ #
+ #deny '127.0.0.1', :reason => 'Do not connect from the local machine!'
+ # This is here to make sure you're paying attention.
+ #abort "You didn't read your configuration!"
+
+ # There's a special type of user called an operator. These users
+ # are allowed certain privileges on the server such as sending
+ # server-wide messages, adding/removing users by hand, etc.
+ #
+ operator :rakaur, :flags => [:announce, :add, :remove]
+ end
+
+ virtual_host 'malkier.net' do
+
+ # The information we need for TLS/SSL.
+ # If you're like most people you'll need to generate
+ # your own, self-signed certificate rather than pay
+ # an ungodly sum of money to some company. In order to
+ # do this you need to run something along the lines of:
+ #
+ # openssl req -new -x509 -days 365 -sha1 -newkey rsa:1024 \
+ # -nodes -keyout server.key -out server.crt \
+ # -subj '/O=Company/OU=Department/CN=xmpp.example.com'
+ #
+ # Use the resulting "server.crt" file for ssl_certificate.
+ # Use the resulting "server.key" file for ssl_private_key.
+ #
+ ssl_certificate 'etc/server.crt'
+ ssl_private_key 'etc/server.key'
+ end
+end
View
@@ -1,86 +0,0 @@
-#
-# kintara: malkier xmpp server
-# etc/config.yml: configuration information
-#
-# Copyright (c) 2003-2009 Eric Will <rakaur@malkier.net>
-#
-# encoding: utf-8
-
-# This file is written in YAML. I decided to go with it over the
-# complex C-style configuration in synapse for a few reasons:
-#
-# 1) It's very simple.
-# 2) Ruby can parse it with one method call rather than an entire library.
-# 3) It's very Ruby-ish instead of C-ish, and that's what I'm going for.
-#
-
-# How much logging should we do?
-# In order of least verbose to most verbose:
-# none, fatal, error, warning, info, debug
-logging: info
-
-# Define domains this daemon will service. Sort of like virtual hosts.
-domains: malkier.net, optera.org
-
-##
-# Define listen ports. Entries are in the form of host:port.
-#
-# c2s = client-to-server ports. You must define at least one.
-# s2s = server-to-server ports. Omitting disables server federation.
-#
-# certificate = The certificate used for STARTTLS.
-# If you're like most people you'll have to generate
-# your own, self-signed certificate rather than pay
-# an ungodly sum of money to some company. In order to
-# do this you need to run something along the lines of:
-#
-# openssl req -new -x509 -days 365 -sha1 -newkey rsa:1024 \
-# -nodes -keyout server.key -out server.crt \
-# -subj '/O=Company/OU=Department/CN=xmpp.example.com'
-#
-# Use server.crt for this directive.
-#
-# private_key = The private key used for STARTTLS. See above.
-# Use server.key for this directive.
-#
-listen:
- c2s:
- - *:5222
- s2s:
- - *:5269
-
- certificate: etc/server.crt
- private_key: etc/server.key
-
-##
-# Define who may connect to this service. The default allows everyone.
-#
-# hosts = list of hosts that are allowed to connect.
-# matches = list of valid Ruby regular expressions. Omit /slashes/.
-#
-authorize:
- matches: (.*) # <- Everyone.
-# hosts: 192.168.0.1, 127.0.0.1
-# matches: 192\.168\.1\.(\d+)
-
-# This is here to make sure you read the config.
-#die: true
-
-##
-# Define who may NOT connect to this service.
-#
-# hosts = list of hosts that are allowed to connect.
-# matches = list of valid Ruby regular expressions. Omit /slashes/.
-deny:
-# hosts: 127.0.0.1, 192.168.0.1
-# matches: 192\.168\.2\.(\d+)
-
-##
-# Define users that are allowed to perform administrative operations.
-#
-# Available privileges:
-#
-# announce = May send server-wide messages.
-operators:
- rakaur: announce
-
Oops, something went wrong.

0 comments on commit 9be60a3

Please sign in to comment.