Exemplo n.º 1
0
func main() {
	log.Println("[+] Starting GHN server...")
	db.Connect()
	addr, err := net.ResolveTCPAddr("tcp", ":9999")
	ghnews.HandleFatal(err, "Address resolution")
	log.Println("[=] Resolved", addr)
	listen, err := net.ListenTCP("tcp", addr)
	ghnews.HandleFatal(err, "TCP binding")
	defer func() {
		listen.Close()
		log.Println("[>] Listen connection closed")
		db.Close()
	}()
	nntpserver := nntpserver.NewServer(&backendInstance)
	for {
		connection, err := listen.AcceptTCP()
		ghnews.HandleFatal(err, "Accept connection")
		go nntpserver.Process(connection)
	}
}
Exemplo n.º 2
0
func Start(port int64, addr string) {
	http.HandleFunc("/", aboutHandle)
	http.HandleFunc("/comment", commentHandle)
	http.HandleFunc("/issue", issueHandle)
	ghnews.HandleFatal(http.ListenAndServe(fmt.Sprintf("%s:%d", addr, port), nil))
}
Exemplo n.º 3
0
func Connect() {
	r, err := redis.Dial("tcp", ":6379")
	ghnews.HandleFatal(err, "Redis connection")
	redisClient = r
}