@@ -81,44 +81,6 @@ + (BOOL) isAddressLAN:(in_addr_t)addr {
81
81
return NO ;
82
82
}
83
83
84
- // This ensures that only RFC 1918 IPv4 addresses can be passed to
85
- // the Add PC dialog. This is required to comply with Apple App Store
86
- // Guideline 4.2.7a.
87
- + (BOOL ) isProhibitedAddress : (NSString *)address {
88
- #ifdef ENABLE_APP_STORE_RESTRICTIONS
89
- struct addrinfo hints;
90
- struct addrinfo* result;
91
- int err;
92
-
93
- // We're explicitly using AF_INET here because we don't want to
94
- // ever receive a synthesized IPv6 address here, even on NAT64.
95
- // IPv6 addresses are not restricted here because we cannot easily
96
- // tell whether they are local or not.
97
- memset (&hints, 0 , sizeof (hints));
98
- hints.ai_family = AF_INET;
99
- err = getaddrinfo ([address UTF8String ], NULL , &hints, &result);
100
- if (err != 0 || result == NULL ) {
101
- Log (LOG_W, @" getaddrinfo(%@ ) failed: %d " , address, err);
102
- return NO ;
103
- }
104
-
105
- if (result->ai_family != AF_INET) {
106
- // This should never happen due to our hints
107
- assert (result->ai_family == AF_INET);
108
- Log (LOG_W, @" Unexpected address family: %d " , result->ai_family );
109
- freeaddrinfo (result);
110
- return NO ;
111
- }
112
-
113
- BOOL ret = ![DiscoveryManager isAddressLAN: ((struct sockaddr_in*)result->ai_addr)->sin_addr.s_addr];
114
- freeaddrinfo (result);
115
-
116
- return ret;
117
- #else
118
- return NO ;
119
- #endif
120
- }
121
-
122
84
- (ServerInfoResponse*) getServerInfoResponseForAddress : (NSString *)address {
123
85
HttpManager* hMan = [[HttpManager alloc ] initWithAddress: address httpsPort: 0 serverCert: nil ];
124
86
ServerInfoResponse* serverInfoResponse = [[ServerInfoResponse alloc ] init ];
@@ -127,14 +89,6 @@ - (ServerInfoResponse*) getServerInfoResponseForAddress:(NSString*)address {
127
89
}
128
90
129
91
- (void ) discoverHost : (NSString *)hostAddress withCallback : (void (^)(TemporaryHost *, NSString *))callback {
130
- BOOL prohibitedAddress = [DiscoveryManager isProhibitedAddress: hostAddress];
131
- NSString * prohibitedAddressMessage = [NSString stringWithFormat: @" Moonlight only supports adding PCs on your local network on %s ." ,
132
- #if TARGET_OS_TV
133
- " tvOS"
134
- #else
135
- " iOS"
136
- #endif
137
- ];
138
92
ServerInfoResponse* serverInfoResponse = [self getServerInfoResponseForAddress: hostAddress];
139
93
140
94
TemporaryHost* host = nil ;
@@ -146,40 +100,7 @@ - (void) discoverHost:(NSString *)hostAddress withCallback:(void (^)(TemporaryHo
146
100
147
101
// Check if this is a new PC
148
102
if (![self getHostInDiscovery: host.uuid]) {
149
- // Enforce LAN restriction for App Store Guideline 4.2.7a
150
- if ([DiscoveryManager isProhibitedAddress: hostAddress]) {
151
- // We have a prohibited address. This might be because the user specified their WAN address
152
- // instead of their LAN address. If that's the case, we'll try their LAN address and if we
153
- // can reach it through that address, we'll allow it.
154
- ServerInfoResponse* lanInfo = [self getServerInfoResponseForAddress: host.localAddress];
155
- if ([lanInfo isStatusOk ]) {
156
- TemporaryHost* lanHost = [[TemporaryHost alloc ] init ];
157
- [lanInfo populateHost: lanHost];
158
-
159
- if (![lanHost.uuid isEqualToString: host.uuid]) {
160
- // This is a different host, so it's prohibited
161
- prohibitedAddress = YES ;
162
- }
163
- else {
164
- // This is the same host that is reachable on the LAN
165
- prohibitedAddress = NO ;
166
- }
167
- }
168
- else {
169
- // LAN request failed, so it's a prohibited address
170
- prohibitedAddress = YES ;
171
- }
172
- }
173
- else {
174
- // It's an RFC 1918 IPv4 address or IPv6 address which counts as LAN
175
- prohibitedAddress = NO ;
176
- }
177
-
178
- if (prohibitedAddress) {
179
- callback (nil , prohibitedAddressMessage);
180
- return ;
181
- }
182
- else if ([DiscoveryManager isAddressLAN: inet_addr ([hostAddress UTF8String ])]) {
103
+ if ([DiscoveryManager isAddressLAN: inet_addr ([hostAddress UTF8String ])]) {
183
104
// Don't send a STUN request if we're connected to a VPN. We'll likely get the VPN
184
105
// gateway's external address rather than the external address of the LAN.
185
106
if (![Utils isActiveNetworkVPN ]) {
@@ -201,10 +122,8 @@ - (void) discoverHost:(NSString *)hostAddress withCallback:(void (^)(TemporaryHo
201
122
} else {
202
123
callback (host, nil );
203
124
}
204
- } else if (!prohibitedAddress) {
205
- callback (nil , @" Could not connect to host.\n\n If you're hosting using GeForce Experience, make sure you've enabled the toggle on the SHIELD tab.\n\n If you're hosting using Sunshine, ensure it is running properly. If you're using a non-default port, you will need to include that here." );
206
125
} else {
207
- callback (nil , prohibitedAddressMessage );
126
+ callback (nil , @" Could not connect to host. \n\n If you're hosting using GeForce Experience, make sure you've enabled the toggle on the SHIELD tab. \n\n If you're hosting using Sunshine, ensure it is running properly. If you're using a non-default port, you will need to include that here. " );
208
127
}
209
128
}
210
129
0 commit comments