func New(containerCli container.Cli, options config.ServerConfig) (*Server, error) {

	var originChekcer func(r *http.Request) bool
	if options.WSOrigin != "" {
		matcher, err := regexp.Compile(options.WSOrigin)
		if err != nil {
			return nil, fmt.Errorf("failed to compile regular expression of Websocket Origin: %s", options.WSOrigin)
		}
		originChekcer = func(r *http.Request) bool {
			return matcher.MatchString(r.Header.Get("Origin"))
		}
	}

	h, _ := os.Hostname()
	return &Server{
		options:      options,
		containerCli: containerCli,
		execs:        make(map[string]string, 500),
		masters:      make(map[string]*types.MasterTTY, 50),
		hostname:     h,

		upgrader: &websocket.Upgrader{
			ReadBufferSize:  1024,
			WriteBufferSize: 1024,
			Subprotocols:    webtty.Protocols,
			CheckOrigin:     originChekcer,
		},
	}, nil
}
// New creates a new instance of Server.
// Server will use the New() of the factory provided to handle each request.
New creates a new instance of Server.
Server will use the New() of the factory provided to handle each request.
// New creates a new instance of Server . // Server will use the New () of the factory provided to handle each request .
func New(containerCli container.Cli, options config.ServerConfig) (*Server, error) {
	var originChekcer func(r *http.Request) bool
	if options.WSOrigin != "" {
		matcher, err := regexp.Compile(options.WSOrigin)
		if err != nil {
			return nil, fmt.Errorf("failed to compile regular expression of Websocket Origin: %s", options.WSOrigin)
		}
		originChekcer = func(r *http.Request) bool {
			return matcher.MatchString(r.Header.Get("Origin"))
		}
	}
	h, _ := os.Hostname()
	return &Server{
		options:      options,
		containerCli: containerCli,
		execs:        make(map[string]string, 500),
		masters:      make(map[string]*types.MasterTTY, 50),
		hostname:     h,
		upgrader: &websocket.Upgrader{
			ReadBufferSize:  1024,
			WriteBufferSize: 1024,
			Subprotocols:    webtty.Protocols,
			CheckOrigin:     originChekcer,
		},
	}, nil
}
func New ( containerCli container . Cli , options config . ServerConfig ) ( * Server , error ) { var originChekcer func ( r * http . Request ) bool if options . WSOrigin != " " { matcher , err := regexp . Compile ( options . WSOrigin ) if err != nil { return nil , fmt . Errorf ( " " , options . WSOrigin ) } originChekcer = func ( r * http . Request ) bool { return matcher . MatchString ( r . Header . Get ( " " ) ) } } h , _ := os . Hostname ( ) return & Server { options : options , containerCli : containerCli , execs : make ( map [ string ] string , 500 ) , masters : make ( map [ string ] * types . MasterTTY , 50 ) , hostname : h , upgrader : & websocket . Upgrader { ReadBufferSize : 1024 , WriteBufferSize : 1024 , Subprotocols : webtty . Protocols , CheckOrigin : originChekcer , } , } , nil }
New creates a new instance of Server.
New creates a new instance of Server .