Пример #1
0
func (s *Server) onConn(c net.Conn) {
	defer s.wg.Done()

	h := newHandler(s)
	conn, err := server.NewConn(c, s.user, s.password, h)
	if err != nil {
		log.Errorf("new connection error %s", err.Error())
		c.Close()
		return
	}

	h.conn = conn

	for {
		select {
		case <-s.quit:
			// Proxy quited, close conection
			conn.Close()
			return
		default:
			break
		}

		err = conn.HandleCommand()
		if err != nil {
			log.Errorf("handle command error %s", err.Error())
			return
		}
	}
}
Пример #2
0
func handleTCPConn(c net.Conn) {
	// Create a connection with user root and an empty passowrd
	conn, err := mysqlserver.NewConn(c, "root", "", vitessproxy.VitessHandler{vitessdb})
	if err != nil {
		log.Println(err)
	}
	for {
		conn.HandleCommand()
	}
}