commit f7a4432300c6621e138854967164e2c3aea56924 Author: Jerry Aldrich Date: Tue Jun 30 07:03:45 2020 -0700 Initial commit diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..d022dcc --- /dev/null +++ b/.dockerignore @@ -0,0 +1,2 @@ +config.json +kiwiirc.conf diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c7a3df9 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +kiwiirc.conf +config.json diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..29ae1c8 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,41 @@ +FROM alpine:latest as builder + +RUN apk --update add git yarn npm wget unzip go make + +RUN git clone --branch v1.5.1 https://github.com/kiwiirc/kiwiirc.git + +WORKDIR kiwiirc + +# Remove silly dice command +COPY ./nodice.patch . +RUN git apply ./nodice.patch + +RUN yarn install + +RUN yarn run build + +WORKDIR / +RUN apk --update add go make +RUN git clone https://github.com/kiwiirc/webircgateway.git && cd webircgateway +WORKDIR webircgateway + +RUN make build + +FROM alpine:latest + +LABEL maintainer jerryaldrichiii@gmail.com + +COPY --from=builder /kiwiirc/dist /srv/kiwiirc/www +COPY --from=builder /webircgateway/webircgateway /srv/kiwiirc + +EXPOSE 8080 + +COPY entrypoint.sh /entrypoint.sh +RUN chmod +x /entrypoint.sh + +RUN adduser -H -D -s /bin/false kiwi +RUN chown -R kiwi:kiwi /srv/ + +USER kiwi + +ENTRYPOINT ["/entrypoint.sh"] diff --git a/README.md b/README.md new file mode 100644 index 0000000..99668ae --- /dev/null +++ b/README.md @@ -0,0 +1,22 @@ +# Kiwi IRC + +## How to run + +Create a config.json: + +[https://github.com/kiwiirc/kiwiirc/blob/master/static/config.json](https://github.com/kiwiirc/kiwiirc/blob/master/static/config.json) + +Create a kiwiirc.conf: + +[https://github.com/kiwiirc/webircgateway/blob/master/config.conf.example](https://github.com/kiwiirc/webircgateway/blob/master/config.conf.example) + +> Alternatively, you could copy the example files in this repo + +Run the following: +``` +docker run -it --rm \ + -p 8080:8080 \ + -v $PWD/kiwiirc.conf:/bootstrap/kiwiirc.conf \ + -v $PWD/config.json:/bootstrap/config.json \ + jerryaldrichiii/kiwiirc:latest +``` diff --git a/config.json.example b/config.json.example new file mode 100644 index 0000000..6043fbc --- /dev/null +++ b/config.json.example @@ -0,0 +1,28 @@ +{ + "windowTitle": "Your IRC", + "startupScreen": "welcome", + "kiwiServer": "/webirc/kiwiirc/", + "restricted": true, + "theme": "dark", + "themes": [ + { "name": "Default", "url": "static/themes/default" }, + { "name": "Dark", "url": "static/themes/dark" }, + { "name": "Coffee", "url": "static/themes/coffee" }, + { "name": "GrayFox", "url": "static/themes/grayfox" }, + { "name": "Nightswatch", "url": "static/themes/nightswatch" }, + { "name": "Osprey", "url": "static/themes/osprey" }, + { "name": "Radioactive", "url": "static/themes/radioactive" }, + { "name": "Sky", "url": "static/themes/sky" } + ], + "startupOptions" : { + "server": "irc.yourserver.com", + "port": 6697, + "tls": true, + "direct": false, + "channel": "#general", + "nick": "kiwiirc-?", + "greetingText": "Welcome. Happy Hacking!", + "infoBackground": "", + "infoContent": "" + } +} diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100644 index 0000000..e1dcef8 --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,8 @@ +#!/bin/sh + +set -e + +cp /bootstrap/kiwiirc.conf /srv/kiwiirc/kiwiirc.conf +cp /bootstrap/config.json /srv/kiwiirc/www/config.json + +/srv/kiwiirc/webircgateway -config /srv/kiwiirc/kiwiirc.conf diff --git a/kiwiirc.conf.example b/kiwiirc.conf.example new file mode 100644 index 0000000..2118128 --- /dev/null +++ b/kiwiirc.conf.example @@ -0,0 +1,82 @@ +# 1 = Debug; 2 = Info; 3 = Warn; +logLevel = 2 + +# Enable the built in identd server (listens on port 113) +identd = false + +# The name of this gateway as reported in WEBIRC to IRC servers +gateway_name = "webircgateway" + +# A secret string used for generating client JWT tokens. Do not share this! +secret = "" + +[verify] +recaptcha_secret = "" +recaptcha_key = "" + +[clients] +# Default username / realname for IRC connections. If disabled it will use +# the values provided from the IRC client itself. +# %h will be replaced with the users hostname +# %i will be replaced with a hexed value of the users IP +username = "%i" +realname = "I am a webchat user" + +# This hostname value will only be used when using a WEBIRC password +#hostname = "%h" + +# The websocket / http server +[server.1] +bind = "0.0.0.0" +port = 8080 +#tls = true +#cert = server.crt +#key = server.key + +# Serve static files from a web root folder. +# Optional, but handy for serving the Kiwi IRC client if no other webserver is available +[fileserving] +enabled = true +webroot = www/ + +[transports] +websocket +sockjs +kiwiirc + +# Websites (hostnames) that are allowed to connect here +# No entries here will allow any website to connect. +[allowed_origins] +#*://example.com + +# If using a reverse proxy, it must be whitelisted for the client +# hostnames to be read correctly. In CIDR format. +# The user IPs are read from the standard X-Forwarded-For HTTP header +[reverse_proxies] +127.0.0.0/8 +10.0.0.0/8 +172.16.0.0/12 +192.168.0.0/16 +"::1/128" +"fd00::/8" + +# Connections will be sent to a random upstream +[upstream.1] +hostname = "irc.yourserver.com" +port = 6697 +tls = true +# Connection timeout in seconds +timeout = 5 +# Throttle the lines being written by X per second +throttle = 5 +# Webirc password as set in the IRC server config +webirc = "CHANGEME" + +# A public gateway to any IRC network +# If enabled, Kiwi IRC clients may connect to any IRC network (or a whitelisted +# network below) through the kiwiirc engine +[gateway] +enabled = false +timeout = 5 +throttle = 2 + diff --git a/nodice.patch b/nodice.patch new file mode 100644 index 0000000..9e4b96e --- /dev/null +++ b/nodice.patch @@ -0,0 +1,47 @@ +diff --git a/src/libs/InputHandler.js b/src/libs/InputHandler.js +index 0f18b283..7dd54602 100644 +--- a/src/libs/InputHandler.js ++++ b/src/libs/InputHandler.js +@@ -199,31 +199,6 @@ inputCommands.action = function inputCommandMsg(event, command, line) { + inputCommands.notice = function inputCommandMsg(event, command, line) { + handleMessage.call(this, 'notice', event, command, line); + }; +-inputCommands.dice = function inputCommandDice(event, command, line) { +- // /dice 100 +- +- event.handled = true; +- let buffer = this.state.getActiveBuffer(); +- let network = this.state.getActiveNetwork(); +- +- let sides = line.replace(/\D/g, ''); +- sides = parseInt(sides || '0', 10); +- if (sides <= 0) { +- sides = 6; +- } +- let rndNumber = Math.floor(Math.random() * sides) + 1; +- +- let msg = TextFormatting.t('dice_roll', { +- sides: TextFormatting.formatNumber(sides), +- number: TextFormatting.formatNumber(rndNumber), +- }); +- network.ircClient.action(buffer.name, msg); +- this.state.addMessage(buffer, { +- nick: network.nick, +- message: msg, +- type: 'action', +- }); +-}; + + inputCommands.ctcp = function inputCommandCtcp(event, command, line) { + event.handled = true; +diff --git a/src/res/autocompleteCommands.js b/src/res/autocompleteCommands.js +index 64111754..0113af40 100644 +--- a/src/res/autocompleteCommands.js ++++ b/src/res/autocompleteCommands.js +@@ -27,5 +27,5 @@ export default [ + { command: 'encoding', alias: [], description: 'locale_id_command_encoding' }, + { command: 'ignore', alias: [], description: 'locale_id_command_ignore' }, + { command: 'unignore', alias: [], description: 'locale_id_command_unignore' }, +- { command: 'dice', alias: [], description: 'locale_id_command_dice' }, ++ + ];