forked from u6du/cloudflare-dns
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit.coffee
executable file
·63 lines (56 loc) · 1.35 KB
/
init.coffee
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/usr/bin/env coffee
request = require('./cloudflare')
add = (user_id, host) ->
account ={id:user_id}
data = {
name:host
account
type:'full'
jump_start:false
}
try
r = await request.post(
"zones"
data
)
catch err
if err.response
response = err.response
console.log response.status
console.log response.statusText
console.log response.data
else
console.log err
return
console.log r.data
do ->
r = await request.get(
"accounts?page=1&per_page=20&direction=desc"
)
console.log r.data.result
user_id = r.data.result[0].id
require('line-reader').eachLine(
"#{__dirname}/host.txt"
(line)->
host = line.trim()
if not host
return
console.log host
await add user_id,host
)
# await add user_id,"6du.world"
# user = (await cf.user.read()).result
# console.log user
# user_id = user.id
# # user_id = user.username
# try
# r = await cf.zones.add({
# name:"6du.tv",
# account:{id:user_id},
# jump_start:false,
# type:"full"
# })
# catch err
# console.log err
# return
# console.log r