@@ -158,7 +158,18 @@ struct Config {
158
158
#[ cfg( feature = "http2" ) ]
159
159
http2_keep_alive_while_idle : bool ,
160
160
local_address : Option < IpAddr > ,
161
- #[ cfg( any( target_os = "android" , target_os = "fuchsia" , target_os = "linux" ) ) ]
161
+ #[ cfg( any(
162
+ target_os = "android" ,
163
+ target_os = "fuchsia" ,
164
+ target_os = "illumos" ,
165
+ target_os = "ios" ,
166
+ target_os = "linux" ,
167
+ target_os = "macos" ,
168
+ target_os = "solaris" ,
169
+ target_os = "tvos" ,
170
+ target_os = "visionos" ,
171
+ target_os = "watchos" ,
172
+ ) ) ]
162
173
interface : Option < String > ,
163
174
nodelay : bool ,
164
175
#[ cfg( feature = "cookies" ) ]
@@ -266,7 +277,18 @@ impl ClientBuilder {
266
277
#[ cfg( feature = "http2" ) ]
267
278
http2_keep_alive_while_idle : false ,
268
279
local_address : None ,
269
- #[ cfg( any( target_os = "android" , target_os = "fuchsia" , target_os = "linux" ) ) ]
280
+ #[ cfg( any(
281
+ target_os = "android" ,
282
+ target_os = "fuchsia" ,
283
+ target_os = "illumos" ,
284
+ target_os = "ios" ,
285
+ target_os = "linux" ,
286
+ target_os = "macos" ,
287
+ target_os = "solaris" ,
288
+ target_os = "tvos" ,
289
+ target_os = "visionos" ,
290
+ target_os = "watchos" ,
291
+ ) ) ]
270
292
interface : None ,
271
293
nodelay : true ,
272
294
hickory_dns : cfg ! ( feature = "hickory-dns" ) ,
@@ -483,7 +505,14 @@ impl ClientBuilder {
483
505
#[ cfg( any(
484
506
target_os = "android" ,
485
507
target_os = "fuchsia" ,
486
- target_os = "linux"
508
+ target_os = "illumos" ,
509
+ target_os = "ios" ,
510
+ target_os = "linux" ,
511
+ target_os = "macos" ,
512
+ target_os = "solaris" ,
513
+ target_os = "tvos" ,
514
+ target_os = "visionos" ,
515
+ target_os = "watchos" ,
487
516
) ) ]
488
517
config. interface . as_deref ( ) ,
489
518
config. nodelay ,
@@ -529,7 +558,14 @@ impl ClientBuilder {
529
558
#[ cfg( any(
530
559
target_os = "android" ,
531
560
target_os = "fuchsia" ,
532
- target_os = "linux"
561
+ target_os = "illumos" ,
562
+ target_os = "ios" ,
563
+ target_os = "linux" ,
564
+ target_os = "macos" ,
565
+ target_os = "solaris" ,
566
+ target_os = "tvos" ,
567
+ target_os = "visionos" ,
568
+ target_os = "watchos" ,
533
569
) ) ]
534
570
config. interface . as_deref ( ) ,
535
571
config. nodelay ,
@@ -726,7 +762,14 @@ impl ClientBuilder {
726
762
#[ cfg( any(
727
763
target_os = "android" ,
728
764
target_os = "fuchsia" ,
729
- target_os = "linux"
765
+ target_os = "illumos" ,
766
+ target_os = "ios" ,
767
+ target_os = "linux" ,
768
+ target_os = "macos" ,
769
+ target_os = "solaris" ,
770
+ target_os = "tvos" ,
771
+ target_os = "visionos" ,
772
+ target_os = "watchos" ,
730
773
) ) ]
731
774
config. interface . as_deref ( ) ,
732
775
config. nodelay ,
@@ -746,7 +789,18 @@ impl ClientBuilder {
746
789
http,
747
790
proxies. clone ( ) ,
748
791
config. local_address ,
749
- #[ cfg( any( target_os = "android" , target_os = "fuchsia" , target_os = "linux" ) ) ]
792
+ #[ cfg( any(
793
+ target_os = "android" ,
794
+ target_os = "fuchsia" ,
795
+ target_os = "illumos" ,
796
+ target_os = "ios" ,
797
+ target_os = "linux" ,
798
+ target_os = "macos" ,
799
+ target_os = "solaris" ,
800
+ target_os = "tvos" ,
801
+ target_os = "visionos" ,
802
+ target_os = "watchos" ,
803
+ ) ) ]
750
804
config. interface . as_deref ( ) ,
751
805
config. nodelay ,
752
806
)
@@ -1428,7 +1482,23 @@ impl ClientBuilder {
1428
1482
self
1429
1483
}
1430
1484
1431
- /// Bind to an interface by `SO_BINDTODEVICE`.
1485
+ /// Bind connections only on the specified network interface.
1486
+ ///
1487
+ /// This option is only available on the following operating systems:
1488
+ ///
1489
+ /// - Android
1490
+ /// - Fuchsia
1491
+ /// - Linux,
1492
+ /// - macOS and macOS-like systems (iOS, tvOS, watchOS and visionOS)
1493
+ /// - Solaris and illumos
1494
+ ///
1495
+ /// On Android, Linux, and Fuchsia, this uses the
1496
+ /// [`SO_BINDTODEVICE`][man-7-socket] socket option. On macOS and macOS-like
1497
+ /// systems, Solaris, and illumos, this instead uses the [`IP_BOUND_IF` and
1498
+ /// `IPV6_BOUND_IF`][man-7p-ip] socket options (as appropriate).
1499
+ ///
1500
+ /// Note that connections will fail if the provided interface name is not a
1501
+ /// network interface that currently exists when a connection is established.
1432
1502
///
1433
1503
/// # Example
1434
1504
///
@@ -1440,7 +1510,21 @@ impl ClientBuilder {
1440
1510
/// .interface(interface)
1441
1511
/// .build().unwrap();
1442
1512
/// ```
1443
- #[ cfg( any( target_os = "android" , target_os = "fuchsia" , target_os = "linux" ) ) ]
1513
+ ///
1514
+ /// [man-7-socket]: https://man7.org/linux/man-pages/man7/socket.7.html
1515
+ /// [man-7p-ip]: https://docs.oracle.com/cd/E86824_01/html/E54777/ip-7p.html
1516
+ #[ cfg( any(
1517
+ target_os = "android" ,
1518
+ target_os = "fuchsia" ,
1519
+ target_os = "illumos" ,
1520
+ target_os = "ios" ,
1521
+ target_os = "linux" ,
1522
+ target_os = "macos" ,
1523
+ target_os = "solaris" ,
1524
+ target_os = "tvos" ,
1525
+ target_os = "visionos" ,
1526
+ target_os = "watchos" ,
1527
+ ) ) ]
1444
1528
pub fn interface ( mut self , interface : & str ) -> ClientBuilder {
1445
1529
self . config . interface = Some ( interface. to_string ( ) ) ;
1446
1530
self
@@ -2414,7 +2498,18 @@ impl Config {
2414
2498
f. field ( "local_address" , v) ;
2415
2499
}
2416
2500
2417
- #[ cfg( any( target_os = "android" , target_os = "fuchsia" , target_os = "linux" ) ) ]
2501
+ #[ cfg( any(
2502
+ target_os = "android" ,
2503
+ target_os = "fuchsia" ,
2504
+ target_os = "illumos" ,
2505
+ target_os = "ios" ,
2506
+ target_os = "linux" ,
2507
+ target_os = "macos" ,
2508
+ target_os = "solaris" ,
2509
+ target_os = "tvos" ,
2510
+ target_os = "visionos" ,
2511
+ target_os = "watchos" ,
2512
+ ) ) ]
2418
2513
if let Some ( ref v) = self . interface {
2419
2514
f. field ( "interface" , v) ;
2420
2515
}
0 commit comments