|
12 | 12 | [puppetlabs.pcp.client :as pcp-client] |
13 | 13 | [puppetlabs.pcp.protocol :as p] |
14 | 14 | [puppetlabs.metrics :refer [time!]] |
15 | | - [clj-time.core :refer [now plus equal?]] |
| 15 | + [clj-time.core :refer [now equal?]] |
16 | 16 | [puppetlabs.ssl-utils.core :as ssl-utils] |
17 | 17 | [puppetlabs.structured-logging.core :as sl] |
18 | 18 | [puppetlabs.trapperkeeper.authorization.ring :as ring] |
|
255 | 255 |
|
256 | 256 | (defn- validate-message-type |
257 | 257 | [^String message-type] |
258 | | - (if-not (re-matches #"^[\w\-.:/]*$" message-type) |
| 258 | + (when-not (re-matches #"^[\w\-.:/]*$" message-type) |
259 | 259 | (i18n/trs "Illegal message type: ''{0}''." message-type))) |
260 | 260 |
|
261 | 261 | (defn- validate-target |
262 | 262 | [^String target] |
263 | | - (if-not (re-matches #"^[\w\-.:/*]*$" target) |
| 263 | + (when-not (re-matches #"^[\w\-.:/*]*$" target) |
264 | 264 | (i18n/trs "Illegal message target: ''{0}''." target))) |
265 | 265 |
|
266 | 266 | (s/defn make-ring-request :- (s/maybe ring/Request) |
|
341 | 341 | in order, if the message: 1) is an associate-request as expected during |
342 | 342 | Session Association; 2) is authenticated; 3) is authorized; 4) does not |
343 | 343 | use multicast delivery." |
344 | | - [broker :- Broker message :- Message connection :- Connection is-association-request :- s/Bool] |
| 344 | + [broker :- Broker message :- Message connection :- Connection _is-association-request :- s/Bool] |
345 | 345 | (cond |
346 | 346 | (not (authenticated? message connection)) :not-authenticated |
347 | 347 | (not (authorized? broker message connection)) :not-authorized |
|
433 | 433 | message |
434 | 434 | (i18n/trs "Error {0} handling message: {1}" (:type m) &throw-context) |
435 | 435 | connection)))) |
436 | | - (catch map? m |
| 436 | + (catch map? _m |
437 | 437 | (sl/maplog |
438 | 438 | [:puppetlabs.pcp.broker.pcp_access :warn] |
439 | 439 | (assoc (connection/summarize connection) |
|
471 | 471 |
|
472 | 472 | (defn- on-bytes! |
473 | 473 | "OnMessage (binary) websocket event handler" |
474 | | - [broker ws bytes offset len] |
| 474 | + [broker ws bytes _offset _len] |
475 | 475 | (on-message! broker ws bytes)) |
476 | 476 |
|
477 | 477 | (defn all-controllers-disconnected? |
478 | 478 | [broker] |
479 | | - (and (not (empty? @(:controllers broker))) |
| 479 | + (and (seq @(:controllers broker)) |
480 | 480 | (= (set (keys @(:controllers broker))) |
481 | 481 | (set (keys (:warning-bin @(:database broker))))))) |
482 | 482 |
|
|
720 | 720 | #(i18n/trs "Checking the existing {0} connections for expired CRLs." (:count %))) |
721 | 721 | (doseq [[uri client-connection] inventory-snapshot] |
722 | 722 | (when (:expired client-connection) |
723 | | - (do |
724 | | - (sl/maplog :debug {:uri (str uri)} #(i18n/trs "Closing expired connection for {0}." (:uri %))) |
725 | | - (Thread/sleep throttle-duration) |
726 | | - (websocket-session/close! |
727 | | - (:websocket client-connection) |
728 | | - 1012 ;; code SERVER_RESTART, client *should* reconnect soon |
729 | | - (i18n/trs "CRL reloaded")) |
730 | | - (sl/maplog |
731 | | - :info {} |
732 | | - (fn [_] (i18n/trs "Evicted stale client connections because of CRL reload.")))))))) |
| 723 | + (sl/maplog :debug {:uri (str uri)} #(i18n/trs "Closing expired connection for {0}." (:uri %))) |
| 724 | + (Thread/sleep throttle-duration) |
| 725 | + (websocket-session/close! |
| 726 | + (:websocket client-connection) |
| 727 | + 1012 ;; code SERVER_RESTART, client *should* reconnect soon |
| 728 | + (i18n/trs "CRL reloaded")) |
| 729 | + (sl/maplog |
| 730 | + :info {} |
| 731 | + (fn [_] (i18n/trs "Evicted stale client connections because of CRL reload."))))))) |
733 | 732 |
|
734 | 733 | (defn on-controller-connect! |
735 | 734 | [broker controller-uri _ws] |
|
744 | 743 |
|
745 | 744 | (defn schedule-client-purge! |
746 | 745 | [broker timestamp controller-disconnection-ms] |
747 | | - (future (do (Thread/sleep controller-disconnection-ms) |
748 | | - (maybe-purge-clients! broker timestamp))) |
| 746 | + (future |
| 747 | + (Thread/sleep controller-disconnection-ms) |
| 748 | + (maybe-purge-clients! broker timestamp)) |
749 | 749 | (sl/maplog |
750 | 750 | :debug {:timeout controller-disconnection-ms} |
751 | 751 | ;; 0 : number of milliseconds |
|
755 | 755 | [broker :- Broker |
756 | 756 | uri :- s/Str |
757 | 757 | controller-disconnection-ms :- s/Int |
758 | | - client :- Client] |
| 758 | + _client :- Client] |
759 | 759 | (let [timestamp (now)] |
760 | 760 | (sl/maplog |
761 | 761 | :info {:uri uri} |
|
808 | 808 | check-interval (:crl-check-period broker)] |
809 | 809 | (loop [] |
810 | 810 | (close-expired-connections! broker) |
811 | | - (if (nil? (deref should-stop check-interval nil)) |
| 811 | + (when (nil? (deref should-stop check-interval nil)) |
812 | 812 | (recur)))))) |
813 | 813 |
|
814 | 814 | (s/defn expire-ssl-connections* |
|
890 | 890 | (when (get-route :v2) |
891 | 891 | (swap! (:handlers broker) conj |
892 | 892 | (add-websocket-handler (build-websocket-handlers broker message/v2-codec) {:route-id :v2}))) |
893 | | - (catch IllegalArgumentException e |
| 893 | + (catch IllegalArgumentException _e |
894 | 894 | (sl/maplog :info {:type :v2-unavailable} |
895 | 895 | (fn [_] (i18n/trs "v2 protocol endpoint not configured."))))) |
896 | 896 | broker)) |
|
0 commit comments