@@ -115,6 +115,7 @@ static struct rtr_socket *rtr_create_rtr_socket(struct tr_socket *socket) {
115
115
static struct tr_ssh_config * rtr_create_ssh_config (
116
116
const char * host ,
117
117
const unsigned int port ,
118
+ const char * bindaddr ,
118
119
const char * server_hostkey_path ,
119
120
const char * username ,
120
121
const char * client_privkey_path ,
@@ -129,6 +130,10 @@ static struct tr_ssh_config *rtr_create_ssh_config(
129
130
result -> port = port ;
130
131
result -> username = strdup (username );
131
132
133
+ // Assign bind address if available.
134
+ if (bindaddr )
135
+ result -> bindaddr = strdup (bindaddr );
136
+
132
137
// Assign key paths (optional).
133
138
if (server_hostkey_path )
134
139
result -> server_hostkey_path = strdup (server_hostkey_path );
@@ -173,7 +178,7 @@ static struct tr_socket *rtr_create_ssh_socket(
173
178
* @return
174
179
*/
175
180
static struct tr_tcp_config * rtr_create_tcp_config (
176
- const char * host , const char * port
181
+ const char * host , const char * port , const char * bindaddr
177
182
) {
178
183
// Initialize result.
179
184
struct tr_tcp_config * result = malloc (sizeof (struct tr_tcp_config ));
@@ -182,6 +187,7 @@ static struct tr_tcp_config *rtr_create_tcp_config(
182
187
// Populate result.
183
188
result -> host = strdup (host );
184
189
result -> port = strdup (port );
190
+ result -> bindaddr = strdup (bindaddr );
185
191
186
192
// Store result in static variable until RTRLIB copies and frees the config.
187
193
tcp_config = result ;
@@ -248,9 +254,9 @@ void rtr_close(struct rtr_mgr_config *rtr_mgr_config) {
248
254
}
249
255
250
256
struct rtr_mgr_config * rtr_ssh_connect (
251
- const char * host , const char * port , const char * hostkey_file ,
252
- const char * username , const char * privkey_file , const char * pubkey_file ,
253
- const pfx_update_fp callback
257
+ const char * host , const char * port , const char * bindaddr ,
258
+ const char * hostkey_file , const char * username , const char * privkey_file ,
259
+ const char * pubkey_file , const pfx_update_fp callback
254
260
) {
255
261
// Create RTR manager config with the single server group.
256
262
struct rtr_mgr_config * result = rtr_create_mgr_config (
@@ -259,6 +265,7 @@ struct rtr_mgr_config *rtr_ssh_connect(
259
265
rtr_create_ssh_socket (rtr_create_ssh_config (
260
266
host ,
261
267
strtoul (port , 0 , 10 ),
268
+ bindaddr ,
262
269
hostkey_file ,
263
270
username ,
264
271
privkey_file ,
@@ -287,13 +294,16 @@ struct rtr_mgr_config *rtr_ssh_connect(
287
294
}
288
295
289
296
struct rtr_mgr_config * rtr_tcp_connect (
290
- const char * host , const char * port , const pfx_update_fp callback
297
+ const char * host , const char * port , const char * bindaddr ,
298
+ const pfx_update_fp callback
291
299
) {
292
300
// Create RTR manager config with the single server group.
293
301
struct rtr_mgr_config * result = rtr_create_mgr_config (
294
302
rtr_create_mgr_group (
295
303
rtr_create_rtr_socket (
296
- rtr_create_tcp_socket (rtr_create_tcp_config (host , port ))
304
+ rtr_create_tcp_socket (
305
+ rtr_create_tcp_config (host , port , bindaddr )
306
+ )
297
307
),
298
308
1
299
309
),
0 commit comments