6358ebe50a
--HG-- branch : nmdc-ircfrontend
43 lines
911 B
Go
43 lines
911 B
Go
package main
|
|
|
|
import (
|
|
"flag"
|
|
"libnmdc"
|
|
"log"
|
|
"net"
|
|
)
|
|
|
|
var (
|
|
ircAddress = flag.String("bind", ":6697", "The address:port to bind to and listen for clients on")
|
|
dcAddress = flag.String("upstream", "127.0.0.1:411", "Upstream NMDC server")
|
|
serverName = flag.String("servername", "nmdc-ircfrontend", "Server name displayed to clients")
|
|
)
|
|
|
|
func main() {
|
|
|
|
flag.Parse()
|
|
|
|
log.Printf("Listening on '%s'...", *ircAddress)
|
|
|
|
listener, err := net.Listen("tcp", *ircAddress)
|
|
if err != nil {
|
|
log.Printf(err.Error())
|
|
return
|
|
}
|
|
|
|
for {
|
|
conn, err := listener.Accept()
|
|
if err != nil {
|
|
log.Printf("Error accepting connection (%s)", err.Error())
|
|
continue
|
|
}
|
|
|
|
// Spin up an IRC server for the new user.
|
|
// The upstream connection doesn't get launched until we hear a nick
|
|
// from the irc client
|
|
|
|
server := NewServer(*serverName, libnmdc.HubAddress(*dcAddress), conn)
|
|
go server.RunWorker()
|
|
}
|
|
}
|