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

Feature: Add new version API dns SELECTEL dns_selectel.sh (actual v2) #5128

Open
wants to merge 21 commits into
base: dev
Choose a base branch
from

Conversation

vlad-kms
Copy link

@vlad-kms vlad-kms commented Apr 30, 2024

This set of changes expands the existing Selectel DNS API script dns_selectel.sh to support the Selectel API version v2 (actual).
Now SELECTEL simultaneously works with two versions of the API: legacy DNS API and actual DNS API (new). The goal is to allow SELECTEL users to use the script for two versions.

https://developers.selectel.ru/docs/cloud-services/dns_api/dns_api_actual/

Issue: #5126

For existing installations where only the old version of the API (legacy) is used, nothing will have to be reconfigured and nothing needs to be done for older versions.

Variables that need to be controlled before starting:

export SL_Ver="v1" -- version API: 'v2' (actual) or 'v1' (legacy).
default: v1

If SL_Ver is equal "v1", then you need to define the variable

export SL_Key="API_KEY" -- token Selectel (API key)
You can view or create it in the control panel in the upper right corner, open the Profile and Settings menu -> API Keys.
https://my.selectel.ru/profile/apikeys

If SL_Ver is equal "v2", then you need to define the following variables

export SL_Expire=60 -- token lifetime in minutes (0-1440).
default: 1400 minutes
export SL_Login_ID=<account_id> -- account number in the control panel;
export SL_Project_Name=<project_name> -- name project.
export SL_Login_Name=<login_name> - service user name.
You can view the name in the control panel:
in the upper right corner, open the menu ? Profile and settings ? User management section ? Service users tab
export SL_Pswd=<> - The service user password can be viewed when creating a user or changed to a new one.
All these variables will be saved in ~/.acme.sh/account.conf and will be reused as needed.

Tests: https://github.com/vlad-kms/acme.sh/actions
For two versions:
test DNS for v1 (legacy) - for version API DNS legacy
test DNS for v2 (actual) - for version API DNS actual (new)

Copy link

Welcome
First thing: don't send PR to the master branch, please send to the dev branch instead.
Please make sure you've read our DNS API Dev Guide and DNS-API-Test.
Then reply on this message, otherwise, your code will not be reviewed or merged.
We look forward to reviewing your Pull request shortly ✨
注意: 必须通过了 DNS-API-Test 才会被 review. 无论是修改, 还是新加的 dns api, 都必须确保通过这个测试.

@vlad-kms vlad-kms changed the title Feature: Add new version API dns (actual) Feature: Add new version API dns SELECTEL (actual) Apr 30, 2024
@vlad-kms vlad-kms changed the title Feature: Add new version API dns SELECTEL (actual) Feature: Add new version API dns SELECTEL dns_selectel.sh (actual v2) Apr 30, 2024
@vlad-kms
Copy link
Author

Tests: https://github.com/vlad-kms/acme.sh/actions
For two versions:
test DNS for v1 (legacy) - for version API DNS legacy
test DNS for v2 (actual) - for version API DNS actual (new)

@vlad-kms
Copy link
Author

Welcome First thing: don't send PR to the master branch, please send to the dev branch instead. Please make sure you've read our DNS API Dev Guide and DNS-API-Test. Then reply on this message, otherwise, your code will not be reviewed or merged. We look forward to reviewing your Pull request shortly ✨ 注意: 必须通过了 DNS-API-Test 才会被 review. 无论是修改, 还是新加的 dns api, 都必须确保通过这个测试.

Tests: https://github.com/vlad-kms/acme.sh/actions
For two versions:
test DNS for v1 (legacy) - for version API DNS legacy
test DNS for v2 (actual) - for version API DNS actual (new)

@mrPsycho
Copy link

mrPsycho commented May 4, 2024

as i understand, comments should be on english, so others can understand it.

but anyway, this is good one!

@vlad-kms
Copy link
Author

vlad-kms commented May 4, 2024

as i understand, comments should be on english, so others can understand it.

but anyway, this is good one!

Translated comments into English. Sorry, I don’t know the language, Google translated it worked.

@rzolotuhin
Copy link

@vlad-kms You have a typo in the case of the character of the name of the variable SL_Login_name, which is used in the comments to the account.conf file. This will result in the exception "You did not specify the selectel.ru API service username." for anyone who will follow the instructions.

@vlad-kms
Copy link
Author

@vlad-kms You have a typo in the case of the character of the name of the variable SL_Login_name, which is used in the comments to the account.conf file. This will result in the exception "You did not specify the selectel.ru API service username." for anyone who will follow the instructions.

Sorry! Corrected in the comments

@vlad-kms
Copy link
Author

@vlad-kms You have a typo in the case of the character of the name of the variable SL_Login_name, which is used in the comments to the account.conf file. This will result in the exception "You did not specify the selectel.ru API service username." for anyone who will follow the instructions.

Please tell me, did you replace the variable name with SL_Login_Name, checked after that?

@rzolotuhin
Copy link

@vlad-kms You have a typo in the case of the character of the name of the variable SL_Login_name, which is used in the comments to the account.conf file. This will result in the exception "You did not specify the selectel.ru API service username." for anyone who will follow the instructions.

Please tell me, did you replace the variable name with SL_Login_Name, checked after that?

Yes, I fixed and checked it locally, everything works. Sorry for the long answer, I did not enter this request after that.

dnsapi/dns_selectel.sh Outdated Show resolved Hide resolved
@alekho
Copy link

alekho commented Jul 23, 2024

@vlad-kms @rzolotuhin Hello. Guys, if I understand correctly, everything works. And did you pass the tests? Продублирую на русском. Не очень понимаю, почему все остановилось, я так понимаю все тесты пройдены, перенес все на новый DNS-хостинг, и старый API уже не работает ((((

@mrPsycho
Copy link

@alekho final review by @Neilpang is needed.

@vlad-kms
Copy link
Author

@vlad-kms @rzolotuhin Hello. Guys, if I understand correctly, everything works. And did you pass the tests? Продублирую на русском. Не очень понимаю, почему все остановилось, я так понимаю все тесты пройдены, перенес все на новый DNS-хостинг, и старый API уже не работает ((((

@alekho
Есть два варианта:

  1. создать поддомен 3-го уровня в своем домене в legacy (API v1) и использовать его режиме alias mode https://github.com/acmesh-official/acme.sh/wiki/DNS-alias-mode;
  2. пройти на https://github.com/vlad-kms/acme_sh-dns_selectel_v2. там в README последний абзац "Инсталляция" прочитать.

@alekho
Copy link

alekho commented Jul 23, 2024

@vlad-kms @rzolotuhin Hello. Guys, if I understand correctly, everything works. And did you pass the tests? Продублирую на русском. Не очень понимаю, почему все остановилось, я так понимаю все тесты пройдены, перенес все на новый DNS-хостинг, и старый API уже не работает ((((

@alekho Есть два варианта:

1. создать поддомен 3-го уровня в своем домене в legacy (API v1) и использовать его режиме alias mode https://github.com/acmesh-official/acme.sh/wiki/DNS-alias-mode;

2. пройти на https://github.com/vlad-kms/acme_sh-dns_selectel_v2. там в README последний абзац "Инсталляция" прочитать.

Благодарю!

@Neilpang
Copy link
Member

Neilpang commented Nov 3, 2024

@valentin85-ru
Copy link

valentin85-ru commented Dec 3, 2024

@vlad-kms , Hi, it's not worked for me. Or I just don't understand how I can make it work... I have put the file into acme.sh directory of my docker and ran "acme.sh --issue --dns dns_selectel -d --keylength 2048". I've pointed SL_Ver="v2" but it still use "v1" because asked me to point the SL_Key "You don't specify selectel.ru api key yet.". And I've pointed it. Then I got "invalid domain". Now I don't now what else can I do. I've tried with 2 and 3 level domains it's the same.
And please tell will it work with wildcard?

@valentin85-ru
Copy link

valentin85-ru commented Dec 3, 2024

@vlad-kms , Hi, it's not worked for me. Or I just don't understand how I can make it work... I have put the file into acme.sh directory of my docker and ran "acme.sh --issue --dns dns_selectel -d --keylength 2048". I've pointed SL_Ver="v2" but it still use "v1" because asked me to point the SL_Key "You don't specify selectel.ru api key yet.". And I've pointed it. Then I got "invalid domain". Now I don't now what else can I do. I've tried with 2 and 3 level domains it's the same. And please tell will it work with wildcard?

I figured out what was going on. it was necessary to properly mount the docker folder with apidns and put the updated dns_selectel file there. Everything is working now.

P.S. I'm using acme.sh docker on Synology.

@vlad-kms
Copy link
Author

vlad-kms commented Dec 3, 2024

@valentin85-ru

Thank you, good thing we figured it out. And it works with wildcard

@sas1024
Copy link

sas1024 commented Dec 20, 2024

Hello, is there any news about this PR?
May be it's time to merge it?

@TerAnYu
Copy link

TerAnYu commented Dec 20, 2024

I have been using this change for a long time, and everything works perfectly. Selectel has announced that the old version of the protocol will no longer be supported: https://hosting.kitchen/selectel/vazhnaya-informaciya-o-zavershenii-podderzhki-legacy-dns-hostinga.html (Unfortunately, Selectel does not publish this information on their website and only sends it via email).


Давно пользуюсь этим изменением и всё работает отлично.
Selectel объявили, что старая версия протокола больше не будет работать: https://hosting.kitchen/selectel/vazhnaya-informaciya-o-zavershenii-podderzhki-legacy-dns-hostinga.html
(к большому сожалению, selectel не размещает эту информацию на своём сайте, а присылает email).

@vlad-kms
Copy link
Author

@Neilpang

https://github.com/vlad-kms/acme.sh/actions/runs/11447191861

What's wrong here? Everything seemed to work.

return 1
fi

_debug3 SL_Ver "$SL_Ver"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't use debug3, please use debug2

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix. Replaced 'debug3' with 'debug2'

@@ -1,14 +1,29 @@
#!/usr/bin/env sh
# shellcheck disable=SC2034
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

keep these descriptions.

Copy link
Author

@vlad-kms vlad-kms Dec 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix. keep description

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean keep these content:

dns_selectel_info='Selectel.com
Domains: Selectel.ru
Site: Selectel.com
Docs: github.com/acmesh-official/acme.sh/wiki/dnsapi#dns_selectel
Options:
 SL_Key API Key
'

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Corrected and left this content

_domain=$h
_debug "Getting domain id for $h"
if ! _sl_rest GET "/$h"; then
i=2
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i starts from 1, not 2

Copy link
Author

@vlad-kms vlad-kms Dec 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Neilpang
Here the parent domain is calculated in a loop. And in this algorithm, the first step must start with 2, not 1. Why check the record, for example _acme-challenge.dom2.dom1.ru. And it is checked right away dom2.dom1.ru

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know what it's doing. make it start from 1.
because we need to support dns alias mode:
https://github.com/acmesh-official/acme.sh/wiki/DNS-alias-mode

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know what it's doing. make it start from 1. because we need to support dns alias mode: https://github.com/acmesh-official/acme.sh/wiki/DNS-alias-mode

Sorry! I only read the phrase "Don't use the domain name only for --domain-alias", and then missed it
I corrected and checked both --challenge-alias and --domain-alias , but only for api version v2. I didn't change it for v1 because there is no way to check. I transferred all my domains to v2 , but I can't add a new domain for the legacy version. And then, this algorithm for v1 was taken from the old file, and it starts with 2.

@Neilpang
Copy link
Member

Vladimir Alexeev and others added 2 commits December 23, 2024 14:50
fix
  don't use debug3, use debug2
  add # shellcheck disable=SC2034
@vlad-kms
Copy link
Author

vlad-kms commented Dec 23, 2024

@Neilpang

update the usage here:

https://github.com/acmesh-official/acme.sh/wiki/dnsapi#dns_selectel

And here you can't edit after the merge?

I left this as a draft:
For existing installations that only use the old API version (legacy), you don't have to reconfigure anything and you don't have to do anything.
Variables to monitor before launch:
export SL_Ver="v1" -- API version: 'v2' (current) or 'v1' (legacy).
default: v1

If SL_Ver is "v1",
then you need to define the variable
export SL_Key="API_KEY" -- Selectel token (API key)

You can view or create it in the control panel in the upper right corner, by opening the Profile and settings -> API keys menu.
https://my.selectel.ru/profile/apikeys

If SL_Ver is "v2", then you need to define the following variables

export SL_Expire=60 -- token lifetime in minutes (0-1440).
by default: 1400 minutes

export SL_Login_ID=<account_id> -- account number in the control panel;

export SL_Project_Name=<project_name> -- project name.

export SL_Login_Name=<login_name> - service user name.

You can see the name in the control panel:
"Аккаунт" -> "Управление пользователями" > "Сервисные пользователи"
"Account" -> "User Management" > "Service Users"
(https://my.selectel.ru/iam/users_management/users?type=service)

export SL_Pswd=<> -- User Password

You can see the password either when creating a user, or change it to a new one.

All these variables will be saved in ~/.acme.sh/account.conf and will be reused as needed.

Note: legacy version of api v1 will be disabled from 09.2025 according to the support service

@Neilpang
Copy link
Member

edit the usage before it's merged.

@vlad-kms
Copy link
Author

edit the usage before it's merged.

Edited by

Vladimir Alexeev added 2 commits December 26, 2024 08:12
# dns_selectel_info='Selectel.com
# Domains: Selectel.ru
# Site: Selectel.com
# Docs: github.com/acmesh-official/acme.sh/wiki/dnsapi#dns_selectel
# Options:
# Variables that must be defined before running
# dns_selectel_info='Selectel.com
# Domains: Selectel.ru
# Site: Selectel.com
# Docs: github.com/acmesh-official/acme.sh/wiki/dnsapi#dns_selectel
# Options:
# Variables that must be defined before running
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.

9 participants