@@ -9,20 +9,31 @@ import provision;
9
9
void main (string [] args) {
10
10
auto app = new Archttp;
11
11
ADI * adi = new ADI (expandTilde(" ~/.adi" ));
12
- adi.serialNo = " DNPX89219" ;
13
- adi.customHeaders[" X-Apple-Locale" ] = " en_US" ;
14
12
15
13
ulong rinfo;
16
- adi.provisionDevice(rinfo);
14
+ if (! adi.isMachineProvisioned()) {
15
+ stderr.write(" Machine requires provisioning... " );
16
+ adi.provisionDevice(rinfo);
17
+ stderr.writeln(" done !" );
18
+ } else {
19
+ adi.getRoutingInformation(rinfo);
20
+ }
21
+
22
+ app.get (" /reprovision" , (req, res) {
23
+ writefln! " [%s >>] GET /reprovision" (req.ip);
24
+ adi.provisionDevice(rinfo);
25
+ writefln! " [>> %s] 200 OK" (req.ip);
26
+ res.code(HttpStatusCode.OK );
27
+ });
17
28
18
29
app.get (" /" , (req, res) {
19
30
try {
20
31
import std.datetime.systime ;
21
32
import std.datetime.timezone ;
22
33
import core.time ;
23
- auto time = Clock .currTime(cast (TimeZone) new SimpleTimeZone(dur ! " msecs " ( 0 ), " GMT+0 " ) );
34
+ auto time = Clock .currTime();
24
35
25
- writeln( " Received request ! " );
36
+ writefln ! " [%s >>] GET / " (req.ip );
26
37
27
38
ubyte [] mid;
28
39
ubyte [] otp;
@@ -39,11 +50,13 @@ void main(string[] args) {
39
50
" X-Apple-I-MD-LU" : adi.localUserUUID,
40
51
" X-Apple-I-SRL-NO" : adi.serialNo,
41
52
" X-MMe-Client-Info" : adi.clientInfo,
42
- " X-Apple-I-TimeZone" : " GMT+0 " ,
53
+ " X-Apple-I-TimeZone" : time.timezone.dstName ,
43
54
" X-Apple-Locale" : " en_US" ,
44
55
" X-Mme-Device-Id" : adi.deviceId,
45
56
];
46
57
58
+ writefln! " [>> %s] 200 OK %s" (req.ip, response);
59
+
47
60
res.code(HttpStatusCode.OK );
48
61
res.send(response);
49
62
} catch (Throwable t) {
0 commit comments