aboutsummaryrefslogtreecommitdiff
path: root/main.go
blob: 86ffa6af0007d8a1753225f6eeac6dde311dc5fc (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package main

import (
	"net"

	"go.lindenii.runxiyu.org/lindenii-common/clog"
)

const VERSION = "MeseIRCd-0.0.0"

func main() {
	// TODO: Parse config and add TLS

	self = &server_t{
		conn: nil,
		sid:  0,
		name: "irc.runxiyu.org",
	}

	listener, err := net.Listen("tcp", ":6667")
	if err != nil {
		clog.Fatal(1, "listen", "error", err)
	}
	defer listener.Close()

	for {
		conn, err := listener.Accept()
		if err != nil {
			clog.Fatal(1, "accept", "error", err)
		}
		go func() {
			defer conn.Close()
			client, err := new_local_client(&conn)
			if err != nil {
				clog.Error("new_local_client", "error", err, "conn", &conn)
			}
			defer client.teardown()
			client.handle_connection()
		}()
	}
}