|
19 | 19 | #import <arpa/inet.h> |
20 | 20 | #import <netinet/in.h> |
21 | 21 |
|
22 | | -#pragma mark - BRNNetworkInfo |
| 22 | +#pragma mark BRNNetworkInfo |
23 | 23 |
|
24 | 24 | typedef NS_ENUM(NSInteger, BNCNetworkAddressType) { |
25 | 25 | BNCNetworkAddressTypeUnknown = 0, |
@@ -58,9 +58,15 @@ @implementation BNCNetworkInterface |
58 | 58 | // BNCLogDebugSDK(@"Found %s: %x.", interface->ifa_name, interface->ifa_flags); |
59 | 59 |
|
60 | 60 | // Check the state: IFF_RUNNING, IFF_UP, IFF_LOOPBACK, etc. |
61 | | - if (!(interface->ifa_flags & IFF_RUNNING) || |
62 | | - (interface->ifa_flags & IFF_LOOPBACK)) |
63 | | - continue; |
| 61 | + if ((interface->ifa_flags & IFF_UP) && |
| 62 | + (interface->ifa_flags & IFF_RUNNING) && |
| 63 | + !(interface->ifa_flags & IFF_LOOPBACK)) { |
| 64 | + } else { |
| 65 | + continue; |
| 66 | + } |
| 67 | + |
| 68 | + // TODO: Check ifdata too. |
| 69 | + // struct if_data *ifdata = interface->ifa_data; |
64 | 70 |
|
65 | 71 | const struct sockaddr_in *addr = (const struct sockaddr_in*)interface->ifa_addr; |
66 | 72 | if (!addr) continue; |
@@ -189,6 +195,14 @@ - (NSString*) localIPAddress { // For 'local_ip' server field. |
189 | 195 | } |
190 | 196 | } |
191 | 197 |
|
| 198 | +- (NSArray<NSString*>*) allIPAddresses { |
| 199 | + NSMutableArray *array = [NSMutableArray new]; |
| 200 | + for (BNCNetworkInterface *inf in [BNCNetworkInterface currentInterfaces]) { |
| 201 | + [array addObject:inf.description]; |
| 202 | + } |
| 203 | + return array; |
| 204 | +} |
| 205 | + |
192 | 206 | + (NSString*) bnc_country { |
193 | 207 |
|
194 | 208 | NSString *country = nil; |
|
0 commit comments