func ParsingHandler(serverConn, clientConn net.Conn) error { log.Printf("Proxying new connection from %v", clientConn.RemoteAddr()) s2cLog := util.NewLogger(fmt.Sprintf("%s->%s", serverConn.RemoteAddr(), clientConn.RemoteAddr())) c2sLog := util.NewLogger(fmt.Sprintf("%s->%s", clientConn.RemoteAddr(), serverConn.RemoteAddr())) go parser(io.TeeReader(serverConn, clientConn), serverConn, s2cLog) go parser(io.TeeReader(clientConn, serverConn), clientConn, c2sLog) return nil }
func (srv *Service) SetConfig(cfg *services.WebConfig) error { srv.lock.Lock() defer srv.lock.Unlock() if cfg.Addr != srv.cfg.Addr { if cfg.Addr == "" { return errors.New("no address specified - refusing to shut down web service") } l, err := net.Listen("tcp", cfg.Addr) if err != nil { return err } if srv.listener != nil { srv.listener.Close() } srv.listener = l go runServer(srv.listener, &http.Server{ Handler: httplog.CommonLogHandler(util.NewLogger(""), httplog.CommonLogFormat, srv.handler), ReadTimeout: 10 * time.Second, WriteTimeout: 10 * time.Second, MaxHeaderBytes: 64 * 1024, }, cfg.OpenInBrowser) } srv.cfg = *cfg return nil }
func NewService(manager *connmgr.ConnManager) *Service { srv := &Service{ log: util.NewLogger("muxserver: "), manager: manager, newMuxConn: make(chan frames.ChannelDialer), badMuxConn: make(chan frames.ChannelDialer), newClientConn: make(chan net.Conn), } srv.muxListener = netutil.NewListenDispatcher( func(muxConn net.Conn) { go srv.negotiateNewMuxConn(muxConn) }, func(listenErr error) { srv.log.Printf("Error listening for mux clients: %v", listenErr) }, func(acceptErr error) { srv.log.Printf("Error accepting to accept mux client: %v", acceptErr) }) srv.clientListener = netutil.NewListenDispatcher( func(clientConn net.Conn) { srv.newClientConn <- clientConn }, func(listenErr error) { srv.log.Printf("Error listening for Artemis clients: %v", listenErr) }, func(acceptErr error) { srv.log.Printf("Error accepting Artemis client: %v", acceptErr) }) go srv.muxMatcher() return srv }
func NewService(manager *connmgr.ConnManager) *Service { return &Service{ manager: manager, log: util.NewLogger("muxclient: "), } }