anonircd/anonircd.go

70 lines
1.9 KiB
Go
Raw Normal View History

2016-09-02 05:54:54 +00:00
// AnonIRCd
// https://github.com/tslocum/anonircd
// Written by Trevor 'tee' Slocum <tslocum@gmail.com>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
2016-08-26 05:50:24 +00:00
package main
import (
"sync"
"math/rand"
"time"
2016-09-01 06:35:27 +00:00
2016-09-02 07:49:36 +00:00
"github.com/BurntSushi/toml"
2016-09-02 05:54:54 +00:00
irc "gopkg.in/sorcix/irc.v2"
2016-09-02 07:49:36 +00:00
"log"
"os"
2016-09-02 05:54:54 +00:00
)
2016-08-26 05:50:24 +00:00
var anonymous = irc.Prefix{"Anonymous", "Anon", "IRC"}
2016-09-02 05:54:54 +00:00
var anonirc = irc.Prefix{Name:"AnonIRC"}
2016-08-31 08:44:40 +00:00
const motd = `
_|_| _|_|_| _|_|_| _|_|_|
_| _| _|_|_| _|_| _|_|_| _| _| _| _|
_|_|_|_| _| _| _| _| _| _| _| _|_|_| _|
_| _| _| _| _| _| _| _| _| _| _| _|
_| _| _| _| _|_| _| _| _|_|_| _| _| _|_|_|
`
2016-09-02 05:54:54 +00:00
const letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
2016-08-26 05:50:24 +00:00
2016-09-02 07:49:36 +00:00
type Config struct {
SSLCert string
SSLKey string
}
2016-08-26 05:50:24 +00:00
func randomIdentifier() string {
b := make([]byte, 10)
for i := range b {
b[i] = letters[rand.Intn(len(letters))]
}
return string(b)
}
2016-09-02 05:54:54 +00:00
func main() {
2016-08-31 08:44:40 +00:00
rand.Seed(time.Now().UTC().UnixNano())
2016-09-02 07:49:36 +00:00
var config Config
if _, err := os.Stat("anonircd.conf"); err == nil {
if _, err := toml.DecodeFile("anonircd.conf", &config); err != nil {
log.Fatalf("Failed to read anonircd.conf: %v", err)
}
}
server := Server{&config, time.Now().Unix(), make(map[string]*Client), make(map[string]*Channel), new(sync.RWMutex)}
2016-09-01 06:35:27 +00:00
server.listen()
}