mirror of
https://github.com/tobychui/zoraxy.git
synced 2025-06-01 13:17:21 +02:00
Updated code generation tool
- Module rename to acmedns
This commit is contained in:
parent
1d63b679dc
commit
55bc939a37
@ -1,6 +1,6 @@
|
||||
### DNS Challenge Update Data Structure Code Generator
|
||||
|
||||
This script is designed to automatically pull lego, update the providersdef module with new json file and create a function for automatically create a provider based on the given providers name and config json.
|
||||
This script is designed to automatically pull lego, update the `acmedns` module with new json file and create a function for automatically create a provider based on the given providers name and config json.
|
||||
|
||||
### Usage
|
||||
|
||||
@ -10,13 +10,13 @@ To update the module, simply run update.sh
|
||||
./update.sh
|
||||
```
|
||||
|
||||
The updated files will be written into the providersdef folder. Then, you can copy it to the ACME module folder (or later-on a CICD pipeline will be made to do this automatically, but for now you have to manually copy it into the module under `src/mod/`)
|
||||
The updated files will be written into the `acmedns` folder. Then, you can copy it to the ACME module folder (or later-on a CICD pipeline will be made to do this automatically, but for now you have to manually copy it into the module under `src/mod/acme/`)
|
||||
|
||||
|
||||
|
||||
### Module Usage
|
||||
|
||||
To use the module, you can call to the following function inside the providersdef
|
||||
To use the module, you can call to the following function inside the `acmedns`
|
||||
|
||||
```go
|
||||
func GetDNSProviderByJsonConfig(name string, js string)(challenge.Provider, error)
|
||||
|
@ -1,5 +1,8 @@
|
||||
package providerdef
|
||||
|
||||
package acmedns
|
||||
/*
|
||||
THIS MODULE IS GENERATED AUTOMATICALLY
|
||||
DO NOT EDIT THIS FILE
|
||||
*/
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
@ -28,7 +31,6 @@ import (
|
||||
"github.com/go-acme/lego/v4/providers/dns/cpanel"
|
||||
"github.com/go-acme/lego/v4/providers/dns/derak"
|
||||
"github.com/go-acme/lego/v4/providers/dns/desec"
|
||||
"github.com/go-acme/lego/v4/providers/dns/designate"
|
||||
"github.com/go-acme/lego/v4/providers/dns/digitalocean"
|
||||
"github.com/go-acme/lego/v4/providers/dns/dnshomede"
|
||||
"github.com/go-acme/lego/v4/providers/dns/dnsimple"
|
||||
@ -76,7 +78,6 @@ import (
|
||||
"github.com/go-acme/lego/v4/providers/dns/mailinabox"
|
||||
"github.com/go-acme/lego/v4/providers/dns/metaname"
|
||||
"github.com/go-acme/lego/v4/providers/dns/mydnsjp"
|
||||
"github.com/go-acme/lego/v4/providers/dns/mythicbeasts"
|
||||
"github.com/go-acme/lego/v4/providers/dns/namecheap"
|
||||
"github.com/go-acme/lego/v4/providers/dns/namedotcom"
|
||||
"github.com/go-acme/lego/v4/providers/dns/namesilo"
|
||||
@ -296,13 +297,6 @@ func GetDNSProviderByJsonConfig(name string, js string)(challenge.Provider, erro
|
||||
return nil, err
|
||||
}
|
||||
return desec.NewDNSProviderConfig(&cfg)
|
||||
case "designate":
|
||||
cfg := designate.Config{}
|
||||
err := json.Unmarshal([]byte(js), &cfg)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return designate.NewDNSProviderConfig(&cfg)
|
||||
case "digitalocean":
|
||||
cfg := digitalocean.Config{}
|
||||
err := json.Unmarshal([]byte(js), &cfg)
|
||||
@ -632,13 +626,6 @@ func GetDNSProviderByJsonConfig(name string, js string)(challenge.Provider, erro
|
||||
return nil, err
|
||||
}
|
||||
return mydnsjp.NewDNSProviderConfig(&cfg)
|
||||
case "mythicbeasts":
|
||||
cfg := mythicbeasts.Config{}
|
||||
err := json.Unmarshal([]byte(js), &cfg)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return mythicbeasts.NewDNSProviderConfig(&cfg)
|
||||
case "namecheap":
|
||||
cfg := namecheap.Config{}
|
||||
err := json.Unmarshal([]byte(js), &cfg)
|
@ -836,28 +836,6 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
"designate": {
|
||||
"Name": "designate",
|
||||
"ConfigableFields": [],
|
||||
"HiddenFields": [
|
||||
{
|
||||
"Title": "PropagationTimeout",
|
||||
"Datatype": "time.Duration"
|
||||
},
|
||||
{
|
||||
"Title": "PollingInterval",
|
||||
"Datatype": "time.Duration"
|
||||
},
|
||||
{
|
||||
"Title": "TTL",
|
||||
"Datatype": "int"
|
||||
},
|
||||
{
|
||||
"Title": "opts",
|
||||
"Datatype": "gophercloud.AuthOptions"
|
||||
}
|
||||
]
|
||||
},
|
||||
"digitalocean": {
|
||||
"Name": "digitalocean",
|
||||
"ConfigableFields": [
|
||||
@ -2305,45 +2283,6 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
"mythicbeasts": {
|
||||
"Name": "mythicbeasts",
|
||||
"ConfigableFields": [
|
||||
{
|
||||
"Title": "UserName",
|
||||
"Datatype": "string"
|
||||
},
|
||||
{
|
||||
"Title": "Password",
|
||||
"Datatype": "string"
|
||||
},
|
||||
{
|
||||
"Title": "APIEndpoint",
|
||||
"Datatype": "*url.URL"
|
||||
},
|
||||
{
|
||||
"Title": "AuthAPIEndpoint",
|
||||
"Datatype": "*url.URL"
|
||||
}
|
||||
],
|
||||
"HiddenFields": [
|
||||
{
|
||||
"Title": "HTTPClient",
|
||||
"Datatype": "*http.Client"
|
||||
},
|
||||
{
|
||||
"Title": "PropagationTimeout",
|
||||
"Datatype": "time.Duration"
|
||||
},
|
||||
{
|
||||
"Title": "PollingInterval",
|
||||
"Datatype": "time.Duration"
|
||||
},
|
||||
{
|
||||
"Title": "TTL",
|
||||
"Datatype": "int"
|
||||
}
|
||||
]
|
||||
},
|
||||
"namecheap": {
|
||||
"Name": "namecheap",
|
||||
"ConfigableFields": [
|
||||
@ -3087,6 +3026,10 @@
|
||||
}
|
||||
],
|
||||
"HiddenFields": [
|
||||
{
|
||||
"Title": "WaitForRecordSetsChanged",
|
||||
"Datatype": "bool"
|
||||
},
|
||||
{
|
||||
"Title": "TTL",
|
||||
"Datatype": "int"
|
@ -10,9 +10,12 @@ import (
|
||||
)
|
||||
|
||||
var legoProvidersSourceFolder string = "./lego/providers/dns/"
|
||||
var outputDir string = "./providersdef"
|
||||
var defTemplate string = `package providerdef
|
||||
|
||||
var outputDir string = "./acmedns"
|
||||
var defTemplate string = `package acmedns
|
||||
/*
|
||||
THIS MODULE IS GENERATED AUTOMATICALLY
|
||||
DO NOT EDIT THIS FILE
|
||||
*/
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
@ -22,7 +25,7 @@ import (
|
||||
)
|
||||
|
||||
//name is the DNS provider name, e.g. cloudflare or gandi
|
||||
//JSON (js) must be in key-value string, e.g. {"Username":"far","Password":"boo"}
|
||||
//JSON (js) must be in key-value string that match ConfigableFields Title in providers.json, e.g. {"Username":"far","Password":"boo"}
|
||||
func GetDNSProviderByJsonConfig(name string, js string)(challenge.Provider, error){
|
||||
switch name {
|
||||
{{magic}}
|
||||
@ -57,13 +60,15 @@ func fileExists(filePath string) bool {
|
||||
// This function define the DNS not supported by zoraxy
|
||||
func getExcludedDNSProviders() []string {
|
||||
return []string{
|
||||
"edgedns", //Too complex data structure
|
||||
"exec", //Not a DNS provider
|
||||
"httpreq", //Not a DNS provider
|
||||
"hurricane", //Multi-credentials arch
|
||||
"oraclecloud", //Evil company
|
||||
"acmedns", //Not a DNS provider
|
||||
"selectelv2", //Not sure why not working with our code generator
|
||||
"edgedns", //Too complex data structure
|
||||
"exec", //Not a DNS provider
|
||||
"httpreq", //Not a DNS provider
|
||||
"hurricane", //Multi-credentials arch
|
||||
"oraclecloud", //Evil company
|
||||
"acmedns", //Not a DNS provider
|
||||
"selectelv2", //Not sure why not working with our code generator
|
||||
"designate", //OpenStack, if you are using this you shd not be using zoraxy
|
||||
"mythicbeasts", //Module require url.URL, which cannot be automatically parsed
|
||||
}
|
||||
}
|
||||
|
||||
@ -230,6 +235,6 @@ func main() {
|
||||
fullCodeSnippet := strings.ReplaceAll(defTemplate, "{{magic}}", generatedConvertcode)
|
||||
fullCodeSnippet = strings.ReplaceAll(fullCodeSnippet, "{{imports}}", importList)
|
||||
|
||||
os.WriteFile(filepath.Join(outputDir, "providersdef.go"), []byte(fullCodeSnippet), 0775)
|
||||
os.WriteFile(filepath.Join(outputDir, "acmedns.go"), []byte(fullCodeSnippet), 0775)
|
||||
fmt.Println("Output written to file")
|
||||
}
|
||||
|
@ -16,6 +16,11 @@ else
|
||||
fi
|
||||
|
||||
# Run the extract.go to get all the config from lego source code
|
||||
echo "Generating code"
|
||||
go run ./extract.go
|
||||
|
||||
echo "Cleaning up lego"
|
||||
# Comment the line below if you dont want to pull everytime update
|
||||
# This is to help go compiler to not load all the lego source file when compile
|
||||
rm -rf ./lego/
|
||||
echo "Config generated"
|
Loading…
x
Reference in New Issue
Block a user