packages feed

hulk (empty) → 0.1

raw patch · 9 files changed

+287/−0 lines, 9 filesdep +ConfigFiledep +Cryptodep +basesetup-changed

Dependencies added: ConfigFile, Crypto, base, cmdargs, containers, irc, mtl, network, split, time, unix, utf8-string

Files

+ LICENSE view
@@ -0,0 +1,30 @@+Copyright (c)2011, Chris Done++All rights reserved.++Redistribution and use in source and binary forms, with or without+modification, are permitted provided that the following conditions are met:++    * Redistributions of source code must retain the above copyright+      notice, this list of conditions and the following disclaimer.++    * Redistributions in binary form must reproduce the above+      copyright notice, this list of conditions and the following+      disclaimer in the documentation and/or other materials provided+      with the distribution.++    * Neither the name of Chris Done nor the names of other+      contributors may be used to endorse or promote products derived+      from this software without specific prior written permission.++THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ README.md view
@@ -0,0 +1,125 @@+# Hulk IRC Server Guide++## Installation++### From Hackage++    $ cabal install hulk++### From Github++    $ git clone git://github.com/chrisdone/hulk.git+    $ cd hulk+    $ cabal install++## Usage++### Configuration++    $ cp hulk.conf.example hulk.conf+    +You can edit the port, server name and MOTD file in here.+    +### Auth++    $ mkdir auth++Put a salt for your passwords in auth/passwd. For example:++    $ head -c 128 /dev/random | sha1sum > auth/passwd-key++Then generate a password for your IRC user:++    $ hulk-generate-pass -u demo -c=hulk.conf >> auth/passwd++(It will wait for a single line containing a pass and output the user+and sha1 sum.)++### Start the server++    $ hulk -chulk.conf++Logs / events will be outputted to stdout. This will be a+configuration option later. (Send me a patch if you already did this!)++Clients *must* connect with a password and user that matches the users+and passwords in your `auth/passwd` file.++## Using with SSL++You can use it with stunnel.++Change the port setting in hulk.conf:++    port = 6666++Generate an SSL certificate:++    $ openssl req -new -out hulk.pem -keyout hulk.pem -nodes -x509 -days 365++Make a stunnel.conf file:++    pid = /path/to/wherever/stunnel.pid+    client = no+    foreground = yes+    output = /dev/stdout+    cert = hulk.pem+    [hulk]+    connect = 127.0.0.1:6666+    accept = 6667+    +Then run it:+    +    stunnel stunnel.conf++(It may be in `/usr/sbin/stunnel` depending on your system.)++Then run hulk:++    hulk -chulk.conf++## Logging++Hulk doesn't support specific channel logging yet, but you can use a+logger bot.++    $ cabal install hog+    $ hog -h=127.0.0.1 --port=6666 -n=hog -u=hog --pass=mypassword --channels=#dev,#x -l/directory/of/logs -d5++`-d5` is the timeout before reconnect.++## Using an announcer bot++If you're using a private IRC server you're probably using it at a dev+company, and you probably want to make announcements about commits,+tickets, etc. from a feed.++You can use rss2irc. But you need a patched version which supports+sending the PASS command:++    $ git clone git://github.com/chrisdone/rss2irc.git+    $ cd rss2irc+    $ cabal install++Then run it:++    $ rss2irc http://myserver/foo.atom announce@127.0.0.1/#dev \+      -p 6667 -i 1 -l  --pass myannouncepass++## Utility for 'telling' people things externally++Sometimes you want automatic scripts to send notices to the IRC.++Save this script in `tell.sh`:++    (cat /mypath/tell-login; echo "NICK $1"; echo "TELL $2 :$3") | nc serverip 6667 -w 1 > /dev/null++Run it like this:++    $ tell announce '#dev' 'Stuff happened!'++And put this in your /mypath/tell-login:++    $ cat /opt/hulk/tell-login+    PASS mypassword+    USER myuser * * *
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ hulk.cabal view
@@ -0,0 +1,45 @@+Name:                hulk+Version:             0.1+Synopsis:            IRC daemon.+Description:         An IRC daemon with mandatory authentication.+License:             BSD3+License-file:        LICENSE+Author:              Chris Done+Maintainer:          chrisdone@gmail.com+Copyright:           2010 Chris Done +Category:            Network+Build-type:          Simple+Cabal-version:       >=1.2+Extra-source-files:  README.md, hulk.conf.example, txt/MOTD, txt/PREFACE++Executable hulk+  Main-is:           Main.hs+  Ghc-options:       -threaded+  Hs-Source-Dirs:    src+  Build-depends:     base >= 4 && <5+                    ,cmdargs >= 0.6 && <0.7+                    ,network >= 2.2 && < 2.4+                    ,ConfigFile >= 1.0 && < 1.1+                    ,unix >= 2.4 && < 2.5+                    ,mtl >= 1.1 && < 1.2+                    ,containers >= 0.3 && < 0.4+                    ,irc >= 0.4 && < 0.5+                    ,split >= 0.1 && < 0.2+                    ,utf8-string >= 0.3 && < 0.4+                    ,Crypto>=4.2 && < 4.3+                    ,time >= 1.1 && < 1.2++Executable hulk-generate-pass+  Main-is:          GeneratePass.hs+  Hs-Source-Dirs:   src+  Build-depends:    base >= 4 && <5+                    ,cmdargs >= 0.6 && <0.7+                    ,network >= 2.2 && < 2.4+                    ,ConfigFile >= 1.0 && < 1.1+                    ,unix >= 2.4 && < 2.5+                    ,mtl >= 1.1 && < 1.2+                    ,containers >= 0.3 && < 0.4+                    ,irc >= 0.4 && < 0.5+                    ,split >= 0.1 && < 0.2+                    ,utf8-string >= 0.3 && <0.4+                    ,Crypto>=4.2 && <4.3
+ hulk.conf.example view
@@ -0,0 +1,11 @@+[LISTEN]+port = 6667+hostname = myhostname++[STRINGS]+motd_file = txt/MOTD+preface_file = txt/PREFACE++[AUTH]+passwd_file = auth/passwd+passwd_key = auth/passwd-key
+ src/GeneratePass.hs view
@@ -0,0 +1,37 @@+{-# LANGUAGE DeriveDataTypeable, RecordWildCards, ScopedTypeVariables #-}+{-# OPTIONS -Wall -fno-warn-missing-signatures -fno-warn-name-shadowing #-}+module Main where++import System.Console.CmdArgs+import Data.HMAC+import Codec.Binary.UTF8.String+import Numeric+import Data.String+import Control.Applicative++import Hulk.Types+import Hulk.Config++data Options = Options+  { conf      :: FilePath+  , user      :: String+  } deriving (Show,Data,Typeable)++options = Options+  { conf = def &= opt "hulk.conf" &= help "The config file."+  , user = "demo"+  }+  &= summary "Hulk IRC Daemon Password Generator (C) Chris Done 2011"+  &= help "Generates a password entry line for the Hulk passwd file."++optionsConf = conf++main = do+  options <- cmdArgs options+  config <- getConfig $ optionsConf options+  let keyFile = configPasswdKey config+  key <- takeWhile digilet <$> readFile keyFile+  pass <- filter (/='\n') <$> getLine+  putStrLn $ ((user options ++ " ") ++)+           $ concat $ map (\x -> showHex x "")+           $ hmac_sha1 (encode key) (encode pass)
+ src/Main.hs view
@@ -0,0 +1,16 @@+{-# OPTIONS -Wall -fno-warn-missing-signatures #-}+module Main where++import Network+import System.Console.CmdArgs+import System.Posix++import Hulk.Config  (getConfig)+import Hulk.Options (options,optionsConf)+import Hulk.Server  (start)+import Hulk.Types   ()++main :: IO ()+main = withSocketsDo $ do+  _ <- installHandler sigPIPE Ignore Nothing+  cmdArgs options >>= getConfig . optionsConf >>= start
+ txt/MOTD view
@@ -0,0 +1,7 @@+Hello and welcome to this IRC server. I am your host, Dr. Bruce Banner+PhD in nuclear physics and HRRRRRNNNNNNNNNNNNGGGGGGGGGGGGGGGGGGGGGGGGG+HRRRRRNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN+NNRUN FOR YOUR LIFENNNNNNNNNNNNNNNNNNNNNNNNNGGGGGGGGNNNNNNNNNNNNNNNNNN+NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN+GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG+GG..
+ txt/PREFACE view
@@ -0,0 +1,14 @@+You must login with a username and password. If you have not already+created one, you should do so by generating one and adding it to the+Hulk passwd file in passwd. To generate a user/password+key/pair, use:++ $ genpass myusername++It will prompt for a password. Inspect it first to confirm it is+correct. To write it to the passwd file use++ $ genpass myusername >> /path/to/hulk/data/passwd++And configure your IRC client to use your username and to send a+*server* password.