62 lines
1.4 KiB
Dart
62 lines
1.4 KiB
Dart
import 'package:dio/dio.dart';
|
|
import 'package:libac_flutter/nbt/impl/CompoundTag.dart';
|
|
import 'package:libac_flutter/utils/Hashing.dart';
|
|
|
|
enum APIEndpoint {
|
|
SetupCheck(script: "SetupCheck.php", path: "/ac/home/supports/"),
|
|
Login(script: "Login.php", path: "/ac/home/supports/");
|
|
|
|
final String script;
|
|
final String path;
|
|
const APIEndpoint({required this.script, required this.path});
|
|
|
|
String getURL() {
|
|
Settings settings = Settings();
|
|
return "${settings.API_SERVER}${path}${script}";
|
|
}
|
|
}
|
|
|
|
class Settings {
|
|
static Settings? _inst = null;
|
|
Settings._() {}
|
|
|
|
Dio dio = Dio();
|
|
|
|
factory Settings() {
|
|
if (Settings._inst != null)
|
|
return Settings._inst!;
|
|
else {
|
|
Settings._inst = Settings._();
|
|
return Settings._inst!;
|
|
}
|
|
}
|
|
|
|
static void Load(CompoundTag tag) {}
|
|
|
|
static CompoundTag save() {
|
|
CompoundTag tag = CompoundTag();
|
|
|
|
return tag;
|
|
}
|
|
|
|
String API_SERVER = "";
|
|
bool OpenSimSetupCompleted = false;
|
|
|
|
void setServices(Map<String, dynamic> js) {
|
|
var protocol = js['api']['protocol'] as String;
|
|
var port = js['api']['port'] as int;
|
|
var host = js['api']['host'] as String;
|
|
|
|
API_SERVER = "${protocol}://${host}:${port}/";
|
|
}
|
|
|
|
Future<String> hashPSK(String PSK) async {
|
|
String hash = Hashing.md5Hash("AriasCreations");
|
|
for (int i = 0; i < 512; i++) {
|
|
hash = Hashing.sha256Hash("${hash}:${PSK}");
|
|
}
|
|
hash = Hashing.md5Hash(hash);
|
|
|
|
return hash;
|
|
}
|
|
}
|