Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 19 additions & 18 deletions lib/communication.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,24 +27,25 @@ class Communication {
if (ips == null)
return false;

List<String>? ipList = ips.split(';');

for (var currentIp = 0; currentIp < ips.length; currentIp++) {
var ip = ipList[currentIp];
var uri = Uri.http("$ip:4646", "ffxivlauncher/$otp");
try {
await http.get(uri);
} on http
.ClientException catch (e) { // This happens since the XL http server is badly implemented, no problem though
developer.log('ClientException: ' + uri.toString(),
name: 'com.goatsoft.xl_otpsend', error: e);
return true;
}
catch (e) {
developer.log('could not send to: ' + uri.toString(),
name: 'com.goatsoft.xl_otpsend', error: e);
}
List<String> ipList = ips.split(";");
return await Future.any(ipList.map((e) => sendOtpToIp(otp, e)));
}

static Future<bool> sendOtpToIp(String otp, String ip) async {
var uri = Uri.http("$ip:4646", "ffxivlauncher/$otp");
try {
await http.get(uri).timeout(const Duration(seconds: 5));
return true;
} on http
.ClientException catch (e) { // This happens since the XL http server is badly implemented, no problem though
developer.log('ClientException: ' + uri.toString(),
name: 'com.goatsoft.xl_otpsend', error: e);
return true;
}
catch (e) {
developer.log('could not send to: ' + uri.toString(),
name: 'com.goatsoft.xl_otpsend', error: e);
}
return true;
return false;
}
}