danielpigott / cloudflare-cli Goto Github PK
View Code? Open in Web Editor NEWCLI for interacting with Cloudflare
License: MIT License
CLI for interacting with Cloudflare
License: MIT License
Using tabs in .cfcli.yml breaks;
C:\Users\stafford\AppData\Roaming\npm\node_modules\cloudflare-cli\lib\argv.js:50
if(ymlConfig.defaults.account || argv.account) {
^
TypeError: Cannot read property 'account' of null
at Object.exports.run (C:\Users\stafford\AppData\Roaming\npm\node_modules\cloudflare-cli\lib\argv.js:50:34)
at new CloudflareCli (C:\Users\stafford\AppData\Roaming\npm\node_modules\cloudflare-cli\lib\cli.js:9:15)
at Object.module.exports.createCli (C:\Users\stafford\AppData\Roaming\npm\node_modules\cloudflare-cli\lib\cli.js:352:12)
at Object.<anonymous> (C:\Users\stafford\AppData\Roaming\npm\node_modules\cloudflare-cli\bin\cfcli:2:33)
at Module._compile (module.js:413:34)
at Object.Module._extensions..js (module.js:422:10)
at Module.load (module.js:357:32)
at Function.Module._load (module.js:314:12)
at Function.Module.runMain (module.js:447:10)
at startup (node.js:142:18)
Note i'm using the default config, not the accounts config.
How do I edit a CNAME record?
I home baked my own cloudflare shell script until I found this amazing repo. But I need to update CNAME for my DNS failover mechanism.
I've tried all possible combinations and none seem to work?
# cfcli -t CNAME edit app b.domain.co.za
Error: No matching records found
But app.domain.co.za
does exist!
If this cannot be done then we need to update docs?
Help does not show with the -h flag, while the CLI output states that it should be used.
$ cfcli -h
Use -h to display help
$ cfcli help
Command not found: help
NAME
cfcli - Interact with cloudflare from the command line
SYNOPSIS
cfcli [options] command [parameters]
...
[email protected]
node v0.10.32
Mac OSX 10.10.2
cloudflare 1.1.1 uses verymodel which uses an old version of joi containing the hoek vulnerability.
Here is the vulnerability
https://nodesecurity.io/advisories/566
The newest version of cloudflare does not have this issue.
I have tried a lot of permutations of this command:
cfcli -d example.com add -t CAA example.com. 0 issue "letsencrypt.org"
But I always get Error: Response code 400 (Bad Request)
Hi,
I'm unable to add SRV
type records with this tool anymore, e.g. something like this:
cfcli -d example.org -t SRV add _test._tcp.example.org 0 0 1234 server.example.org
I'm sure it was working several months ago as I have built this command into my scripts that were working at a time. Apparently CF changed something that breaks the tool. Tried with priority
option too but no luck.
Is there an option we can pass so that cfcli add -t CNAME some-cname some-host
does not fail if the record exists already? Maybe log a message that the record already exists. This would be helpful while building automations. Same for remove behaviour. Would this be possible?
running [email protected]
~/.cfcli.yml
cfcli listdomains
outputs.
This would help to automate and chain commands with jq
.
e.g.
I'm getting this a lot, even when I haven't used cfcli in days or weeks.
Other times it works without issue.
Looks like the API can take an array of up to 30 files to purge, but this line is passing things through as a single string: https://github.com/danielpigott/cloudflare-cli/blob/master/index.js#L370
I think could treat any args at the end of the file as a space-separated list of URLs:
cfcli purge http://example.com/ https://example.com/ http://example.com/help https://example.com/help
Would that work?
Cloudflare have launched API tokens for use with their API but the headers required to use it are different from the current implementation.
I've had a look and switching the headers would potentially require a BC break so wanted to get some input before putting in a PR.
Headers X-Auth-Email
and X-Auth-Key
(set here https://github.com/danielpigott/cloudflare-cli/blob/master/lib/apiClient.js#L14) are skipped and Authorize: Bearer <token>
is used instead.
Should be fairly trivial to make both work; either by adding a new option to the cli wrapper or allowing email to be nullable (and assuming API token should be used if not set).
Let me know what you think and I'll put a PR in.
Hello,
Cannot add MX record on cfcli version 2.0.3. Also same command is normal working on cfcli 1.5.2
cfcli -d example.com -t MX addrecord example.com mail.example.com -p 1 -l 3600
Error: Response code 400 (Bad Request)
Thanks beforehand,
BR, Areg
It would be great to be able to set the TTL when creating or updating records. The API supports it: https://www.cloudflare.com/docs/client-api.html#s5
Hi, I'm working on a PR that adds a script to automatically run in Docker, similar to Compose. It would be a lot easier if we could just have it pull from hub.docker.com instead of having to build the image. Is there any reason you've not done this?
Is there a way that I can specify a value for the record that I would like to enable cloudflare for?
For example - if I have two A records with the same name but different IPs, invoking cfcli enablecf recordname
will activate it for both records. It ignores any value supplied. I have also tried cfcli editrecord recordname --activate
, however that is not a valid option.
Any thoughts? I poked through the cfcli.js file myself to see if I could easily add it, but my javascript knowledge is depressingly poor.
Could you please point at how to get a token?
The CloudFlare npm module you're using is an older version with API v1 which connects to the endpoint: https://www.cloudflare.com/api_json.html
As CloudFlare has deprecated the v1 API, we should move towards using the new v4 API.
The new endpoint for this is: https://api.cloudflare.com/client/v4
As far as i know, the latest version of the CloudFlare npm module supports the v4 API.
Hi,
When trying to edit the A record of my domain, even if I specify -t A in the command, and no matter where it is specified, before or after the 'editrecord' command, I get this:
Found 3 records that matched domain.tld. canceling edit. My record are as follow. 4 CNAMEs, 1 A record, 1 MX and 1 TXT. The command I'm trying to do is:
cfcli -t A editrecord domain.tld $(curl icanhazip.com)
or:
cfcli editrecord -t A domain.tld $(curl icanhazip.com)
Both commands gives the same result. Is there something I'm doing wrong ? Or is it a bug ?
Thanks :)
Only shows the first 250, should page through the results
I was hoping this tool would make for a quick way to fetch Cloudflare record IDs (which are only exposed via Cloudflare API), but it doesn't look like they're rendered in the output for either ls
or find
. Is this something you'd be open to adding?
The Alpine image used by the Node image for this project has a high severity vulnerability for musl.
how about supporting multi accounts?
maybe config in yaml like this
defaults:
- # user 1
token: <cloudflare-token>
email: <[email protected]>
domain: <default-cloudflare-domain>
- # user 2
token: <cloudflare-token>
email: <[email protected]>
domain: <default-cloudflare-domain>
and use cfcli
like this
$ cfcli -u [1|[email protected]] [other options] command [parameters]
Hello,
Is it updated for v4 of the API
I get this error when trying to purgefile
Error: Invalid zone
at IncomingMessage. (/usr/local/lib/node_modules/cloudflare-cli/node_modules/cloudflare/lib/cloudflare.js:654:10)
at emitNone (events.js:91:20)
at IncomingMessage.emit (events.js:185:7)
at endReadableNT (_stream_readable.js:973:12)
at _combinedTickCallback (internal/process/next_tick.js:74:11)
at process._tickCallback (internal/process/next_tick.js:98:9)
Hi,
Is there any scope to look at adding logpush to be configured via the command line cli?
Cheers
Details:
https://support.cloudflare.com/hc/en-us/articles/360013599871-Getting-Started-with-Cloudflare-Logpush-Beta****
I have no problem enablecf / disablecf on the subdomain, like so:
/usr/local/bin/cfcli -t A --domain mydomain.com enablecf www mydomain.com
However, when I attempt the same thing on the root domain, like so:
/usr/local/bin/cfcli -t A --domain mydomain.com enablecf mydomain.com 1.2.3.4
I get this error:
Error: 8 matching records found, unable to update
And the output of ls
(csv):
A,cpanel.mydomain.com,3.4.5.6,Auto,false
A,mydomain.com,1.2.3.4,Auto,true
CNAME,ftp.mydomain.com,mydomain.com,Auto,false
CNAME,mail.mydomain.com,mydomain.com,Auto,false
CNAME,www.mydomain.com,mydomain.com,Auto,true
MX,mydomain.com,alt1.aspmx.l.google.com,Auto,false
MX,mydomain.com,alt2.aspmx.l.google.com,Auto,false
MX,mydomain.com,alt3.aspmx.l.google.com,Auto,false
MX,mydomain.com,alt4.aspmx.l.google.com,Auto,false
MX,mydomain.com,aspmx.l.google.com,Auto,false
TXT,mydomain.com,google-site-verification=blah-BW5W9QiF0,Auto,false
TXT,mydomain.com,v=spf1 include:spf.protection.outlook.com ~all,Auto,false
halp?
Commands which fail:
cfcli -a -t A add anything 1.2.3.4
cfcli ls
Background:
The below happens on Windows if I don't have the environment variables set.
It happens on Linux (within docker image node:10
) even if I do.
Exception:
(node:17) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'data' of undefined
at /usr/local/lib/node_modules/cloudflare-cli/index.js:170:52
at process._tickCallback (internal/process/next_tick.js:68:7)
at Function.Module.runMain (internal/modules/cjs/loader.js:745:11)
at startup (internal/bootstrap/node.js:266:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:596:3)
(node:17) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 3)
(node:17) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
Continuing to investigate my side..
Hi,
I have try API token and API keys
both of them can work ok according Cloudflare official test.
But when I want to add an A record
[centos@ip-172-26-7-72 ~]$ cfcli -a -t A add hkg 35.220.162.202
Error response received: Invalid request headers
I have always got the Error results above.
I can give you all the info include VPS login info and API key via Email or others.
Please help me.
HI, just seen you have added zones-add great thanks.
how does this work with several accounts.
cfcli -u "account email" zone-add test.com
i have 10 CloudFlare accounts setup and an 11th account that has access to all 10 accounts using CF's members feature.
Kevin
when I run "cfcli disablecf [record]", I receive the following record. I have tested it on multiple records.
/usr/lib/node_modules/cloudflare-cli/lib/cli.js:222
var matches = cfcli.findRecord(name, false, result);
^
TypeError: Object # has no method 'findRecord'
at editRecord (/usr/lib/node_modules/cloudflare-cli/lib/cli.js:222:25)
at /usr/lib/node_modules/cloudflare-cli/node_modules/cloudflare/lib/cloudflare.js:123:7
at IncomingMessage. (/usr/lib/node_modules/cloudflare-cli/node_modules/cloudflare/lib/cloudflare.js:652:7)
at IncomingMessage.emit (events.js:117:20)
at _stream_readable.js:944:16
at process._tickCallback (node.js:442:13)
storing those values in file is good, but perhaps some will prefer storing them in env variables instead. Shouldn't the command line look for those vals in env var too?
When you try to remove a specific name (record A) with multiple points (IPs), it will remove a randomly entry.
Example:
A mc 1.1.1.1
A mc 1.1.1.2
A mc 1.1.1.3
A mc 1.1.1.4
If you try to remove entry mc with 1.1.1.3 IP, it will not work. The command only work with name, not name and IP.
Im trying to test the API with the following command: cfcli -d mywebsite.com devmode on
Im getting this output: Error: Cannot set static values
Im pretty sure my yaml config is correct, it is listing all the right zones when I run cfcli zones
after install cloudflare-cli
I use
vi .cfcli.yml
to create
defaults:
token:
email: [email protected]
domain: <doudoulong.club>
and save
but after I type
cfcli -a -t A add 3hk 1.1.1.1
The following required parameters were not provided: token,email
it shows the error above
I want to add a DNS A records to domain doudoulong.club so I type
cfcli -a -t A add 3hk 1.1.1.1 -e [email protected] -k f3f3eedae298
Error response received: DNS Validation Error
it shows the error above
how to fix it and add DNS records correctly?
Thanks very much for help~
We're currently using outdated 2.4.1
Hi,
Is it possible to add a DNS record with the cli and also set the option "proxied". We currently would like to create records with the option to either set it as proxied or not.
Details:
https://api.cloudflare.com/#dns-records-for-a-zone-create-dns-record
proxiedboolean |
Whether the record is receiving the performance and security benefits of Cloudflare
false |
valid values: (true,false)
-- | -- | --
"cfcfli rm" without any matching parameter will delete 20 dns records without asking user first. User should get warning if it's ok to delete record without any matching parameter. This is really danger design for careless user like me.
Please consider adding confirmation for deleting records more then just single record.
The API supports this operation and it would be nice to have this option because we could automate the process of adding a domain to CloudFlare completely.
Hi,
Do you know if it would be possible to add this feature to the cli. I am currently running the command adding our credentials which have access to all of our 3 accounts, however when its bringing back the domains I cannot distinguish which domain is from which account.
Is there anyway to add this to the list zones command so that I could then only view domains within a specific account. I can see there is sort of the option with the .cfcli.yml multiple account options but this would require separate accounts that only have access specifically to that account.
Cheers
when issuing a cfcli rm
, there's no way to specify the record type. So If I have the following two records:
CNAME,blah.example.com,blah.com,Auto,false
TXT,blah.example.com,blah.com,Auto,false
a cfcli rm blah blah.com
will remove both records.
Looks like the configuration options to create SRV records are not complete.
When I run:
cfcli addrecord -t SRV -p 1 _foo._tcp.your.domain SRV 1 12345 service.domain
The result is:
[Error: Invalid service value.]
This also happens with multiple variations of the arguments.
Looking at the API docs for the rec_new
function I get the feeling that parameters like service
, etc. have to passed separately when creating SRV records.
Maybe I am just using it wrong, but I was not able to find a way to create an SRV record. Any idea? :)
I currently work with this api, I hope to add subdomains automatically to my cloudflare account.
I occupy centos 7, nginx
when I run or add my subdomain I get the error mentioned
[root@root ~]# cfcli -a -t A add my.dominio.com myipdestine
Error response received: Invalid request headers
What is the syntax for MX records? Without specifying the priority, I get a
"No priority is present for a MX or SRV record." error.
I can't seem to get it to accept the priority in any location in the command.
cfcli addrecord -t MX domain.com mail.domain.com 100
causes it to just ignore the priority and returns the same error.
Thanks
When I try to use "if /usr/bin/cfcli -c /root/cloudflare//cfcli.yml removerecord mc | egrep -i finished; then (...)" inside of a bash script I get:
events.js:72
throw er; // Unhandled 'error' event
^
Error: write EPIPE
at errnoException (net.js:905:11)
at Object.afterWrite (net.js:721:19)
When I use this command in terminal I get success. Do you know what is the problem?
Hi! When an A record name contains only numbers, this is the output:
Error response received: Failed to parse request body, content-type must be application/json
Example:
cfcli -t A -l 1 add 123 88.282.282.282
Error response received: Failed to parse request body, content-type must be application/json
Instead:
cfcli -t A -l 1 add asd123 88.282.282.282
Added A record asd123.example.com -> 88.282.282.282
How is adding a option for enabling development mode?
For those of us who like to keep our home directory under version control, explicitly setting the token
field in cfcli.yml
forces us to not track that for unless we risk leaking the token. My preferred solution to this is allowing the token to be retrieved from an external command.
Pianobar, for example, has a password_command
setting for just this. Other solutions exist as well though. Mutt has a source
command that can run commands from the output of an external command. That's pretty clunky, but offlineimap allows setting usernames and passwords with an external command with its remoteusereval
and remotepasseval
commands.
I'm not that familiar with node.js, but from a quick search of th edocs it seems this could be implemented in a relatively straightforward manner using child_process.exec
.
I've started getting the below errors
(node:14799) UnhandledPromiseRejectionWarning: TypeError: Cannot read property '0' of undefined
at /usr/local/lib/node_modules/cloudflare-cli/index.js:198:83
at processTicksAndRejections (internal/process/task_queues.js:89:5)
(node:14799) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)
(node:14799) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
I personally find it more intuitive and in line with other cli tools to display the help output when no commands or options are given.
This confused me for a bit at first when cfcli
alone on the command line gave no output and didn't even return an error code to the shell.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.