Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Structured DNS provider API info #4738

Merged
merged 1 commit into from May 19, 2024
Merged

Conversation

stokito
Copy link
Contributor

@stokito stokito commented Aug 15, 2023

For the OpenWrt luci-app-acme we need to show on UI list of all DSN providers and their options. My goal is to make regular users to use it without knowing anything about console.

For now I just put a list of all providers into a select
https://github.com/openwrt/luci/blob/master/applications/luci-app-acme/htdocs/luci-static/resources/view/acme.js#L97

And also I collected list of all options per provider and rendering input fields for them:
https://github.com/openwrt/luci/blob/master/applications/luci-app-acme/htdocs/luci-static/resources/view/acme.js#L243

This makes it fragile because once a new DNS provider is added or changed I have to update the LUCI app.
Instead we need a way to get list of all options.
So my idea is to make a new command like acme.sh --dns-provider-info that will print all options. Then I can parse them and render.

The info is stored in plain string and it's both human readable and easy to parse.

dns_example_info='API name
 An extended description.
Site: the dns provider website e.g. example.com
Docs: Link to ACME.sh wiki for the provider
Options:
 VARIABLE Title for the option. Optional. Description.
Issues: Link to https://github.com/acmesh-official/acme.sh
Author: First Lastname <authoremail@example.com>
'

Some providers may have alternative names or domains e.g. Aliyun and AlibabaCloud so for them I added a Domains: section.

Please tell me if you will accept the PR and I will continue for other providers.

@stokito
Copy link
Contributor Author

stokito commented Aug 15, 2023

@github-actions

Done

@stokito
Copy link
Contributor Author

stokito commented Oct 1, 2023

Hi @Neilpang sorry for pushing but please let me know if you'll accept the PR. I want to finish all opened tasks.

@acmesh-official acmesh-official deleted a comment from github-actions bot Oct 6, 2023
@Neilpang
Copy link
Member

Neilpang commented Oct 6, 2023

It seems not bad, but you will have to update all the almost near 200 dns providers. Are you sure?

@stokito
Copy link
Contributor Author

stokito commented Oct 6, 2023

No problem.

@stokito stokito force-pushed the dns_api_info branch 2 times, most recently from fbc041c to a3e3de8 Compare October 10, 2023 11:08
@stokito stokito marked this pull request as ready for review October 10, 2023 11:11
@stokito
Copy link
Contributor Author

stokito commented Oct 10, 2023

@Neilpang I added the structured info to all DNS providers.
There is no any impact on existing functionality so you please merge it.
The extracting of the info from a command line --dns-provider-info is not implemented yet.
I can do that later in a separate PR but maybe this should be implemented by you.

@stokito stokito force-pushed the dns_api_info branch 7 times, most recently from fba571b to 09c19cc Compare October 11, 2023 08:33
@stokito
Copy link
Contributor Author

stokito commented Oct 11, 2023

@Neilpang I rebased on top of the dev branch and reviwed again. Now it should be better.
Please merge

@stokito
Copy link
Contributor Author

stokito commented Oct 24, 2023

Hi @Neilpang please have a look

@stokito
Copy link
Contributor Author

stokito commented Nov 18, 2023

Hi @Neilpang sorry for pushing but this issue blocks me because I want to update GUI for acme in the luci-app-acme based on this functionality.
Here I wrote a script (dash and ash complient) to generate a list of all infos:

#!/bin/ash
for f in ./dnsapi/dns_*.sh
do
  filename=$(basename -- "$f")
  dns_api="${filename%.*}"
  echo "$dns_api"
  dns_api_info_var="${dns_api}_info"
  # shellcheck source=./dnsapi/dns_*.sh
  . "$f"
  info=""
  eval info=\$$dns_api_info_var
  echo "$info"
done

I executed it and stored result to info.txt file:

sh ./dns_info.sh > info.txt

The resulted file has size of 38kb bytes and gziped it's 9kb.

Basically it would be really great to put the info a separate txt file.
For example dns_1984hosting.sh and dns_1984hosting_info.txt.
Then to get list of all params we can just make cat *_info.txt.
Also for limited embedded devices we can not include the info files into a package to save space.
Please tell me if you ok to store the info into a separate text file. Then I'll change the PR. This can double size of files but it should worth it.

For now I'm going to just include the info.txt file into the luci-app-acme and parse it in JS on a broswer side.

@stokito stokito force-pushed the dns_api_info branch 3 times, most recently from 22555b1 to 7c572f1 Compare November 18, 2023 21:22
@stokito
Copy link
Contributor Author

stokito commented Nov 18, 2023

@stokito
Copy link
Contributor Author

stokito commented Mar 30, 2024

Hi @Neilpang I updated the PR and fixed merge conflict. Please merge it before new conflicts happen

Instead of using comments declare info in a special variable.
Then the variable can be used to print the DNS API provider usage.
The usage can be parsed on UI and show all needed inputs for options.

The info is stored in plain string that it's both human-readable and easy to parse:

    dns_example_info='API name
     An extended description.
     Multiline.
    Domains: list of alternative domains to find
    Site: the dns provider website e.g. example.com
    Docs: Link to ACME.sh wiki for the provider
    Options:
     VARIABLE1 Title for the option1.
     VARIABLE2 Title for the option2. Default "default value".
     VARIABLE3 Title for the option3. Description to show on UI. Optional.
    Issues: Link to a support ticket on https://github.com/acmesh-official/acme.sh
    Author: First Lastname <authoremail@example.com>, Another Author <https://github.com/example>;
    '

Here:
VARIABLE1 will be required.
VARIABLE2 will be required too but will be populated with a "default value".
VARIABLE3 is optional and can be empty.

A DNS provider may have alternative options like CloudFlare may use API KEY or API Token.
You can use a second section OptionsAlt: section.

Some providers may have alternative names or domains e.g. Aliyun and AlibabaCloud.
Add them to Domains: section.

Signed-off-by: Sergey Ponomarev <stokito@gmail.com>
@stokito
Copy link
Contributor Author

stokito commented May 18, 2024

Hi @Neilpang I updated (yet again) the PR and fixed merge conflict. Please merge it before new conflicts happen

@Neilpang Neilpang merged commit f7e09af into acmesh-official:dev May 19, 2024
13 checks passed
@stokito stokito deleted the dns_api_info branch May 19, 2024 07:58
@stokito
Copy link
Contributor Author

stokito commented May 19, 2024

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants