File tree 1 file changed +21
-6
lines changed
1 file changed +21
-6
lines changed Original file line number Diff line number Diff line change 139
139
(first opts)
140
140
(apply hash-map opts))
141
141
{:keys [^String host
142
+ ^String remote-host
143
+ ^String local-host
142
144
^Integer port
145
+ ^Integer remote-port
146
+ ^Integer local-port
143
147
tls?
144
148
key
145
149
cert
146
150
ca-cert
147
151
^Boolean cache-dns?]
148
- :or {host " localhost" , cache-dns? false }} opts]
152
+ :or {host " localhost" , cache-dns? false , local-port 0 }} opts]
149
153
150
154
; Check options
151
155
(when tls?
154
158
(assert ca-cert))
155
159
156
160
; Create client
157
- (let [port (or port (if tls? 5554 5555 ))
161
+ (let [remote- port (or remote-port port (if tls? 5554 5555 ))
158
162
client (if tls?
159
163
; TLS client
160
164
(RiemannClient.
161
- (doto (TcpTransport. host port)
165
+ (doto (if-not local-host
166
+ (TcpTransport. (or remote-host host) remote-port)
167
+ (TcpTransport. (or remote-host host) remote-port local-host local-port))
162
168
(-> .sslContext
163
169
; ; (.set (SSL/sslContext key cert ca-cert))
164
170
(.set (ssl/ssl-context key cert ca-cert)))
165
171
(-> .cacheDns (.set cache-dns?))))
166
172
167
173
; Standard client
168
- (doto (RiemannClient/tcp host port)
174
+ (doto (if-not local-host
175
+ (RiemannClient/tcp (or remote-host host) remote-port)
176
+ (RiemannClient/tcp (or remote-host host) remote-port local-host local-port))
169
177
(-> .transport .cacheDns (.set cache-dns?))))]
170
178
171
179
; Attempt to connect lazily.
184
192
(first opts)
185
193
(apply hash-map opts))
186
194
{:keys [^String host
195
+ ^String remote-host
196
+ ^String local-host
187
197
^Integer port
198
+ ^Integer remote-port
199
+ ^Integer local-port
188
200
^Integer max-size
189
201
^Boolean cache-dns?]
190
202
:or {port 5555
191
203
host " localhost"
192
204
max-size 16384
193
- cache-dns? false }} opts
205
+ cache-dns? false
206
+ local-port 0 }} opts
194
207
c (RiemannClient.
195
- (doto (UdpTransport. host port)
208
+ (doto (if-not local-host
209
+ (UdpTransport. (or remote-host host) (or remote-port port))
210
+ (UdpTransport. (or remote-host host) (or remote-port port) local-host local-port))
196
211
(-> .sendBufferSize (.set max-size))
197
212
(-> .cacheDns (.set cache-dns?))))]
198
213
(try (connect! c)
You can’t perform that action at this time.
0 commit comments