Skip to content
This repository has been archived by the owner on Mar 22, 2023. It is now read-only.

Commit

Permalink
adds ALPN support
Browse files Browse the repository at this point in the history
  • Loading branch information
shamsimam committed Mar 19, 2019
1 parent 82b5e2a commit 5104f1f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
8 changes: 4 additions & 4 deletions project.clj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
:license {:name "Eclipse Public License"
:url "http://www.eclipse.org/legal/epl-v10.html"}
:dependencies [[org.clojure/clojure "1.8.0"]
[org.mortbay.jetty.alpn/alpn-boot "8.1.3.v20150130"
[org.mortbay.jetty.alpn/alpn-boot "8.1.13.v20181017"
:prepend true]
[org.clojure/core.async "0.2.374"]
[org.eclipse.jetty/jetty-server ~jetty-version]
Expand All @@ -14,16 +14,16 @@
[org.eclipse.jetty.websocket/websocket-servlet ~jetty-version]
[org.eclipse.jetty.websocket/websocket-client ~jetty-version]
[org.eclipse.jetty/jetty-client ~jetty-version]
[org.eclipse.jetty/jetty-alpn-server ~jetty-version]
[org.eclipse.jetty/jetty-alpn-openjdk8-client ~jetty-version]
[org.eclipse.jetty/jetty-alpn-openjdk8-server ~jetty-version]
[org.eclipse.jetty.alpn/alpn-api "1.1.3.v20160715"]
[org.eclipse.jetty.http2/http2-common ~jetty-version]
[org.eclipse.jetty.http2/http2-http-client-transport ~jetty-version]
[org.eclipse.jetty.http2/http2-client ~jetty-version]
;; [org.eclipse.jetty/jetty-alpn-client ~jetty-version]
[cheshire "5.5.0"]]

:plugins [[info.sunng/lein-bootclasspath-deps "0.3.0"]]
:boot-dependencies [[org.mortbay.jetty.alpn/alpn-boot "8.1.3.v20150130"
:boot-dependencies [[org.mortbay.jetty.alpn/alpn-boot "8.1.13.v20181017"
:prepend true]]

:repositories {"sonatype" {:url "http://oss.sonatype.org/content/repositories/releases"
Expand Down
14 changes: 10 additions & 4 deletions src/clj/qbits/jet/server.clj
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ Derived from ring.adapter.jetty"
[clojure.core.async :as async]
[qbits.jet.websocket :refer :all])
(:import
;; (org.eclipse.jetty.alpn.server
;; ALPNServerConnectionFactory)
(org.eclipse.jetty.alpn.server
ALPNServerConnectionFactory)
(org.eclipse.jetty.server
Connector
Handler
Expand All @@ -20,6 +20,8 @@ Derived from ring.adapter.jetty"
ConnectionFactory)
(org.eclipse.jetty.http
HttpCompliance)
(org.eclipse.jetty.http2
HTTP2Cipher)
(org.eclipse.jetty.http2.server
HTTP2ServerConnectionFactory
HTTP2CServerConnectionFactory)
Expand Down Expand Up @@ -124,7 +126,8 @@ Derived from ring.adapter.jetty"
(defn- ^SslContextFactory ssl-context-factory
"Creates a new SslContextFactory instance from a map of options."
[{:as options
:keys [keystore keystore-type key-password client-auth
:keys [client-auth http2?
keystore keystore-type key-password
truststore trust-password truststore-type]}]
(let [context (SslContextFactory.)]
(if (string? keystore)
Expand All @@ -145,6 +148,8 @@ Derived from ring.adapter.jetty"
:need (.setNeedClientAuth context true)
:want (.setWantClientAuth context true)
nil)
(when http2?
(.setCipherComparator context HTTP2Cipher/COMPARATOR))
context))

(defn ^HttpCompliance any->parser-compliance
Expand Down Expand Up @@ -239,7 +244,8 @@ supplied options:
(ssl-context-factory options)
^"[Lorg.eclipse.jetty.server.ConnectionFactory;"
(into-array ConnectionFactory
(cond-> [http-connection-factory]
(cond-> [(ALPNServerConnectionFactory. ^String (cond->> "http/1.1" http2? (str "h2,")))
http-connection-factory]
http2? (conj (HTTP2ServerConnectionFactory. http-conf)))))
(.setPort (or ssl-port port 443))
(.setHost host)
Expand Down

0 comments on commit 5104f1f

Please sign in to comment.