<commit_before>package unfiltered.jetty

import org.eclipse.jetty.server.Connector
import org.eclipse.jetty.server.bio.SocketConnector
import org.eclipse.jetty.server.ssl.SslSocketConnector
import org.eclipse.jetty.util.ssl.SslContextFactory

/** Convenience methods for attaching connector providers. */
trait ConnectorBuilder {
  val allInterfacesHost = "0.0.0.0"
  val localInterfaceHost = "127.0.0.1"
  val defaultHttpPort = 80
  val defaultHttpsPort = 443
  val defaultKeystorePathProperty = "jetty.ssl.keyStore"
  val defaultKeystorePasswordProperty = "jetty.ssl.keyStorePassword"

  def attach(connector: ConnectorProvider): Server

  def http(port: Int = defaultHttpPort, host: String = allInterfacesHost) = attach(
    SocketConnectorProvider(port, host)
  )

  def local(port: Int): Server = attach(
    SocketConnectorProvider(port, localInterfaceHost)
  )

  def anylocal: Server = local(unfiltered.util.Port.any)

  def https(
    port: Int = defaultHttpsPort,
    host: String = allInterfacesHost,
    keyStorePath: String,
    keyStorePassword: String
  ) = attach(
    SslSocketConnectorProvider(
      port,
      host,
      SslContextProvider.Simple(
        keyStorePath = keyStorePath,
        keyStorePassword = keyStorePassword
      )
    )
  )

  def httpsSysProperties(
    port: Int = defaultHttpsPort,
    host: String = allInterfacesHost,
    keyStorePathProperty: String = defaultKeystorePathProperty,
    keyStorePasswordProperty: String = defaultKeystorePasswordProperty<commit_msg>define local in terms of http<commit_after>package unfiltered.jetty

import org.eclipse.jetty.server.Connector
import org.eclipse.jetty.server.bio.SocketConnector
import org.eclipse.jetty.server.ssl.SslSocketConnector
import org.eclipse.jetty.util.ssl.SslContextFactory

/** Convenience methods for attaching connector providers. */
trait ConnectorBuilder {
  val allInterfacesHost = "0.0.0.0"
  val localInterfaceHost = "127.0.0.1"
  val defaultHttpPort = 80
  val defaultHttpsPort = 443
  val defaultKeystorePathProperty = "jetty.ssl.keyStore"
  val defaultKeystorePasswordProperty = "jetty.ssl.keyStorePassword"

  def attach(connector: ConnectorProvider): Server

  def http(port: Int = defaultHttpPort, host: String = allInterfacesHost) = attach(
    SocketConnectorProvider(port, host)
  )

  def local(port: Int): Server =
    http(port, localInterfaceHost)

  def anylocal: Server = local(unfiltered.util.Port.any)

  def https(
    port: Int = defaultHttpsPort,
    host: String = allInterfacesHost,
    keyStorePath: String,
    keyStorePassword: String
  ) = attach(
    SslSocketConnectorProvider(
      port,
      host,
      SslContextProvider.Simple(
        keyStorePath = keyStorePath,
        keyStorePassword = keyStorePassword
      )
    )
  )

  def httpsSysProperties(
    port: Int = defaultHttpsPort,
    host: String = allInterfacesHost,
    keyStorePathProperty: String = defaultKeystorePathProperty,
    keyStorePasswordProperty: String = defaultKeystorePasswordProperty
{'fraction_non_alphanumeric': 0.08164619980086293, 'fraction_numerical': 0.009956853634251576, 'mean_word_length': 4.196551724137931, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 4, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4212559', 'n_tokens_mistral': 926, 'n_tokens_neox': 893, 'n_words': 195}