-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
676 additions
and
551 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
registry=https://registry.npmmirror.com |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
image=apisix-acme:2.1.1 | ||
image=apisix-acme:2.2.0 | ||
|
||
input=$1 | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import axios from 'axios' | ||
import config from '../config.js' | ||
|
||
/** | ||
* 列出所有证书 | ||
* @typedef {{id: string, snis: Array<string>, validity_start: number, validity_end: number}} Item | ||
* @returns {Promise<Array<Item>>} | ||
*/ | ||
async function sslList() { | ||
const resp = await axios.request({ | ||
method: 'GET', | ||
headers: { 'X-API-KEY': config.apisix_token }, | ||
url: `${config.apisix_host}/apisix/admin/ssl` | ||
}) | ||
|
||
const { data } = resp | ||
const nodes = [] | ||
const results = [] | ||
|
||
if (data.node && data.node.nodes) { | ||
nodes.push(...data.node.nodes) | ||
} | ||
|
||
nodes.forEach(node => { | ||
const item = node.value || {} | ||
if (!item.snis) return | ||
|
||
results.push({ | ||
id: item.id, | ||
snis: item.snis, | ||
validity_start: item.validity_start, | ||
validity_end: item.validity_end | ||
}) | ||
}) | ||
|
||
return results | ||
} | ||
|
||
/** | ||
* 设置证书 | ||
* @param {string} id | ||
* @param {{snis: Array<string>, cert: string, key: string, validity_start: number, validity_end: number}} data | ||
* @returns {Promise<void>} | ||
*/ | ||
async function setupSsl(id, data) { | ||
return axios.request({ | ||
method: 'PUT', | ||
headers: { 'X-API-KEY': config.apisix_token }, | ||
url: `${config.apisix_host}/apisix/admin/ssl/${id}`, | ||
data | ||
}) | ||
} | ||
|
||
export default { | ||
sslList, | ||
setupSsl | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import axios from 'axios' | ||
import config from '../config.js' | ||
|
||
/** | ||
* 列出所有证书 | ||
* @typedef {{id: string, snis: Array<string>, validity_start: number, validity_end: number}} Item | ||
* @returns {Promise<Array<Item>>} | ||
*/ | ||
async function sslList() { | ||
const resp = await axios.request({ | ||
method: 'GET', | ||
headers: { 'X-API-KEY': config.apisix_token }, | ||
url: `${config.apisix_host}/apisix/admin/ssls` | ||
}) | ||
|
||
const { data } = resp | ||
const nodes = [] | ||
const results = [] | ||
|
||
if (Array.isArray(data.list)) { | ||
nodes.push(...data.list) | ||
} | ||
|
||
nodes.forEach(node => { | ||
const item = node.value || {} | ||
if (!item.snis) return | ||
|
||
results.push({ | ||
id: item.id, | ||
snis: item.snis, | ||
validity_start: item.validity_start, | ||
validity_end: item.validity_end | ||
}) | ||
}) | ||
|
||
return results | ||
} | ||
|
||
/** | ||
* 设置证书 | ||
* @param {string} id | ||
* @param {{snis: Array<string>, cert: string, key: string, validity_start: number, validity_end: number}} data | ||
* @returns {Promise<void>} | ||
*/ | ||
async function setupSsl(id, data) { | ||
return axios.request({ | ||
method: 'PUT', | ||
headers: { 'X-API-KEY': config.apisix_token }, | ||
url: `${config.apisix_host}/apisix/admin/ssls/${id}`, | ||
data | ||
}) | ||
} | ||
|
||
export default { | ||
sslList, | ||
setupSsl | ||
} |
Oops, something went wrong.