// runTransparentServer transparently intercepts connections, listening at addr.
runTransparentServer transparently intercepts connections, listening at addr.
// runTransparentServer transparently intercepts connections listening at addr .
func runTransparentServer(addr string) error {
	ln, err := net.Listen("tcp", addr)
	if err != nil {
		return err
	}
	go func() {
		<-shutdownChan
		ln.Close()
	}()
	ln = tcpKeepAliveListener{ln.(*net.TCPListener)}
	var tempDelay time.Duration
	for {
		conn, err := ln.Accept()
		if err != nil {
			if ne, ok := err.(net.Error); ok && ne.Temporary() {
				if tempDelay == 0 {
					tempDelay = 5 * time.Millisecond
				} else {
					tempDelay *= 2
				}
				if max := 1 * time.Second; tempDelay > max {
					tempDelay = max
				}
				log.Printf("Accept error: %v; retrying in %v", err, tempDelay)
				time.Sleep(tempDelay)
				continue
			}
			return err
		}
		go func() {
			user, _, _ := net.SplitHostPort(conn.RemoteAddr().String())
			serverAddr, err := realServerAddress(conn)
			if err != nil || isLocalAddress(serverAddr) {
				SSLBump(conn, "", user, "", nil)
				return
			}
			SSLBump(conn, serverAddr.String(), user, "", nil)
		}()
	}
	panic("unreachable")
}
func runTransparentServer ( addr string ) error { ln , err := net . Listen ( " " , addr ) if err != nil { return err } go func ( ) { <- shutdownChan ln . Close ( ) } ( ) ln = tcpKeepAliveListener { ln . ( * net . TCPListener ) } var tempDelay time . Duration for { conn , err := ln . Accept ( ) if err != nil { if ne , ok := err . ( net . Error ) ; ok && ne . Temporary ( ) { if tempDelay == 0 { tempDelay = 5 * time . Millisecond } else { tempDelay *= 2 } if max := 1 * time . Second ; tempDelay > max { tempDelay = max } log . Printf ( " " , err , tempDelay ) time . Sleep ( tempDelay ) continue } return err } go func ( ) { user , _ , _ := net . SplitHostPort ( conn . RemoteAddr ( ) . String ( ) ) serverAddr , err := realServerAddress ( conn ) if err != nil || isLocalAddress ( serverAddr ) { SSLBump ( conn , " " , user , " " , nil ) return } SSLBump ( conn , serverAddr . String ( ) , user , " " , nil ) } ( ) } panic ( " " ) }
runTransparentServer transparently intercepts connections, listening at addr.
runTransparentServer transparently intercepts connections listening at addr .
// We can't get the original address of the connnection; maybe it was intercepted // remotely or by an unsupported firewall. But we'll proceed and hope it has Server // Name Indication.