// NewWithServer wraps an existing http.Server.
770295
func NewWithServer(s *http.Server) *Server {
	return &Server{
		Server:      s,
		KillTimeOut: 10 * time.Second,
	}
}
385980
func New() *http.Client {
	cli := cleanhttp.DefaultPooledClient()
	cli.Transport = &userAgentRoundTripper{
		userAgent: UserAgentString(),
		inner:     cli.Transport,
	}
	return cli
}
72070
func New(conf *config.AppConfig) *server {

	if conf.Insecure {
		acl.SetSkipAuth()
	}

	// create new storage handler
	if err := storage.New(conf.Storage); err != nil {
		log.Fatalf("Could not create storage handler => %s", err.Error())
	}

	// create new locker handler
	if err := locker.New(conf.Locker); err != nil {
		log.Fatalf("Could not create locker handler => %s", err.Error())
	}

	// load ca clients
	client.New(conf.Clients)
	providers.New(conf.Payment)

	lis, err := net.Listen("tcp", conf.Address)
	if err != nil {
		log.Fatalf("failed to listen: %v", err)
	}
	log.Infof("Listening on %s", conf.Address)
	return &server{
		listener:   lis,
		grpcServer: newGRPCServer(conf),
	}
}
174713
func New(mws ...Middleware) *Router {
	r := &Router{
		parent:           nil,
		hostrm:           newHostMatcher(),
		middlewares:      Middlewares{},
		namedMiddlewares: make(map[string]Middlewares),
		pool:             newCtxPool(),
	}
	r.Use(mws...)
	r.Configure(
		WithLogger(lionLogger),
		WithServer(&http.Server{
			ReadTimeout:  5 * time.Second,
			WriteTimeout: 10 * time.Second,
		}),
	)
	return r
}
94829
func NewHandlerWith(eng *stats.Engine, h http.Handler) http.Handler {
	return &handler{
		handler: h,
		eng:     eng,
	}
}
1321937
func New(ctx context.Context, ds models.Datastore, mq models.MessageQueue, apiURL string, opts ...ServerOption) *Server {
	metricLogger := runner.NewMetricLogger()
	funcLogger := runner.NewFuncLogger()

	rnr, err := runner.New(ctx, funcLogger, metricLogger)
	if err != nil {
		logrus.WithError(err).Fatalln("Failed to create a runner")
		return nil
	}

	tasks := make(chan task.Request)
	s := &Server{
		Runner:    rnr,
		Router:    gin.New(),
		Datastore: ds,
		MQ:        mq,
		hotroutes: routecache.New(cacheSize),
		tasks:     tasks,
		Enqueue:   DefaultEnqueue,
		apiURL:    apiURL,
	}

	s.Router.Use(prepareMiddleware(ctx))
	s.bindHandlers(ctx)
	s.setupMiddlewares()

	for _, opt := range opts {
		opt(s)
	}
	return s
}
920776
func New(server ...string) (*mc.Client, error) {
	ks := &JavaServerSelector{}

	for _, s := range server {
		err := ks.AddServer(s)
		if err != nil {
			return nil, err
		}
	}

	return mc.NewFromSelector(ks), nil
}
1018516
func (s *LoadBalancerSetting) AddServer(server *LoadBalancerServer) {
	if s.Servers == nil {
		s.Servers = []*LoadBalancerServer{}
	}
	s.Servers = append(s.Servers, server)
}
659108
func New() *Host {
	connectionString := defaultDatabaseServer + defaultDatabaseName
	if !strings.HasSuffix(defaultDatabaseServer, "/") {
		connectionString = defaultDatabaseServer + "/" + defaultDatabaseName
	}
	return NewHost(connectionString)
}
537422
func New(c ServerConfig) (*Server, error) {
	// Check and make sure we everything we need to build a forwarding node.
	err := c.CheckDefaults()
	if err != nil {
		return nil, trace.Wrap(err)
	}

	// Build a pipe connection to hook up the client and the server. we save both
	// here and will pass them along to the context when we create it so they
	// can be closed by the context.
	serverConn, clientConn := utils.DualPipeNetConn(c.SrcAddr, c.DstAddr)
	if err != nil {
		return nil, trace.Wrap(err)
	}

	s := &Server{
		log: logrus.WithFields(logrus.Fields{
			trace.Component: teleport.ComponentForwardingNode,
			trace.ComponentFields: map[string]string{
				"src-addr": c.SrcAddr.String(),
				"dst-addr": c.DstAddr.String(),
			},
		}),
		id:              uuid.New(),
		targetConn:      c.TargetConn,
		serverConn:      utils.NewTrackingConn(serverConn),
		clientConn:      clientConn,
		userAgent:       c.UserAgent,
		hostCertificate: c.HostCertificate,
		authClient:      c.AuthClient,
		auditLog:        c.AuthClient,
		authService:     c.AuthClient,
		sessionServer:   c.AuthClient,
		dataDir:         c.DataDir,
		clock:           c.Clock,
	}

	// Set the ciphers, KEX, and MACs that the in-memory server will send to the
	// client in its SSH_MSG_KEXINIT.
	s.ciphers = c.Ciphers
	s.kexAlgorithms = c.KEXAlgorithms
	s.macAlgorithms = c.MACAlgorithms

	s.sessionRegistry, err = srv.NewSessionRegistry(s)
	if err != nil {
		return nil, trace.Wrap(err)
	}

	// Common auth handlers.
	s.authHandlers = &srv.AuthHandlers{
		Entry: logrus.WithFields(logrus.Fields{
			trace.Component:       teleport.ComponentForwardingNode,
			trace.ComponentFields: logrus.Fields{},
		}),
		Server:      s,
		Component:   teleport.ComponentForwardingNode,
		AuditLog:    c.AuthClient,
		AccessPoint: c.AuthClient,
	}

	// Common term handlers.
	s.termHandlers = &srv.TermHandlers{
		SessionRegistry: s.sessionRegistry,
	}

	// Create a close context that is used internally to signal when the server
	// is closing and for any blocking goroutines to unblock.
	s.closeContext, s.closeCancel = context.WithCancel(context.Background())

	return s, nil
}
1114464
func New(c *Options) (s *Server) {
	c.ensure()
	s = &Server{
		cfg:    c,
		Logger: log.Get(PkgName),
		Binder: new(binder),
		router: router.New(router.Options{}),
		routes: make(map[string]router.Route),
	}
	s.stdLogger = slog.New(s.Logger, "web > ", 0)
	s.ctxPool = newContextPool(s)
	return s
}
242307
func NewHasServerKeys(g *libkb.GlobalContext) *HasServerKeys {
	return &HasServerKeys{
		Contextified: libkb.NewContextified(g),
	}
}
27100
func NewMockServer(ctrl *gomock.Controller) *MockServer {
	mock := &MockServer{ctrl: ctrl}
	mock.recorder = &MockServerMockRecorder{mock}
	return mock
}
456124
func NewRequestServer(rwc io.ReadWriteCloser, h Handlers) *RequestServer {
	svrConn := &serverConn{
		conn: conn{
			Reader:      rwc,
			WriteCloser: rwc,
		},
	}
	return &RequestServer{
		serverConn:   svrConn,
		Handlers:     h,
		pktMgr:       newPktMgr(svrConn),
		openRequests: make(map[string]*Request),
	}
}
96179
func (s *GrpcServer) StartWithServer(server func() *grpc.Server) error {
	s.lock.Lock()
	defer s.lock.Unlock()

	if server == nil {
		return fmt.Errorf("Server function has not been defined")
	}

	if s.running {
		return fmt.Errorf("Server already running")
	}

	s.server = server()

	// Start listening for requests
	s.startGrpcService()
	return nil
}
836138
func New(ctx context.Context, h HandlerC) http.Handler {
        return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
                h.ServeHTTPC(ctx, w, r.WithContext(ctx))
        })
}
1102816
func New(ip net.IP, l leasepool.LeasePool, options ...func(*Server) error) (*Server, error) {
	s := Server{
		ip:             ip,
		defaultGateway: ip,
		dnsServers:     []net.IP{net.IPv4(208, 67, 222, 222), net.IPv4(208, 67, 220, 220)}, //OPENDNS
		subnetMask:     net.IPv4(255, 255, 255, 0),
		leaseDuration:  24 * time.Hour,
		leasePool:      l,
		laddr:          net.UDPAddr{IP: net.IPv4(0, 0, 0, 0), Port: 67},
		raddr:          net.UDPAddr{IP: net.IPv4bcast, Port: 68},
	}

	err := s.setOptions(options...)
	if err != nil {
		return &s, err
	}

	return &s, err
}