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

            

               
                
              
            
             

                                                      




                                       
                                                                                                      
                                        
















                                                 
                                                                                                                                          
                                                                  



                                                                                           
 
package main

import (
	"bufio"
	"errors"
	"flag"
	"io"
	"net"

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

const VERSION = "lindenii-maild v0.0.0"

func main() {
	config_path := flag.String("config", "/etc/lindenii/maild.scfg", "path to configuration file")
	err := load_config(*config_path)
	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.NewReadWriter(bufio.NewReader(conn), bufio.NewWriter(conn)), &conn)
			if err != nil && !errors.Is(err, io.EOF) {
				clog.Error("connection handler returned error", "err", err)
			}
		}()
	}
}