Coder Social home page Coder Social logo

cloudflare-cli's Issues

Tabs in config

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.

Edit CNAME

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?

-h flag doesn't work as expected

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

Unable to create CAA record

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)

Can't add SRV records anymore

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.

Idempotent DNS Add/Remove

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?

Add option to output in JSON

This would help to automate and chain commands with jq.

e.g.

  • find all zones
  • find all records of all zones with a certain condition
  • change all records meeting the condition

Support API Tokens

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.

Cannot add MX record

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

Push to Docker Hub

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?

Unable to specify which record to enable Cloudflare for

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.

Editting A record

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 :)

Expose DNS record IDs on `ls` and `find` cmds

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?

multi accounts support

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]

invalid zone

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)

cannot `enablecf` on the "root" domain

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?

UnhandledPromiseRejectionWarning

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..

Error response received: Invalid request headers

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.

Zones-Add Multipul accounts

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

problem with disablecf

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)

supporting env variables

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?

Remove multiple records with same name

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.

Error: Cannot set static values

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

errors on adding DNS A records,please help

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~

cfcli rm is too dangerous!

"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.

Feature Request: Return account name on list zones

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

Need to specify type to `rm`

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.

Missing configuration options for SRV 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? :)

Error response received: Invalid request headers

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

Syntax for adding MX records?

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 remove all entries with same name

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?

[BUG!] Error response when adding numerical-only A records

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

Using latest cloudflare-cli -- Installed via npm (v. 12.18.2)

[Feature Request] Support getting token from external command

Synopsis

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.

Examples from Other Projects

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.

Implementation Idea

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.

Error with node v12.1.0

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.

[Feature Idea] Output help when no command or options are given

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.