aboutsummaryrefslogblamecommitdiff
path: root/main.go
blob: 8d6b797b8fdba1a711fcb457782332cde672324c (plain) (tree)
1
2
3
4
5
6

            

               

             






























                                                                           
                                                                                                              






                                                                                           
package main

import (
	"bufio"
	"net"
	"os"

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

const VERSION = "lindenii-maild v0.0.0"

func main() {
	config_file, err := os.Open("maild.scfg")
	if err != nil {
		panic(err)
	}

	err = scfg.NewDecoder(bufio.NewReader(config_file)).Decode(&config)
	if err != nil {
		panic(err)
	}

	listener, err := net.Listen("tcp", ":25")
	if err != nil {
		panic(err)
	}
	defer listener.Close()

	for {
		conn, err := listener.Accept()
		if err != nil {
			panic(err)
		}

		go func() {
			err := handle_incoming_server_connection(bufio.NewReader(conn), bufio.NewWriter(conn))
			if err != nil {
				clog.Error("connection handler returned error", "err", err)
			}
		}()
	}

}