Compare commits
17 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
d4bdf43bfe | ||
![]() |
c792d21e93 | ||
![]() |
48a91b87cb | ||
![]() |
4045bbb373 | ||
![]() |
a22f7d20d5 | ||
![]() |
66473209bd | ||
![]() |
7bffda6818 | ||
![]() |
73fe81d8d1 | ||
![]() |
a5c2783e8f | ||
![]() |
7eee870172 | ||
![]() |
c960f84603 | ||
![]() |
04475f172e | ||
![]() |
d9c72ac9ee | ||
![]() |
c63c6c659e | ||
![]() |
91ad6cf100 | ||
![]() |
6ff4194c85 | ||
![]() |
491b82d735 |
5
.gitignore
vendored
5
.gitignore
vendored
@@ -1,3 +1,8 @@
|
||||
*.swp
|
||||
/catbox
|
||||
/test-net
|
||||
*.crt
|
||||
*.crl
|
||||
*.pem
|
||||
terrarium
|
||||
terrarium.exe
|
||||
|
120
Makefile
Normal file
120
Makefile
Normal file
@@ -0,0 +1,120 @@
|
||||
VERSION=0.0.05
|
||||
CGO_ENABLED=0
|
||||
export CGO_ENABLED=0
|
||||
|
||||
GOOS?=$(shell uname -s | tr A-Z a-z)
|
||||
GOARCH?="amd64"
|
||||
|
||||
ARG=-v -tags netgo -ldflags '-w -extldflags "-static"'
|
||||
|
||||
BINARY=terrarium
|
||||
SIGNER=hankhill19580@gmail.com
|
||||
CONSOLEPOSTNAME=IRC
|
||||
USER_GH=eyedeekay
|
||||
|
||||
build: dep
|
||||
go build $(ARG) -tags="netgo" -o $(BINARY)-$(GOOS)-$(GOARCH) ./cmd/$(BINARY)
|
||||
make su3
|
||||
|
||||
clean:
|
||||
rm -f $(BINARY)-plugin plugin $(BINARY)-*zip -r
|
||||
rm -f *.su3 *.zip $(BINARY)-$(GOOS)-$(GOARCH) $(BINARY)-*
|
||||
|
||||
all: windows linux osx bsd
|
||||
|
||||
windows:
|
||||
GOOS=windows GOARCH=amd64 make build su3
|
||||
GOOS=windows GOARCH=386 make build su3
|
||||
|
||||
linux:
|
||||
GOOS=linux GOARCH=amd64 make build su3
|
||||
GOOS=linux GOARCH=arm64 make build su3
|
||||
GOOS=linux GOARCH=386 make build su3
|
||||
|
||||
osx:
|
||||
GOOS=darwin GOARCH=amd64 make build su3
|
||||
GOOS=darwin GOARCH=arm64 make build su3
|
||||
|
||||
bsd:
|
||||
GOOS=freebsd GOARCH=amd64 make build su3
|
||||
GOOS=openbsd GOARCH=amd64 make build su3
|
||||
|
||||
dep:
|
||||
cp "$(HOME)/Workspace/GIT_WORK/i2p.i2p/build/shellservice.jar" conf/lib/shellservice.jar -v
|
||||
|
||||
su3:
|
||||
i2p.plugin.native -name=$(BINARY)-$(GOOS)-$(GOARCH) \
|
||||
-signer=$(SIGNER) \
|
||||
-version "$(VERSION)" \
|
||||
-author=$(SIGNER) \
|
||||
-autostart=true \
|
||||
-clientname=$(BINARY)-$(GOOS)-$(GOARCH) \
|
||||
-consolename="$(BINARY) - $(CONSOLEPOSTNAME)" \
|
||||
-consoleurl="http://127.0.0.1:8084" \
|
||||
-name="$(BINARY)-$(GOOS)-$(GOARCH)" \
|
||||
-delaystart="1" \
|
||||
-desc="`cat desc`" \
|
||||
-exename=$(BINARY)-$(GOOS)-$(GOARCH) \
|
||||
-icondata=icon/icon.png \
|
||||
-updateurl="http://idk.i2p/terrarium/$(BINARY)-$(GOOS)-$(GOARCH).su3" \
|
||||
-website="http://idk.i2p/terrarium/" \
|
||||
-command="$(BINARY)-$(GOOS)-$(GOARCH) -conf \"\$$PLUGIN/catbox-i2p.conf\"" \
|
||||
-license=MIT \
|
||||
-res=conf/
|
||||
unzip -o $(BINARY)-$(GOOS)-$(GOARCH).zip -d $(BINARY)-$(GOOS)-$(GOARCH)-zip
|
||||
|
||||
sum:
|
||||
sha256sum $(BINARY)-$(GOOS)-$(GOARCH).su3
|
||||
|
||||
version:
|
||||
gothub release -u eyedeekay -r terrarium -t "$(VERSION)" -d "`cat desc`"; true
|
||||
|
||||
upload:
|
||||
gothub upload -u eyedeekay -r terrarium -t "$(VERSION)" -f $(BINARY)-$(GOOS)-$(GOARCH).su3 -n $(BINARY)-$(GOOS)-$(GOARCH).su3 -l "`sha256sum $(BINARY)-$(GOOS)-$(GOARCH).su3`"
|
||||
|
||||
upload-windows:
|
||||
GOOS=windows GOARCH=amd64 make upload
|
||||
GOOS=windows GOARCH=386 make upload
|
||||
|
||||
upload-linux:
|
||||
GOOS=linux GOARCH=amd64 make upload
|
||||
GOOS=linux GOARCH=arm64 make upload
|
||||
GOOS=linux GOARCH=386 make upload
|
||||
|
||||
upload-osx:
|
||||
GOOS=darwin GOARCH=amd64 make upload
|
||||
GOOS=darwin GOARCH=arm64 make upload
|
||||
|
||||
upload-bsd:
|
||||
GOOS=freebsd GOARCH=amd64 make upload
|
||||
GOOS=openbsd GOARCH=amd64 make upload
|
||||
|
||||
upload-all: upload-windows upload-linux upload-osx upload-bsd
|
||||
|
||||
download-su3s:
|
||||
GOOS=windows GOARCH=amd64 make download-single-su3
|
||||
GOOS=windows GOARCH=386 make download-single-su3
|
||||
GOOS=linux GOARCH=amd64 make download-single-su3
|
||||
GOOS=linux GOARCH=arm64 make download-single-su3
|
||||
GOOS=linux GOARCH=386 make download-single-su3
|
||||
GOOS=darwin GOARCH=amd64 make download-single-su3
|
||||
GOOS=darwin GOARCH=arm64 make download-single-su3
|
||||
GOOS=freebsd GOARCH=amd64 make download-single-su3
|
||||
GOOS=openbsd GOARCH=amd64 make download-single-su3
|
||||
|
||||
download-single-su3:
|
||||
wget -N -c "https://github.com/$(USER_GH)/$(BINARY)/releases/download/$(VERSION)/$(BINARY)-$(GOOS)-$(GOARCH).su3"
|
||||
|
||||
release: clean all version upload-all
|
||||
|
||||
index:
|
||||
@echo "<!DOCTYPE html>" > index.html
|
||||
@echo "<html>" >> index.html
|
||||
@echo "<head>" >> index.html
|
||||
@echo " <title>$(BINARY) - $(CONSOLEPOSTNAME)</title>" >> index.html
|
||||
@echo " <link rel=\"stylesheet\" type=\"text/css\" href =\"/style.css\" />" >> index.html
|
||||
@echo "</head>" >> index.html
|
||||
@echo "<body>" >> index.html
|
||||
pandoc README.md >> index.html
|
||||
@echo "</body>" >> index.html
|
||||
@echo "</html>" >> index.html
|
51
README.md
51
README.md
@@ -1,12 +1,17 @@
|
||||

|
||||
# 
|
||||
|
||||
[](https://travis-ci.org/eyedeekay/terrarium)
|
||||
[](https://goreportcard.com/report/i2pgit.org/idk/terrarium)
|
||||
|
||||
terrarium is an IRC server with a focus on being small and understandable. The
|
||||
goal is security.
|
||||
terrarium is an IRC server with a focus on being small and understandable,
|
||||
originally forked from [horgh/catbox](https://github.com/horgh/catbox). The
|
||||
goal is to create an easy-to-configure I2P IRC server which is highly stable
|
||||
and secure, while retaining the ability to link with non-I2P IRC servers using
|
||||
TLS in order to bridge anonymous and non-anonymous chat. For now, Bridged
|
||||
servers are not anonymous, this may change in the future as I evaluate the
|
||||
feasibility of outproxies or Tor.
|
||||
|
||||
|
||||
# Features
|
||||
@@ -18,17 +23,32 @@ goal is security.
|
||||
* TLS
|
||||
|
||||
terrarium implements enough of [RFC 1459](https://tools.ietf.org/html/rfc1459)
|
||||
to be recognisable as IRC and be minimally functional. I likely won't add
|
||||
much more and don't intend it to be complete. If I don't think something is
|
||||
required it likely won't be here.
|
||||
to be recognisable as IRC and be minimally functional. It will intentionally
|
||||
omit unnecessary features. Priority features are those which enable moderation
|
||||
and provide more flexible security.
|
||||
|
||||
# Plugin Installation URL's
|
||||
|
||||
[A guide to installing I2P plugins can be found on the I2P web site.](https://geti2p.net/en/docs/plugins)
|
||||
|
||||
### Inside I2P
|
||||
|
||||
- [Windows (In-I2P)](http://idk.i2p/terrarium/terrarium-windows-amd64.su3)
|
||||
- [Linux (In-I2P)](http://idk.i2p/terrarium/terrarium-linux-amd64.su3)
|
||||
|
||||
### Outside I2P
|
||||
|
||||
- [Windows](https://github.com/terrarium/blizzard/releases)
|
||||
- [Linux](https://github.com/terrarium/blizzard/releases)
|
||||
|
||||
# Installation
|
||||
1. Download terrarium from the Releases tab on GitHub, or build from source
|
||||
1. Clone the software from [i2pgit.org](https://i2pgit.org/idk/terrarium)
|
||||
(`git clone https://i2pgit.org/idk/terrarium go/src/i2pgit.org/idk/terrarium && cd go/src/i2pgit.org/idk/terrarium`).
|
||||
2. Build from source
|
||||
(`go build`).
|
||||
2. Configure terrarium through config files. There are example configs in the
|
||||
3. Configure terrarium through config files. There are example configs in the
|
||||
`conf` directory. All settings are optional and have defaults.
|
||||
3. Run it, e.g. `./terrarium -conf terrarium.conf`. You might run it via systemd
|
||||
4. Run it, e.g. `./terrarium -conf terrarium.conf`. You might run it via systemd
|
||||
via a service such as:
|
||||
|
||||
```
|
||||
@@ -73,9 +93,18 @@ Clients connect to the network hostname and verify against it. Servers
|
||||
connect to each other by server hostname and verify against it.
|
||||
|
||||
|
||||
## I2P
|
||||
An example I2P configuration can be found in:
|
||||
|
||||
`conf/catbox-i2p.conf`
|
||||
|
||||
That's all the docs I have for now
|
||||
|
||||
# Why the name?
|
||||
My domain name is summercat.com, cats love boxes, and a tribute to
|
||||
ircd-ratbox, the IRC daemon I used in the past.
|
||||
It was forked from an IRC server called catbox which had a focus on simplicity
|
||||
and understandability. It now has the ability to connect to other IRC servers
|
||||
through I2P Tunnels. Clearnet is to I2P Tunnels is sort of like Catbox is to
|
||||
Terrarium.
|
||||
|
||||
|
||||
# Logo
|
||||
|
@@ -4,13 +4,13 @@
|
||||
# the option.
|
||||
|
||||
# Host to listen on.
|
||||
#listen-host = 0.0.0.0
|
||||
listen-host = 127.0.0.1
|
||||
|
||||
# Port to listen on. Set -1 to not listen.
|
||||
#listen-port = -1
|
||||
listen-port = 7667
|
||||
|
||||
# Port to listen on (TLS). Set -1 to not listen.
|
||||
#listen-port-tls = -1
|
||||
listen-port-tls = -1
|
||||
|
||||
listen-i2p = terrarium.i2p
|
||||
sam-address = 127.0.0.1:7656
|
||||
|
5
desc
Normal file
5
desc
Normal file
@@ -0,0 +1,5 @@
|
||||
terrarium is an IRC server with a focus on being small and understandable,
|
||||
originally forked from [horgh/catbox](https://github.com/horgh/catbox). The
|
||||
goal is to create an easy-to-configure I2P IRC server which is highly stable
|
||||
and secure, while retaining the ability to link with non-I2P IRC servers using
|
||||
TLS in order to bridge anonymous and non-anonymous chat.
|
73
index.html
Normal file
73
index.html
Normal file
@@ -0,0 +1,73 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>terrarium - IRC</title>
|
||||
<link rel="stylesheet" type="text/css" href ="/style.css" />
|
||||
</head>
|
||||
<body>
|
||||
<h1 id="terrarium"><img src="doc/terrarium-with-text.png" alt="terrarium" /></h1>
|
||||
<p><a href="https://travis-ci.org/eyedeekay/terrarium"><img src="https://travis-ci.org/eyedeekay/terrarium.svg" alt="Build Status" /></a> <a href="https://goreportcard.com/report/i2pgit.org/idk/terrarium"><img src="https://goreportcard.com/badge/i2pgit.org/idk/terrarium" alt="Go Report Card" /></a></p>
|
||||
<p>terrarium is an IRC server with a focus on being small and understandable, originally forked from <a href="https://github.com/horgh/catbox">horgh/catbox</a>. The goal is to create an easy-to-configure I2P IRC server which is highly stable and secure, while retaining the ability to link with non-I2P IRC servers using TLS in order to bridge anonymous and non-anonymous chat. For now, Bridged servers are not anonymous, this may change in the future as I evaluate the feasibility of outproxies or Tor.</p>
|
||||
<h1 id="features">Features</h1>
|
||||
<ul>
|
||||
<li>Server to server linking</li>
|
||||
<li>IRC operators</li>
|
||||
<li>Private (WHOIS shows no channels, LIST isn’t supported)</li>
|
||||
<li>Flood protection</li>
|
||||
<li>K: line style connection banning</li>
|
||||
<li>TLS</li>
|
||||
</ul>
|
||||
<p>terrarium implements enough of <a href="https://tools.ietf.org/html/rfc1459">RFC 1459</a> to be recognisable as IRC and be minimally functional. It will intentionally omit unnecessary features. Priority features are those which enable moderation and provide more flexible security.</p>
|
||||
<h1 id="plugin-installation-urls">Plugin Installation URL’s</h1>
|
||||
<p><a href="https://geti2p.net/en/docs/plugins">A guide to installing I2P plugins can be found on the I2P web site.</a></p>
|
||||
<h3 id="inside-i2p">Inside I2P</h3>
|
||||
<ul>
|
||||
<li><a href="http://idk.i2p/terrarium/terrarium-windows-amd64.su3">Windows (In-I2P)</a></li>
|
||||
<li><a href="http://idk.i2p/terrarium/terrarium-linux-amd64.su3">Linux (In-I2P)</a></li>
|
||||
</ul>
|
||||
<h3 id="outside-i2p">Outside I2P</h3>
|
||||
<ul>
|
||||
<li><a href="https://github.com/terrarium/blizzard/releases">Windows</a></li>
|
||||
<li><a href="https://github.com/terrarium/blizzard/releases">Linux</a></li>
|
||||
</ul>
|
||||
<h1 id="installation">Installation</h1>
|
||||
<ol type="1">
|
||||
<li>Clone the software from <a href="https://i2pgit.org/idk/terrarium">i2pgit.org</a> (<code>git clone https://i2pgit.org/idk/terrarium go/src/i2pgit.org/idk/terrarium && cd go/src/i2pgit.org/idk/terrarium</code>).</li>
|
||||
<li>Build from source (<code>go build</code>).</li>
|
||||
<li>Configure terrarium through config files. There are example configs in the <code>conf</code> directory. All settings are optional and have defaults.</li>
|
||||
<li>Run it, e.g. <code>./terrarium -conf terrarium.conf</code>. You might run it via systemd via a service such as:</li>
|
||||
</ol>
|
||||
<pre><code>[Service]
|
||||
ExecStart=/home/ircd/terrarium/terrarium -conf /home/ircd/terrarium/terrarium.conf
|
||||
Restart=always
|
||||
|
||||
[Install]
|
||||
WantedBy=default.target</code></pre>
|
||||
<h1 id="configuration">Configuration</h1>
|
||||
<h2 id="terrarium.conf">terrarium.conf</h2>
|
||||
<p>Global server settings.</p>
|
||||
<h2 id="opers.conf">opers.conf</h2>
|
||||
<p>IRC operators.</p>
|
||||
<h2 id="servers.conf">servers.conf</h2>
|
||||
<p>The servers to link with.</p>
|
||||
<h2 id="users.conf">users.conf</h2>
|
||||
<p>Privileges and hostname spoofs for users.</p>
|
||||
<p>The only privilege right now is flood exemption.</p>
|
||||
<h2 id="tls">TLS</h2>
|
||||
<p>A setup for a network might look like this:</p>
|
||||
<ul>
|
||||
<li>Give each server a certificate with 2 SANs: Its own hostname, e.g. server1.example.com, and the network hostname, e.g. irc.example.com.</li>
|
||||
<li>Set up irc.example.com with DNS round-robin listing each server’s IP.</li>
|
||||
<li>List each server by its own hostname in servers.conf.</li>
|
||||
</ul>
|
||||
<p>Clients connect to the network hostname and verify against it. Servers connect to each other by server hostname and verify against it.</p>
|
||||
<h2 id="i2p">I2P</h2>
|
||||
<p>An example I2P configuration can be found in:</p>
|
||||
<p><code>conf/catbox-i2p.conf</code></p>
|
||||
<p>That’s all the docs I have for now</p>
|
||||
<h1 id="why-the-name">Why the name?</h1>
|
||||
<p>It was forked from an IRC server called catbox which had a focus on simplicity and understandability. It now has the ability to connect to other IRC servers through I2P Tunnels. Clearnet is to I2P Tunnels is sort of like Catbox is to Terrarium.</p>
|
||||
<h1 id="logo">Logo</h1>
|
||||
<p>terrarium logo (c) 2017 Bee</p>
|
||||
</body>
|
||||
</html>
|
29
main.go
29
main.go
@@ -6,6 +6,7 @@ import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"math/rand"
|
||||
"net"
|
||||
"os"
|
||||
"os/signal"
|
||||
@@ -17,10 +18,8 @@ import (
|
||||
|
||||
"github.com/horgh/irc"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
import (
|
||||
"github.com/eyedeekay/sam3/helper"
|
||||
sam "github.com/eyedeekay/sam3/helper"
|
||||
)
|
||||
|
||||
// Catbox holds the state for this local server.
|
||||
@@ -206,7 +205,18 @@ const ExcessFloodThreshold = 50
|
||||
// from a user.
|
||||
const ChanModesPerCommand = 4
|
||||
|
||||
func randString() string {
|
||||
var letterRunes = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")
|
||||
n := 3
|
||||
b := make([]rune, n)
|
||||
for i := range b {
|
||||
b[i] = letterRunes[rand.Intn(len(letterRunes))]
|
||||
}
|
||||
return string(b)
|
||||
}
|
||||
|
||||
func NewCatbox(configFile string) (*Catbox, error) {
|
||||
rand.Seed(time.Now().UnixNano())
|
||||
cb := Catbox{
|
||||
ConfigFile: configFile,
|
||||
LocalClients: make(map[uint64]*LocalClient),
|
||||
@@ -230,6 +240,9 @@ func NewCatbox(configFile string) (*Catbox, error) {
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("configuration problem: %s", err)
|
||||
}
|
||||
if cfg.ServerName == "irc.terrarium.i2p" {
|
||||
cfg.ServerName = randString() + ".dirt.i2p"
|
||||
}
|
||||
cb.Config = cfg
|
||||
|
||||
if cb.Config.ListenPortTLS != "-1" || cb.Config.CertificateFile != "" ||
|
||||
@@ -359,18 +372,18 @@ func (cb *Catbox) Start(listenFD int) error {
|
||||
|
||||
// I2P Listener with TLS
|
||||
if cb.Config.ListenI2PTLS != "-1" {
|
||||
ln, err := sam.I2PListener(cb.Config.ListenI2P, cb.Config.SAMAddress, cb.Config.ListenI2P)
|
||||
ln, err := sam.I2PListener(cb.Config.ListenI2PTLS, cb.Config.SAMAddress, cb.Config.ListenI2PTLS)
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to listen (I2P): %s", err)
|
||||
}
|
||||
tlsln := tls.NewListener(ln, cb.TLSConfig)
|
||||
cb.I2PListenerTLS = tlsln
|
||||
err = ioutil.WriteFile(cb.Config.ListenI2P+".i2paddresshelper", []byte("http://"+cb.Config.ListenI2P+"?i2paddresshelper="+cb.I2PListener.Addr().String()), 0644)
|
||||
err = ioutil.WriteFile(cb.Config.ListenI2PTLS+".tls.i2paddresshelper", []byte("http://"+cb.Config.ListenI2PTLS+"?i2paddresshelper="+cb.I2PListener.Addr().String()), 0644)
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to write I2P addresshelper link to file: %s", err)
|
||||
}
|
||||
if strings.HasSuffix(cb.Config.ServerName, ".i2p") {
|
||||
err = ioutil.WriteFile(cb.Config.ServerName+".i2paddresshelper", []byte("http://"+cb.Config.ServerName+"?i2paddresshelper="+cb.I2PListener.Addr().String()), 0644)
|
||||
err = ioutil.WriteFile(cb.Config.ServerName+".tls.i2paddresshelper", []byte("http://"+cb.Config.ServerName+"?i2paddresshelper="+cb.I2PListener.Addr().String()), 0644)
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to write I2P addresshelper link to file: %s", err)
|
||||
}
|
||||
@@ -388,7 +401,7 @@ func (cb *Catbox) Start(listenFD int) error {
|
||||
// Catch SIGUSR1 and restart.
|
||||
signalChan := make(chan os.Signal)
|
||||
signal.Notify(signalChan, syscall.SIGHUP)
|
||||
signal.Notify(signalChan, syscall.SIGUSR1)
|
||||
signal.Notify(signalChan, syscall.SIGINT)
|
||||
|
||||
cb.WG.Add(1)
|
||||
go func() {
|
||||
@@ -401,7 +414,7 @@ func (cb *Catbox) Start(listenFD int) error {
|
||||
cb.newEvent(Event{Type: RehashEvent})
|
||||
break
|
||||
}
|
||||
if sig == syscall.SIGUSR1 {
|
||||
if sig == syscall.SIGINT {
|
||||
log.Printf("Received SIGUSR1 signal, restarting")
|
||||
cb.newEvent(Event{Type: RestartEvent})
|
||||
break
|
||||
|
Reference in New Issue
Block a user