profile
viewpoint

blitz-js/blitz 2873

⚡️The Fullstack React Framework — built on Next.js

jorgebucaran/awesome-fish 1917

A curated list of packages, prompts, and resources for the fish shell.

sijad/flarum-ext-auth-steam 14

Allow users to log into flarum with their steam account

persianfla/flarum-ext-persian 6

Flarum Persian language pack

sijad/flarum-ext-github-autolink 6

depricated! use https://github.com/FriendsOfFlarum/github-autolink

sijad/certbot-dns-arvancloud 3

please use lego instead

persianfla/flarum-ext-jalali 1

Jalali extension for Flarum

startedpshihn/rough-notation

started time in a day

startedreach/reach-ui

started time in a day

created tagsijad/iran-cities-list

tagv0.0.1

Iran cities in separated json files

created time in 2 days

created tagsijad/iran-cities-list

tag0.0.1

Iran cities in separated json files

created time in 2 days

release sijad/iran-cities-list

0.0.1

released time in 2 days

startedrenatoviolin/next_word_prediction

started time in 2 days

startedbokuweb/react-rnd

started time in 2 days

startedmertJF/tailblocks

started time in 2 days

delete branch sijad/lego

delete branch : arvancloud

delete time in 3 days

pull request commentgo-acme/lego

Add DNS provider for ArvanCloud

Thanks it seems fixed now!

I wish I've seen your changes and didn't waste so many time!

env ARVANCLOUD_API_KEY='Apikey xxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx' ./lego -a --dns arvancloud -d \*.thetangle.ir -d thetangle.ir --email hi@hashemian.me -s https://acme-staging-v02.api.letsencrypt.org/directory run
2020/05/28 19:21:06 [INFO] [*.thetangle.ir, thetangle.ir] acme: Obtaining bundled SAN certificate
2020/05/28 19:21:09 [INFO] [*.thetangle.ir] AuthURL: https://acme-staging-v02.api.letsencrypt.org/acme/authz-v3/59946993
2020/05/28 19:21:09 [INFO] [thetangle.ir] AuthURL: https://acme-staging-v02.api.letsencrypt.org/acme/authz-v3/59946994
2020/05/28 19:21:09 [INFO] [*.thetangle.ir] acme: use dns-01 solver
2020/05/28 19:21:09 [INFO] [thetangle.ir] acme: Could not find solver for: tls-alpn-01
2020/05/28 19:21:09 [INFO] [thetangle.ir] acme: Could not find solver for: http-01
2020/05/28 19:21:09 [INFO] [thetangle.ir] acme: use dns-01 solver
2020/05/28 19:21:09 [INFO] [*.thetangle.ir] acme: Preparing to solve DNS-01
2020/05/28 19:21:24 [INFO] [thetangle.ir] acme: Preparing to solve DNS-01
2020/05/28 19:21:26 [INFO] [*.thetangle.ir] acme: Trying to solve DNS-01
2020/05/28 19:21:26 [INFO] [*.thetangle.ir] acme: Checking DNS record propagation using [8.8.8.8:53 8.8.4.4:53 192.168.43.202:53]
2020/05/28 19:21:26 [INFO] Wait for propagation [timeout: 2m0s, interval: 2s]
2020/05/28 19:21:36 [INFO] [*.thetangle.ir] acme: Waiting for DNS record propagation.
2020/05/28 19:21:49 [INFO] [*.thetangle.ir] acme: Waiting for DNS record propagation.
2020/05/28 19:21:56 [INFO] [*.thetangle.ir] acme: Waiting for DNS record propagation.
2020/05/28 19:22:09 [INFO] [*.thetangle.ir] acme: Waiting for DNS record propagation.
2020/05/28 19:22:24 [INFO] [*.thetangle.ir] The server validated our request
2020/05/28 19:22:24 [INFO] [thetangle.ir] acme: Trying to solve DNS-01
2020/05/28 19:22:24 [INFO] [thetangle.ir] acme: Checking DNS record propagation using [8.8.8.8:53 8.8.4.4:53 192.168.43.202:53]
2020/05/28 19:22:24 [INFO] Wait for propagation [timeout: 2m0s, interval: 2s]
2020/05/28 19:22:28 [INFO] [thetangle.ir] The server validated our request
2020/05/28 19:22:28 [INFO] [*.thetangle.ir] acme: Cleaning DNS-01 challenge
2020/05/28 19:22:29 [INFO] [thetangle.ir] acme: Cleaning DNS-01 challenge
2020/05/28 19:22:31 [INFO] [*.thetangle.ir, thetangle.ir] acme: Validations succeeded; requesting certificates
2020/05/28 19:22:33 [INFO] [*.thetangle.ir] Server responded with a certificate.
sijad

comment created time in 3 days

Pull request review commentgo-acme/lego

Add DNS provider for ArvanCloud

+package internal++import (+	"bytes"+	"encoding/json"+	"fmt"+	"io"+	"io/ioutil"+	"net/http"+	"net/url"+	"path"+)++// defaultBaseURL represents the API endpoint to call.+const defaultBaseURL = "https://napi.arvancloud.com"++const authHeader = "Authorization"++// Client the ArvanCloud client.+type Client struct {+	HTTPClient *http.Client+	BaseURL    string++	apiKey string+}++// NewClient Creates a new ArvanCloud client.+func NewClient(apiKey string) *Client {+	return &Client{+		HTTPClient: http.DefaultClient,+		BaseURL:    defaultBaseURL,+		apiKey:     apiKey,+	}+}++// GetTxtRecord gets a TXT record.+func (c *Client) GetTxtRecord(domain, name, value string) (*DNSRecord, error) {+	records, err := c.getRecords(domain, value)+	if err != nil {+		return nil, err+	}++	for _, record := range records {+		if equalsTXTRecord(record, name, value) {+			return &record, nil+		}+	}++	return nil, fmt.Errorf("could not find record: Domain: %s; Record: %s", domain, name)+}++// https://www.arvancloud.com/docs/api/cdn/4.0#operation/dns_records.list+func (c *Client) getRecords(domain, search string) ([]DNSRecord, error) {+	endpoint, err := c.createEndpoint("cdn", "4.0", "domains", domain, "dns-records")+	if err != nil {+		return nil, fmt.Errorf("failed to create endpoint: %w", err)+	}++	query := endpoint.Query()+	query.Set("search", search)+	endpoint.RawQuery = query.Encode()++	resp, err := c.do(http.MethodGet, endpoint.String(), nil)+	if err != nil {+		return nil, err+	}++	defer func() { _ = resp.Body.Close() }()++	body, err := ioutil.ReadAll(resp.Body)+	if err != nil {+		return nil, fmt.Errorf("failed to read response body: %w", err)+	}++	if resp.StatusCode != http.StatusOK {+		return nil, fmt.Errorf("could not get records %s: Domain: %s; Status: %s; Body: %s",+			search, domain, resp.Status, string(body))+	}++	response := &apiResponse{}+	err = json.Unmarshal(body, response)+	if err != nil {+		return nil, fmt.Errorf("failed to decode response body: %w", err)+	}++	var records []DNSRecord+	err = json.Unmarshal(response.Data, &records)+	if err != nil {+		return nil, fmt.Errorf("failed to decode records: %w", err)+	}++	return records, nil+}++// CreateRecord creates a DNS record.+// https://www.arvancloud.com/docs/api/cdn/4.0#operation/dns_records.create+func (c *Client) CreateRecord(domain string, record DNSRecord) (*DNSRecord, error) {+	reqBody, err := json.Marshal(record)+	if err != nil {+		return nil, err+	}++	endpoint, err := c.createEndpoint("cdn", "4.0", "domains", domain, "dns-records")+	if err != nil {+		return nil, fmt.Errorf("failed to create endpoint: %w", err)+	}++	resp, err := c.do(http.MethodPost, endpoint.String(), bytes.NewReader(reqBody))+	if err != nil {+		return nil, err+	}++	body, err := ioutil.ReadAll(resp.Body)+	if err != nil {+		return nil, fmt.Errorf("failed to read response body: %w", err)+	}++	if resp.StatusCode != http.StatusCreated {+		return nil, fmt.Errorf("could not create record %s; Domain: %s; Status: %s; Body: %s", string(reqBody), domain, resp.Status, string(body))+	}++	response := &apiResponse{}+	err = json.Unmarshal(body, response)+	if err != nil {+		return nil, fmt.Errorf("failed to decode response body: %w", err)+	}++	var newRecord DNSRecord+	err = json.Unmarshal(response.Data, &newRecord)+	if err != nil {+		return nil, fmt.Errorf("failed to decode record: %w", err)+	}++	return &newRecord, nil+}++// DeleteRecord deletes a DNS record.+// https://www.arvancloud.com/docs/api/cdn/4.0#operation/dns_records.remove+func (c *Client) DeleteRecord(domain, id string) error {+	endpoint, err := c.createEndpoint("cdn", "4.0", "domains", domain, "dns-records", id)+	if err != nil {+		return fmt.Errorf("failed to create endpoint: %w", err)+	}++	resp, err := c.do(http.MethodDelete, endpoint.String(), nil)+	if err != nil {+		return err+	}++	if resp.StatusCode != http.StatusOK {+		body, _ := ioutil.ReadAll(resp.Body)+		return fmt.Errorf("could not delete record %s; Domain: %s; Status: %s; Body: %s", id, domain, resp.Status, string(body))+	}++	return nil+}++func (c *Client) do(method, endpoint string, body io.Reader) (*http.Response, error) {+	req, err := http.NewRequest(method, endpoint, body)+	if err != nil {+		return nil, err+	}++	req.Header.Set("Accept", "application/json")+	req.Header.Set("Content-Type", "application/json")

yes, I meant DELETE, that was my mistake, I've fixed it later (which accidentally removed your changes too)

sijad

comment created time in 3 days

Pull request review commentgo-acme/lego

Add DNS provider for ArvanCloud

+package internal++import (+	"bytes"+	"encoding/json"+	"fmt"+	"io"+	"io/ioutil"+	"net/http"+	"net/url"+	"path"+)++// defaultBaseURL represents the API endpoint to call.+const defaultBaseURL = "https://napi.arvancloud.com"++const authHeader = "Authorization"++// Client the ArvanCloud client.+type Client struct {+	HTTPClient *http.Client+	BaseURL    string++	apiKey string+}++// NewClient Creates a new ArvanCloud client.+func NewClient(apiKey string) *Client {+	return &Client{+		HTTPClient: http.DefaultClient,+		BaseURL:    defaultBaseURL,+		apiKey:     apiKey,+	}+}++// GetTxtRecord gets a TXT record.+func (c *Client) GetTxtRecord(domain, name, value string) (*DNSRecord, error) {+	records, err := c.getRecords(domain, value)+	if err != nil {+		return nil, err+	}++	for _, record := range records {+		if equalsTXTRecord(record, name, value) {+			return &record, nil+		}+	}++	return nil, fmt.Errorf("could not find record: Domain: %s; Record: %s", domain, name)+}++// https://www.arvancloud.com/docs/api/cdn/4.0#operation/dns_records.list+func (c *Client) getRecords(domain, search string) ([]DNSRecord, error) {+	endpoint, err := c.createEndpoint("cdn", "4.0", "domains", domain, "dns-records")+	if err != nil {+		return nil, fmt.Errorf("failed to create endpoint: %w", err)+	}++	query := endpoint.Query()+	query.Set("search", search)+	endpoint.RawQuery = query.Encode()++	resp, err := c.do(http.MethodGet, endpoint.String(), nil)+	if err != nil {+		return nil, err+	}++	defer func() { _ = resp.Body.Close() }()++	body, err := ioutil.ReadAll(resp.Body)+	if err != nil {+		return nil, fmt.Errorf("failed to read response body: %w", err)+	}++	if resp.StatusCode != http.StatusOK {+		return nil, fmt.Errorf("could not get records %s: Domain: %s; Status: %s; Body: %s",+			search, domain, resp.Status, string(body))+	}++	response := &apiResponse{}+	err = json.Unmarshal(body, response)+	if err != nil {+		return nil, fmt.Errorf("failed to decode response body: %w", err)+	}++	var records []DNSRecord+	err = json.Unmarshal(response.Data, &records)+	if err != nil {+		return nil, fmt.Errorf("failed to decode records: %w", err)+	}++	return records, nil+}++// CreateRecord creates a DNS record.+// https://www.arvancloud.com/docs/api/cdn/4.0#operation/dns_records.create+func (c *Client) CreateRecord(domain string, record DNSRecord) (*DNSRecord, error) {+	reqBody, err := json.Marshal(record)+	if err != nil {+		return nil, err+	}++	endpoint, err := c.createEndpoint("cdn", "4.0", "domains", domain, "dns-records")+	if err != nil {+		return nil, fmt.Errorf("failed to create endpoint: %w", err)+	}++	resp, err := c.do(http.MethodPost, endpoint.String(), bytes.NewReader(reqBody))+	if err != nil {+		return nil, err+	}++	body, err := ioutil.ReadAll(resp.Body)+	if err != nil {+		return nil, fmt.Errorf("failed to read response body: %w", err)+	}++	if resp.StatusCode != http.StatusCreated {+		return nil, fmt.Errorf("could not create record %s; Domain: %s; Status: %s; Body: %s", string(reqBody), domain, resp.Status, string(body))+	}++	response := &apiResponse{}+	err = json.Unmarshal(body, response)+	if err != nil {+		return nil, fmt.Errorf("failed to decode response body: %w", err)+	}++	var newRecord DNSRecord+	err = json.Unmarshal(response.Data, &newRecord)+	if err != nil {+		return nil, fmt.Errorf("failed to decode record: %w", err)+	}++	return &newRecord, nil+}++// DeleteRecord deletes a DNS record.+// https://www.arvancloud.com/docs/api/cdn/4.0#operation/dns_records.remove+func (c *Client) DeleteRecord(domain, id string) error {+	endpoint, err := c.createEndpoint("cdn", "4.0", "domains", domain, "dns-records", id)+	if err != nil {+		return fmt.Errorf("failed to create endpoint: %w", err)+	}++	resp, err := c.do(http.MethodDelete, endpoint.String(), nil)+	if err != nil {+		return err+	}++	if resp.StatusCode != http.StatusOK {+		body, _ := ioutil.ReadAll(resp.Body)+		return fmt.Errorf("could not delete record %s; Domain: %s; Status: %s; Body: %s", id, domain, resp.Status, string(body))+	}++	return nil+}++func (c *Client) do(method, endpoint string, body io.Reader) (*http.Response, error) {+	req, err := http.NewRequest(method, endpoint, body)+	if err != nil {+		return nil, err+	}++	req.Header.Set("Accept", "application/json")+	req.Header.Set("Content-Type", "application/json")

here:

2020/05/28 18:54:18 No key found for account hi@hashemian.me. Generating a P384 key.
2020/05/28 18:54:18 Saved key to /home/jimc/go/src/github.com/go-acme/lego/cmd/lego/.lego/accounts/acme-staging-v02.api.letsencrypt.org/hi@hashemian.me/keys/hi@hashemian.me.key
2020/05/28 18:54:21 [INFO] acme: Registering account for hi@hashemian.me
!!!! HEADS UP !!!!

Your account credentials have been saved in your Let's Encrypt
configuration directory at "/home/jimc/go/src/github.com/go-acme/lego/cmd/lego/.lego/accounts".

You should make a secure backup of this folder now. This
configuration directory will also contain certificates and
private keys obtained from Let's Encrypt so making regular
backups of this folder is ideal.
2020/05/28 18:54:22 [INFO] [*.thetangle.ir, thetangle.ir] acme: Obtaining bundled SAN certificate
2020/05/28 18:54:25 [INFO] [*.thetangle.ir] AuthURL: https://acme-staging-v02.api.letsencrypt.org/acme/authz-v3/59941157
2020/05/28 18:54:25 [INFO] [thetangle.ir] AuthURL: https://acme-staging-v02.api.letsencrypt.org/acme/authz-v3/59941158
2020/05/28 18:54:25 [INFO] [*.thetangle.ir] acme: use dns-01 solver
2020/05/28 18:54:25 [INFO] [thetangle.ir] acme: Could not find solver for: tls-alpn-01
2020/05/28 18:54:25 [INFO] [thetangle.ir] acme: Could not find solver for: http-01
2020/05/28 18:54:25 [INFO] [thetangle.ir] acme: use dns-01 solver
2020/05/28 18:54:25 [INFO] [*.thetangle.ir] acme: Preparing to solve DNS-01
2020/05/28 18:54:38 [INFO] [thetangle.ir] acme: Preparing to solve DNS-01
2020/05/28 18:54:44 [INFO] [*.thetangle.ir] acme: Trying to solve DNS-01
2020/05/28 18:54:44 [INFO] [*.thetangle.ir] acme: Checking DNS record propagation using [8.8.8.8:53 8.8.4.4:53 192.168.43.202:53]
2020/05/28 18:54:44 [INFO] Wait for propagation [timeout: 2m0s, interval: 2s]
2020/05/28 18:54:46 [INFO] [*.thetangle.ir] acme: Waiting for DNS record propagation.
2020/05/28 18:54:50 [INFO] [*.thetangle.ir] acme: Waiting for DNS record propagation.
2020/05/28 18:54:54 [INFO] [*.thetangle.ir] acme: Waiting for DNS record propagation.
2020/05/28 18:54:58 [INFO] [*.thetangle.ir] acme: Waiting for DNS record propagation.
2020/05/28 18:55:03 [INFO] [*.thetangle.ir] acme: Waiting for DNS record propagation.
2020/05/28 18:55:07 [INFO] [*.thetangle.ir] acme: Waiting for DNS record propagation.
2020/05/28 18:55:11 [INFO] [*.thetangle.ir] acme: Waiting for DNS record propagation.
2020/05/28 18:55:14 [INFO] [*.thetangle.ir] acme: Waiting for DNS record propagation.
2020/05/28 18:55:17 [INFO] [*.thetangle.ir] acme: Waiting for DNS record propagation.
2020/05/28 18:55:24 [INFO] [*.thetangle.ir] acme: Waiting for DNS record propagation.
2020/05/28 18:55:29 [INFO] [*.thetangle.ir] The server validated our request
2020/05/28 18:55:29 [INFO] [thetangle.ir] acme: Trying to solve DNS-01
2020/05/28 18:55:29 [INFO] [thetangle.ir] acme: Checking DNS record propagation using [8.8.8.8:53 8.8.4.4:53 192.168.43.202:53]
2020/05/28 18:55:29 [INFO] Wait for propagation [timeout: 2m0s, interval: 2s]
2020/05/28 18:55:32 [INFO] [thetangle.ir] The server validated our request
2020/05/28 18:55:32 [INFO] [*.thetangle.ir] acme: Cleaning DNS-01 challenge
2020/05/28 18:55:33 [WARN] [*.thetangle.ir] acme: cleaning up failed: arvancloud: failed to delate TXT record: id=5ace4bfb-014c-4362-8f40-0e4e50569118: could not delete record 5ace4bfb-014c-4362-8f40-0e4e50569118; Domain: thetangle.ir; Status: 500 Internal Server Error; Body: {
    "status": false,
    "message": "Internal Server Error"
} 
2020/05/28 18:55:33 [INFO] [thetangle.ir] acme: Cleaning DNS-01 challenge
2020/05/28 18:55:34 [WARN] [thetangle.ir] acme: cleaning up failed: arvancloud: failed to delate TXT record: id=27e49a84-1df4-4bac-ac96-8d7f33cfcb64: could not delete record 27e49a84-1df4-4bac-ac96-8d7f33cfcb64; Domain: thetangle.ir; Status: 500 Internal Server Error; Body: {
    "status": false,
    "message": "Internal Server Error"
} 
2020/05/28 18:55:34 [INFO] [*.thetangle.ir, thetangle.ir] acme: Validations succeeded; requesting certificates
2020/05/28 18:55:36 [INFO] [*.thetangle.ir] Server responded with a certificate.

I'm pretty sure my suggestion fixes it

sijad

comment created time in 3 days

pull request commentgo-acme/lego

Add DNS provider for ArvanCloud

the GetTxtRecord is not used, I replaced it by a map of IDs.

so the 500 cannot be fixed by changing that.

yes that was my mistake but challenges sometimes contains _ and it cause an error too:

{"status":false,"message":"The given data was invalid.","errors":{"search":["The search is invalid."]}}

e.g. https://napi.arvancloud.com/cdn/4.0/domains/thetangle.ir/dns-records?search=YhQB5ZCbhy87MPUUvd2INfU2ZPOLD4RUumZ6Kd7B_TQ

sijad

comment created time in 3 days

Pull request review commentgo-acme/lego

Add DNS provider for ArvanCloud

+package internal++import (+	"bytes"+	"encoding/json"+	"fmt"+	"io"+	"io/ioutil"+	"net/http"+	"net/url"+	"path"+)++// defaultBaseURL represents the API endpoint to call.+const defaultBaseURL = "https://napi.arvancloud.com"++const authHeader = "Authorization"++// Client the ArvanCloud client.+type Client struct {+	HTTPClient *http.Client+	BaseURL    string++	apiKey string+}++// NewClient Creates a new ArvanCloud client.+func NewClient(apiKey string) *Client {+	return &Client{+		HTTPClient: http.DefaultClient,+		BaseURL:    defaultBaseURL,+		apiKey:     apiKey,+	}+}++// GetTxtRecord gets a TXT record.+func (c *Client) GetTxtRecord(domain, name, value string) (*DNSRecord, error) {+	records, err := c.getRecords(domain, value)+	if err != nil {+		return nil, err+	}++	for _, record := range records {+		if equalsTXTRecord(record, name, value) {+			return &record, nil+		}+	}++	return nil, fmt.Errorf("could not find record: Domain: %s; Record: %s", domain, name)+}++// https://www.arvancloud.com/docs/api/cdn/4.0#operation/dns_records.list+func (c *Client) getRecords(domain, search string) ([]DNSRecord, error) {+	endpoint, err := c.createEndpoint("cdn", "4.0", "domains", domain, "dns-records")+	if err != nil {+		return nil, fmt.Errorf("failed to create endpoint: %w", err)+	}++	query := endpoint.Query()+	query.Set("search", search)+	endpoint.RawQuery = query.Encode()++	resp, err := c.do(http.MethodGet, endpoint.String(), nil)+	if err != nil {+		return nil, err+	}++	defer func() { _ = resp.Body.Close() }()++	body, err := ioutil.ReadAll(resp.Body)+	if err != nil {+		return nil, fmt.Errorf("failed to read response body: %w", err)+	}++	if resp.StatusCode != http.StatusOK {+		return nil, fmt.Errorf("could not get records %s: Domain: %s; Status: %s; Body: %s",+			search, domain, resp.Status, string(body))+	}++	response := &apiResponse{}+	err = json.Unmarshal(body, response)+	if err != nil {+		return nil, fmt.Errorf("failed to decode response body: %w", err)+	}++	var records []DNSRecord+	err = json.Unmarshal(response.Data, &records)+	if err != nil {+		return nil, fmt.Errorf("failed to decode records: %w", err)+	}++	return records, nil+}++// CreateRecord creates a DNS record.+// https://www.arvancloud.com/docs/api/cdn/4.0#operation/dns_records.create+func (c *Client) CreateRecord(domain string, record DNSRecord) (*DNSRecord, error) {+	reqBody, err := json.Marshal(record)+	if err != nil {+		return nil, err+	}++	endpoint, err := c.createEndpoint("cdn", "4.0", "domains", domain, "dns-records")+	if err != nil {+		return nil, fmt.Errorf("failed to create endpoint: %w", err)+	}++	resp, err := c.do(http.MethodPost, endpoint.String(), bytes.NewReader(reqBody))+	if err != nil {+		return nil, err+	}++	body, err := ioutil.ReadAll(resp.Body)+	if err != nil {+		return nil, fmt.Errorf("failed to read response body: %w", err)+	}++	if resp.StatusCode != http.StatusCreated {+		return nil, fmt.Errorf("could not create record %s; Domain: %s; Status: %s; Body: %s", string(reqBody), domain, resp.Status, string(body))+	}++	response := &apiResponse{}+	err = json.Unmarshal(body, response)+	if err != nil {+		return nil, fmt.Errorf("failed to decode response body: %w", err)+	}++	var newRecord DNSRecord+	err = json.Unmarshal(response.Data, &newRecord)+	if err != nil {+		return nil, fmt.Errorf("failed to decode record: %w", err)+	}++	return &newRecord, nil+}++// DeleteRecord deletes a DNS record.+// https://www.arvancloud.com/docs/api/cdn/4.0#operation/dns_records.remove+func (c *Client) DeleteRecord(domain, id string) error {+	endpoint, err := c.createEndpoint("cdn", "4.0", "domains", domain, "dns-records", id)+	if err != nil {+		return fmt.Errorf("failed to create endpoint: %w", err)+	}++	resp, err := c.do(http.MethodDelete, endpoint.String(), nil)+	if err != nil {+		return err+	}++	if resp.StatusCode != http.StatusOK {+		body, _ := ioutil.ReadAll(resp.Body)+		return fmt.Errorf("could not delete record %s; Domain: %s; Status: %s; Body: %s", id, domain, resp.Status, string(body))+	}++	return nil+}++func (c *Client) do(method, endpoint string, body io.Reader) (*http.Response, error) {+	req, err := http.NewRequest(method, endpoint, body)+	if err != nil {+		return nil, err+	}++	req.Header.Set("Accept", "application/json")+	req.Header.Set("Content-Type", "application/json")

this is cause the 500 error, GET should not have this header.

	if body != nil {
		req.Header.Set("Content-Type", "application/json")
	}
sijad

comment created time in 3 days

pull request commentgo-acme/lego

Add DNS provider for ArvanCloud

500 error can be fixed by this: https://github.com/go-acme/lego/commit/9ca50e9963c620ace526e870fcee526334d7a613#diff-90d063d641bee15c29d584998b371f9fR137-R139

sijad

comment created time in 3 days

pull request commentgo-acme/lego

Add DNS provider for ArvanCloud

now I get this error:

2020/05/28 18:23:27 [INFO] [*.thetangle.ir, thetangle.ir] acme: Obtaining bundled SAN certificate
2020/05/28 18:23:30 [INFO] [*.thetangle.ir] AuthURL: https://acme-staging-v02.api.letsencrypt.org/acme/authz-v3/59934974
2020/05/28 18:23:30 [INFO] [thetangle.ir] AuthURL: https://acme-staging-v02.api.letsencrypt.org/acme/authz-v3/59934975
2020/05/28 18:23:30 [INFO] [*.thetangle.ir] acme: use dns-01 solver
2020/05/28 18:23:30 [INFO] [thetangle.ir] acme: Could not find solver for: tls-alpn-01
2020/05/28 18:23:30 [INFO] [thetangle.ir] acme: Could not find solver for: http-01
2020/05/28 18:23:30 [INFO] [thetangle.ir] acme: use dns-01 solver
2020/05/28 18:23:30 [INFO] [*.thetangle.ir] acme: Preparing to solve DNS-01
2020/05/28 18:23:50 [INFO] [thetangle.ir] acme: Preparing to solve DNS-01
2020/05/28 18:23:51 [INFO] [*.thetangle.ir] acme: Trying to solve DNS-01
2020/05/28 18:23:51 [INFO] [*.thetangle.ir] acme: Checking DNS record propagation using [8.8.8.8:53 8.8.4.4:53 192.168.43.202:53]
2020/05/28 18:23:51 [INFO] Wait for propagation [timeout: 2m0s, interval: 2s]
2020/05/28 18:24:02 [INFO] [*.thetangle.ir] acme: Waiting for DNS record propagation.
2020/05/28 18:24:15 [INFO] [*.thetangle.ir] acme: Waiting for DNS record propagation.
2020/05/28 18:24:28 [INFO] [*.thetangle.ir] acme: Waiting for DNS record propagation.
2020/05/28 18:24:41 [INFO] [*.thetangle.ir] acme: Waiting for DNS record propagation.
2020/05/28 18:24:50 [INFO] [*.thetangle.ir] The server validated our request
2020/05/28 18:24:50 [INFO] [thetangle.ir] acme: Trying to solve DNS-01
2020/05/28 18:24:50 [INFO] [thetangle.ir] acme: Checking DNS record propagation using [8.8.8.8:53 8.8.4.4:53 192.168.43.202:53]
2020/05/28 18:24:50 [INFO] Wait for propagation [timeout: 2m0s, interval: 2s]
2020/05/28 18:24:58 [INFO] [thetangle.ir] The server validated our request
2020/05/28 18:24:58 [INFO] [*.thetangle.ir] acme: Cleaning DNS-01 challenge
2020/05/28 18:25:00 [WARN] [*.thetangle.ir] acme: cleaning up failed: arvancloud: failed to delate TXT record: id=4c40e758-6b94-4a34-aa77-0909232744ac: could not delete record 4c40e758-6b94-4a34-aa77-0909232744ac; Domain: thetangle.ir; Status: 500 Internal Server Error 
2020/05/28 18:25:00 [INFO] [thetangle.ir] acme: Cleaning DNS-01 challenge
2020/05/28 18:25:01 [WARN] [thetangle.ir] acme: cleaning up failed: arvancloud: failed to delate TXT record: id=7569d7e3-e547-4541-91e9-206fe7883ea2: could not delete record 7569d7e3-e547-4541-91e9-206fe7883ea2; Domain: thetangle.ir; Status: 500 Internal Server Error 
2020/05/28 18:25:01 [INFO] [*.thetangle.ir, thetangle.ir] acme: Validations succeeded; requesting certificates
2020/05/28 18:25:03 [INFO] [*.thetangle.ir] Server responded with a certificate.

please note search parameter can not contain _.

https://github.com/go-acme/lego/commit/9ca50e9963c620ace526e870fcee526334d7a613#diff-90d063d641bee15c29d584998b371f9fR38

BTW I'm sorry about your changes, I didn't noticed them

sijad

comment created time in 3 days

Pull request review commentgo-acme/lego

Add DNS provider for ArvanCloud

+// Package arvancloud implements a DNS provider for solving the DNS-01 challenge using ArvanCloud DNS.+package arvancloud++import (+	"errors"+	"fmt"+	"net/http"+	"strings"+	"sync"+	"time"++	"github.com/go-acme/lego/v3/challenge/dns01"+	"github.com/go-acme/lego/v3/platform/config/env"+	"github.com/go-acme/lego/v3/providers/dns/arvancloud/internal"+)++const minTTL = 600++// Environment variables names.+const (+	envNamespace = "ARVANCLOUD_"++	EnvAPIKey = envNamespace + "API_KEY"++	EnvTTL                = envNamespace + "TTL"+	EnvPropagationTimeout = envNamespace + "PROPAGATION_TIMEOUT"+	EnvPollingInterval    = envNamespace + "POLLING_INTERVAL"+	EnvHTTPTimeout        = envNamespace + "HTTP_TIMEOUT"+)++// Config is used to configure the creation of the DNSProvider.+type Config struct {+	APIKey             string+	PropagationTimeout time.Duration+	PollingInterval    time.Duration+	TTL                int+	HTTPClient         *http.Client+}++// NewDefaultConfig returns a default configuration for the DNSProvider.+func NewDefaultConfig() *Config {+	return &Config{+		TTL:                env.GetOrDefaultInt(EnvTTL, minTTL),+		PropagationTimeout: env.GetOrDefaultSecond(EnvPropagationTimeout, 120*time.Second),+		PollingInterval:    env.GetOrDefaultSecond(EnvPollingInterval, 2*time.Second),+		HTTPClient: &http.Client{+			Timeout: env.GetOrDefaultSecond(EnvHTTPTimeout, 30*time.Second),+		},+	}+}++// DNSProvider implements the challenge.Provider interface.+type DNSProvider struct {+	config *Config+	client *internal.Client++	recordIDs   map[string]string+	recordIDsMu sync.Mutex+}++// NewDNSProvider returns a DNSProvider instance configured for ArvanCloud.+// Credentials must be passed in the environment variable: ARVANCLOUD_API_KEY.+func NewDNSProvider() (*DNSProvider, error) {+	values, err := env.Get(EnvAPIKey)+	if err != nil {+		return nil, fmt.Errorf("arvancloud: %w", err)+	}++	config := NewDefaultConfig()+	config.APIKey = values[EnvAPIKey]++	return NewDNSProviderConfig(config)+}++// NewDNSProviderConfig return a DNSProvider instance configured for ArvanCloud.+func NewDNSProviderConfig(config *Config) (*DNSProvider, error) {+	if config == nil {+		return nil, errors.New("arvancloud: the configuration of the DNS provider is nil")+	}++	if config.APIKey == "" {+		return nil, errors.New("arvancloud: credentials missing")+	}++	if config.TTL < minTTL {+		return nil, fmt.Errorf("arvancloud: invalid TTL, TTL (%d) must be greater than %d", config.TTL, minTTL)+	}++	client := internal.NewClient(config.APIKey)++	if config.HTTPClient != nil {+		client.HTTPClient = config.HTTPClient+	}++	return &DNSProvider{config: config, client: client}, nil+}++// Timeout returns the timeout and interval to use when checking for DNS+// propagation. Adjusting here to cope with spikes in propagation times.+func (d *DNSProvider) Timeout() (timeout, interval time.Duration) {+	return d.config.PropagationTimeout, d.config.PollingInterval+}++// Present creates a TXT record to fulfill the dns-01 challenge.+func (d *DNSProvider) Present(domain, token, keyAuth string) error {+	fqdn, value := dns01.GetRecord(domain, keyAuth)++	authZone, err := getZone(fqdn)+	if err != nil {+		return err+	}++	record := internal.DNSRecord{+		Type:          "txt",+		Name:          d.extractRecordName(fqdn, domain),+		Value:         internal.TXTRecordValue{Text: value},+		TTL:           d.config.TTL,+		UpstreamHTTPS: "default",+		IPFilterMode: &internal.IPFilterMode{+			Count:     "single",+			GeoFilter: "none",+			Order:     "none",+		},+	}++	newRecord, err := d.client.CreateRecord(authZone, record)+	if err != nil {+		return fmt.Errorf("arvancloud: failed to add TXT record: fqdn=%s: %w", fqdn, err)+	}++	d.recordIDsMu.Lock()+	d.recordIDs[token] = newRecord.ID+	d.recordIDsMu.Unlock()++	return nil+}++// CleanUp removes the TXT record matching the specified parameters.+func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error {+	fqdn, _ := dns01.GetRecord(domain, keyAuth)++	authZone, err := getZone(fqdn)+	if err != nil {+		return err+	}++	// gets the record's unique ID from when we created it+	d.recordIDsMu.Lock()+	recordID, ok := d.recordIDs[token]+	d.recordIDsMu.Unlock()+	if !ok {+		return fmt.Errorf("arvancloud: unknown record ID for '%s' '%s'", fqdn, token)+	}++	if err := d.client.DeleteRecord(authZone, recordID); err != nil {+		return fmt.Errorf("arvancloud: failed to delate TXT record: id=%s: %w", recordID, err)+	}++	// deletes record ID from map+	d.recordIDsMu.Lock()+	delete(d.recordIDs, token)+	d.recordIDsMu.Unlock()++	return nil+}++func getZone(fqdn string) (string, error) {

just asking, doesn't effective go discourages this kind of naming?

sijad

comment created time in 3 days

pull request commentgo-acme/lego

Add DNS provider for ArvanCloud

I get this error now:

2020/05/28 18:14:45 No key found for account hi@hashemian.me. Generating a P384 key.
2020/05/28 18:14:45 Saved key to /home/jimc/go/src/github.com/go-acme/lego/cmd/lego/.lego/accounts/acme-staging-v02.api.letsencrypt.org/hi@hashemian.me/keys/hi@hashemian.me.key
2020/05/28 18:14:51 [INFO] acme: Registering account for hi@hashemian.me
!!!! HEADS UP !!!!

Your account credentials have been saved in your Let's Encrypt
configuration directory at "/home/jimc/go/src/github.com/go-acme/lego/cmd/lego/.lego/accounts".

You should make a secure backup of this folder now. This
configuration directory will also contain certificates and
private keys obtained from Let's Encrypt so making regular
backups of this folder is ideal.
2020/05/28 18:14:52 [INFO] [*.thetangle.ir, thetangle.ir] acme: Obtaining bundled SAN certificate
2020/05/28 18:14:54 [INFO] [*.thetangle.ir] AuthURL: https://acme-staging-v02.api.letsencrypt.org/acme/authz-v3/59933345
2020/05/28 18:14:54 [INFO] [thetangle.ir] AuthURL: https://acme-staging-v02.api.letsencrypt.org/acme/authz-v3/59933346
2020/05/28 18:14:54 [INFO] [*.thetangle.ir] acme: use dns-01 solver
2020/05/28 18:14:54 [INFO] [thetangle.ir] acme: Could not find solver for: tls-alpn-01
2020/05/28 18:14:54 [INFO] [thetangle.ir] acme: Could not find solver for: http-01
2020/05/28 18:14:54 [INFO] [thetangle.ir] acme: use dns-01 solver
2020/05/28 18:14:54 [INFO] [*.thetangle.ir] acme: Preparing to solve DNS-01
panic: assignment to entry in nil map

goroutine 1 [running]:
github.com/go-acme/lego/v3/providers/dns/arvancloud.(*DNSProvider).Present(0xc0004dfd20, 0xc000046db0, 0xc, 0xc0005a80c0, 0x2b, 0xc000628000, 0x57, 0xc000046da8, 0x3)
	/home/jimc/go/src/github.com/go-acme/lego/providers/dns/arvancloud/arvancloud.go:132 +0x2de
github.com/go-acme/lego/v3/challenge/dns01.(*Challenge).PreSolve(0xc00036ab40, 0xc000046dd0, 0x7, 0x0, 0xed66af1d4, 0x0, 0xc000046da8, 0x3, 0xc000046db0, 0xc, ...)
	/home/jimc/go/src/github.com/go-acme/lego/challenge/dns01/dns_challenge.go:94 +0x2a1
github.com/go-acme/lego/v3/challenge/resolver.parallelSolve(0xc0004ae240, 0x2, 0x2, 0xc000439ad0)
	/home/jimc/go/src/github.com/go-acme/lego/challenge/resolver/prober.go:135 +0x11c
github.com/go-acme/lego/v3/challenge/resolver.(*Prober).Solve(0xc0000102d8, 0xc0001a0000, 0x2, 0x2, 0x1e, 0xc00018c080)
	/home/jimc/go/src/github.com/go-acme/lego/challenge/resolver/prober.go:84 +0x359
github.com/go-acme/lego/v3/certificate.(*Certifier).Obtain(0xc0004cb530, 0xc00036db80, 0x2, 0x2, 0x1, 0x0, 0x0, 0x0, 0x199, 0xc00059e080, ...)
	/home/jimc/go/src/github.com/go-acme/lego/certificate/certificates.go:114 +0x2da
github.com/go-acme/lego/v3/cmd.obtainCertificate(0xc000474160, 0xc0004dfd00, 0x164fc69, 0x145, 0xc000565768)
	/home/jimc/go/src/github.com/go-acme/lego/cmd/cmd_run.go:166 +0x2d8
github.com/go-acme/lego/v3/cmd.run(0xc000474160, 0x0, 0x2)
	/home/jimc/go/src/github.com/go-acme/lego/cmd/cmd_run.go:84 +0xe6
github.com/urfave/cli.HandleAction(0x12fab00, 0x167a6f8, 0xc000474160, 0xc000474160, 0x0)
	/home/jimc/go/pkg/mod/github.com/urfave/cli@v1.22.1/app.go:523 +0x11a
github.com/urfave/cli.Command.Run(0x15f2212, 0x3, 0x0, 0x0, 0x0, 0x0, 0x0, 0x163e0f8, 0x3a, 0x0, ...)
	/home/jimc/go/pkg/mod/github.com/urfave/cli@v1.22.1/command.go:174 +0x56e
github.com/urfave/cli.(*App).Run(0xc00046a000, 0xc00011c680, 0xd, 0xd, 0x0, 0x0)
	/home/jimc/go/pkg/mod/github.com/urfave/cli@v1.22.1/app.go:276 +0x7ae
main.main()
sijad

comment created time in 3 days

push eventsijad/lego

Sajjad Hashemian

commit sha 537383b15844b10d09c9f810a19334498c956086

Add DNS provider for ArvanCloud

view details

push time in 3 days

pull request commentgo-acme/lego

Add DNS provider for ArvanCloud

env ARVANCLOUD_API_KEY='Apikey xxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx' ./lego -a --dns arvancloud -d *.thetangle.ir -d thetangle.ir --email hi@hashemian.me -s https://acme-staging-v02.api.letsencrypt.org/directory run 2020/05/28 17:43:45 No key found for account hi@hashemian.me. Generating a P384 key. 2020/05/28 17:43:45 Saved key to /home/jimc/go/src/github.com/go-acme/lego/cmd/lego/.lego/accounts/acme-staging-v02.api.letsencrypt.org/hi@hashemian.me/keys/hi@hashemian.me.key 2020/05/28 17:43:50 [INFO] acme: Registering account for hi@hashemian.me !!!! HEADS UP !!!!

Your account credentials have been saved in your Let's Encrypt configuration directory at "/home/jimc/go/src/github.com/go-acme/lego/cmd/lego/.lego/accounts".

You should make a secure backup of this folder now. This configuration directory will also contain certificates and private keys obtained from Let's Encrypt so making regular backups of this folder is ideal. 2020/05/28 17:43:51 [INFO] [.thetangle.ir, thetangle.ir] acme: Obtaining bundled SAN certificate 2020/05/28 17:43:53 [INFO] [.thetangle.ir] AuthURL: https://acme-staging-v02.api.letsencrypt.org/acme/authz-v3/59926102 2020/05/28 17:43:53 [INFO] [thetangle.ir] AuthURL: https://acme-staging-v02.api.letsencrypt.org/acme/authz-v3/59926103 2020/05/28 17:43:53 [INFO] [.thetangle.ir] acme: use dns-01 solver 2020/05/28 17:43:53 [INFO] [thetangle.ir] acme: Could not find solver for: tls-alpn-01 2020/05/28 17:43:53 [INFO] [thetangle.ir] acme: Could not find solver for: http-01 2020/05/28 17:43:53 [INFO] [thetangle.ir] acme: use dns-01 solver 2020/05/28 17:43:53 [INFO] [.thetangle.ir] acme: Preparing to solve DNS-01 2020/05/28 17:44:11 [INFO] [thetangle.ir] acme: Preparing to solve DNS-01 2020/05/28 17:44:13 [INFO] [.thetangle.ir] acme: Trying to solve DNS-01 2020/05/28 17:44:13 [INFO] [.thetangle.ir] acme: Checking DNS record propagation using [8.8.8.8:53 8.8.4.4:53 192.168.43.202:53] 2020/05/28 17:44:13 [INFO] Wait for propagation [timeout: 2m0s, interval: 2s] 2020/05/28 17:44:16 [INFO] [.thetangle.ir] acme: Waiting for DNS record propagation. 2020/05/28 17:44:20 [INFO] [.thetangle.ir] acme: Waiting for DNS record propagation. 2020/05/28 17:44:24 [INFO] [.thetangle.ir] acme: Waiting for DNS record propagation. 2020/05/28 17:44:27 [INFO] [.thetangle.ir] acme: Waiting for DNS record propagation. 2020/05/28 17:44:30 [INFO] [.thetangle.ir] acme: Waiting for DNS record propagation. 2020/05/28 17:44:34 [INFO] [.thetangle.ir] acme: Waiting for DNS record propagation. 2020/05/28 17:44:37 [INFO] [.thetangle.ir] acme: Waiting for DNS record propagation. 2020/05/28 17:44:41 [INFO] [.thetangle.ir] acme: Waiting for DNS record propagation. 2020/05/28 17:44:44 [INFO] [.thetangle.ir] acme: Waiting for DNS record propagation. 2020/05/28 17:44:48 [INFO] [.thetangle.ir] acme: Waiting for DNS record propagation. 2020/05/28 17:44:51 [INFO] [.thetangle.ir] acme: Waiting for DNS record propagation. 2020/05/28 17:44:54 [INFO] [.thetangle.ir] acme: Waiting for DNS record propagation. 2020/05/28 17:44:59 [INFO] [.thetangle.ir] The server validated our request 2020/05/28 17:44:59 [INFO] [thetangle.ir] acme: Trying to solve DNS-01 2020/05/28 17:44:59 [INFO] [thetangle.ir] acme: Checking DNS record propagation using [8.8.8.8:53 8.8.4.4:53 192.168.43.202:53] 2020/05/28 17:44:59 [INFO] Wait for propagation [timeout: 2m0s, interval: 2s] 2020/05/28 17:45:01 [INFO] [thetangle.ir] The server validated our request 2020/05/28 17:45:01 [INFO] [.thetangle.ir] acme: Cleaning DNS-01 challenge 2020/05/28 17:45:04 [INFO] [thetangle.ir] acme: Cleaning DNS-01 challenge 2020/05/28 17:45:15 [INFO] [.thetangle.ir, thetangle.ir] acme: Validations succeeded; requesting certificates 2020/05/28 17:45:17 [INFO] [.thetangle.ir] Server responded with a certificate.

sijad

comment created time in 3 days

push eventsijad/lego

Sajjad Hashemian

commit sha 9ca50e9963c620ace526e870fcee526334d7a613

add arvancloud dns provider

view details

push time in 3 days

pull request commentgo-acme/lego

Add ArvanCloud dns provider

it's ready to be reviewed, I think CI is failing is unrelated to this changes. as there's another PR for ArvanCloud, please let me know if I should make this PR undraft.

sijad

comment created time in 3 days

push eventsijad/lego

Sajjad Hashemian

commit sha b66ae93159b6dc2151c094ab3bbebbbe2a65f125

add arvancloud dns provider

view details

push time in 3 days

push eventsijad/lego

Sajjad Hashemian

commit sha c8306ca3f08e427931dea078f92119d71bdc2bf5

add arvancloud dns provider

view details

push time in 3 days

issue commentgo-acme/lego

[Feature Request] Add support for ArvanCloud

but I already made one #1173, if you were creating this you should've let me know sooner. I've spend hours to create it.

sijad

comment created time in 3 days

PR opened go-acme/lego

Add ArvanCloud dns provider
+665 -0

0 comment

9 changed files

pr created time in 3 days

create barnchsijad/lego

branch : arvancloud

created branch time in 3 days

fork sijad/lego

Let's Encrypt client and ACME library written in Go

https://go-acme.github.io/lego/

fork in 3 days

issue openedgo-acme/lego

[Feature Request] Add support for ArvanCloud

ArvanCloud is a DNS and CDN provider. you can find DNS API here: arvancloud.com/docs/api/cdn/4.0#tag/DNS

I'd add it if that's ok

created time in 3 days

startedmjmlio/mjml

started time in 5 days

create barnchsijad/certbot-dns-arvancloud

branch : master

created branch time in 5 days

created repositorysijad/certbot-dns-arvancloud

created time in 5 days

startedospfranco/rn-macos-menubar-template

started time in 5 days

issue openedcertbot/certbot

DNS plugin for ArvanCloud

ArvanCloud is a DNS and CDN provider. you can find DNS API here: https://www.arvancloud.com/docs/api/cdn/4.0#tag/DNS

created time in 6 days

startedrgommezz/react-native-scroll-bottom-sheet

started time in 7 days

startedmicrosoft/MS-DOS

started time in 7 days

startedpikapkg/snowpack

started time in 9 days

push eventsijad/vegipe.ir

Sajjad Hashemian

commit sha 13c8c4ecb7c545fdeef4789d4b5febb2a5fd6111

fix new recipe link

view details

push time in 10 days

push eventsijad/vegipe.ir

Sajjad Hashemian

commit sha eca18cc3a6e1ccda1cfc461e53105208843337ad

make it beat

view details

Sajjad Hashemian

commit sha 5575cf3c50b4d77267e86d137d887b05c741edd6

pretty links

view details

Sajjad Hashemian

commit sha 7c63651f8f58d6cf17b1d9b32c6d08fcc2340147

get full static

view details

push time in 10 days

startedmanojVivek/responsively-app

started time in 10 days

startedsplitbee/react-notion

started time in 10 days

startedmicrosoft/react-native-macos

started time in 11 days

startedyosoyubik/canvas

started time in 12 days

push eventsijad/vegipe.ir

Sajjad Hashemian

commit sha 8dfd4aead404d8af82184bef9db0d16f3f40d283

add now

view details

Sajjad Hashemian

commit sha 533784996de862708d68c2ff519a1cc3491f35dd

fix font in production

view details

push time in 13 days

create barnchsijad/vegipe.ir

branch : master

created branch time in 13 days

created repositorysijad/vegipe.ir

vegipe.ir source code

created time in 13 days

startedrastikerdar/vazir-font

started time in 13 days

startednearform/graphql-hooks

started time in 14 days

starteddgraph-io/dgraph

started time in 15 days

startedusefathom/fathom

started time in 15 days

issue commentjensneuse/graphql-go-tools

simple http server performance

yes that was faster, but I think it can improved even further:

package main

import (
	"context"
	"encoding/json"
	"fmt"
	"io/ioutil"
	"sync"

	"github.com/gin-gonic/gin"
	"github.com/jensneuse/abstractlogger"
	"github.com/jensneuse/graphql-go-tools/pkg/execution/datasource"
	"github.com/jensneuse/graphql-go-tools/pkg/graphql"
)

func stringify(any interface{}) []byte {
	data, _ := json.Marshal(any)
	return data
}

func ggtHandler() gin.HandlerFunc {
	newEngine := func() *graphql.ExecutionEngine {
		schema, _ := graphql.NewSchemaFromString(`type Query { hello: String}`)
		plannerConfig := datasource.PlannerConfiguration{
			TypeFieldConfigurations: []datasource.TypeFieldConfiguration{
				{
					TypeName:  "query",
					FieldName: "hello",
					Mapping: &datasource.MappingConfiguration{
						Disabled: true,
					},
					DataSource: datasource.SourceConfig{
						Name: "HelloDataSource",
						Config: stringify(datasource.StaticDataSourceConfig{
							Data: "world",
						}),
					},
				},
			},
		}
		engine, _ := graphql.NewExecutionEngine(abstractlogger.NoopLogger, schema, plannerConfig)
		engine.AddDataSource("HelloDataSource", datasource.StaticDataSourcePlannerFactoryFactory{})
		return engine
	}

	ctx := context.Background()
	pool := sync.Pool{
		New: func() interface{} {
			return newEngine()
		},
	}

	return func(c *gin.Context) {
		data, _ := ioutil.ReadAll(c.Request.Body)
		var req graphql.Request
		json.Unmarshal(data, &req)
		engine := pool.Get().(*graphql.ExecutionEngine)
		engine.ExecuteWithWriter(ctx, &req, c.Writer, graphql.ExecutionOptions{})
		pool.Put(engine)
	}
}

func main() {

	r := gin.New()
	r.POST("/graphql", ggtHandler())

	fmt.Println("Now server is running on port 8080")
	fmt.Println("Test with POST      : curl -g --request POST 'http://localhost:8080/graphql?query={hello}'")
	r.Run() // listen and serve on 0.0.0.0:8080
}
wrk -t12 -c400 -d5s --timeout 10s --script=golang/post.lua --latency http://localhost:8080/graphql
Running 5s test @ http://localhost:8080/graphql
  12 threads and 400 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency    25.84ms   35.32ms 382.15ms   85.37%
    Req/Sec     2.76k     0.91k   17.63k    88.32%
  Latency Distribution
     50%    9.94ms
     75%   40.52ms
     90%   73.62ms
     99%  155.48ms
  167347 requests in 5.06s, 22.82MB read
Requests/sec:  33090.04
Transfer/sec:      4.51MB
sijad

comment created time in 16 days

startedfacebookexperimental/Recoil

started time in 16 days

issue openedjensneuse/graphql-go-tools

simple http server performance

I'm trying to add this library to golang-graphql-benchmark. I've created a simple http server but it perform very bad, am i doing this right?

package main

import (
	"encoding/json"
	"fmt"

	"github.com/gin-gonic/gin"
	"github.com/jensneuse/abstractlogger"
	"github.com/jensneuse/graphql-go-tools/pkg/execution"
	"github.com/jensneuse/graphql-go-tools/pkg/execution/datasource"
	"github.com/jensneuse/graphql-go-tools/pkg/http"
)

var schema = []byte(`
schema {
  query: Query
}
type Query {
  hello: String!
}
`)

func toJSON(any interface{}) []byte {
	data, _ := json.Marshal(any)
	return data
}

func ggtHandler() gin.HandlerFunc {
	plannerConfig := datasource.PlannerConfiguration{
		TypeFieldConfigurations: []datasource.TypeFieldConfiguration{
			{
				TypeName:  "Query",
				FieldName: "hello",
				Mapping: &datasource.MappingConfiguration{
					Disabled: true,
				},
				DataSource: datasource.SourceConfig{
					Name: "StaticDataSource",
					Config: toJSON(datasource.StaticDataSourceConfig{
						Data: "world",
					}),
				},
			},
		},
	}
	base, _ := datasource.NewBaseDataSourcePlanner(schema, plannerConfig, abstractlogger.NoopLogger)
	base.RegisterDataSourcePlannerFactory("StaticDataSource", datasource.StaticDataSourcePlannerFactoryFactory{})
	executionHandler := execution.NewHandler(base, nil)
	executionHandler.Handle([]byte("query {hello}"), nil)
	r := http.NewGraphqlHTTPHandlerFunc(executionHandler, abstractlogger.NoopLogger, nil)
	fmt.Println("ok")

	return func(c *gin.Context) {
		r.ServeHTTP(c.Writer, c.Request)
	}
}

func main() {

	r := gin.New()
	r.POST("/graphql", ggtHandler())

	fmt.Println("Now server is running on port 8080")
	fmt.Println("Test with POST      : curl -g --request POST 'http://localhost:8080/graphql?query={hello}'")
	r.Run() // listen and serve on 0.0.0.0:8080
}

graphql-go-tools result:

❯ wrk -t12 -c400 -d5s --timeout 10s --script=golang/post.lua --latency http://localhost:8080/graphql
Running 5s test @ http://localhost:8080/graphql
  12 threads and 400 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency    69.30ms   95.08ms 848.21ms   86.50%
    Req/Sec     1.00k   278.66     2.77k    71.52%
  Latency Distribution
     50%   26.68ms
     75%  109.12ms
     90%  196.78ms
     99%  408.77ms
  59497 requests in 5.09s, 7.60MB read
Requests/sec:  11684.25
Transfer/sec:      1.49MB

gqlgen result:

❯ wrk -t12 -c400 -d5s --timeout 10s --script=golang/post.lua --latency http://localhost:8080/graphql
Running 5s test @ http://localhost:8080/graphql
  12 threads and 400 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency     5.02ms    8.17ms 151.58ms   92.29%
    Req/Sec    10.34k     2.78k   36.27k    84.75%
  Latency Distribution
     50%    2.56ms
     75%    7.05ms
     90%   12.13ms
     99%   27.94ms
  631983 requests in 5.10s, 80.76MB read
Requests/sec: 123909.34
Transfer/sec:     15.83MB

created time in 16 days

issue commentjensneuse/graphql-go-tools

question about implementing dynamic data sources

I'm trying to add this library to golang-graphql-benchmark. I've created a simple http server but it perform very bad, am i doing this right?

package main

import (
	"encoding/json"
	"fmt"

	"github.com/gin-gonic/gin"
	"github.com/jensneuse/abstractlogger"
	"github.com/jensneuse/graphql-go-tools/pkg/execution"
	"github.com/jensneuse/graphql-go-tools/pkg/execution/datasource"
	"github.com/jensneuse/graphql-go-tools/pkg/http"
)

var schema = []byte(`
schema {
  query: Query
}
type Query {
  hello: String!
}
`)

func toJSON(any interface{}) []byte {
	data, _ := json.Marshal(any)
	return data
}

func ggtHandler() gin.HandlerFunc {
	plannerConfig := datasource.PlannerConfiguration{
		TypeFieldConfigurations: []datasource.TypeFieldConfiguration{
			{
				TypeName:  "Query",
				FieldName: "hello",
				Mapping: &datasource.MappingConfiguration{
					Disabled: true,
				},
				DataSource: datasource.SourceConfig{
					Name: "StaticDataSource",
					Config: toJSON(datasource.StaticDataSourceConfig{
						Data: "world",
					}),
				},
			},
		},
	}
	base, _ := datasource.NewBaseDataSourcePlanner(schema, plannerConfig, abstractlogger.NoopLogger)
	base.RegisterDataSourcePlannerFactory("StaticDataSource", datasource.StaticDataSourcePlannerFactoryFactory{})
	executionHandler := execution.NewHandler(base, nil)
	executionHandler.Handle([]byte("query {hello}"), nil)
	r := http.NewGraphqlHTTPHandlerFunc(executionHandler, abstractlogger.NoopLogger, nil)
	fmt.Println("ok")

	return func(c *gin.Context) {
		r.ServeHTTP(c.Writer, c.Request)
	}
}

func main() {

	r := gin.New()
	r.POST("/graphql", ggtHandler())

	fmt.Println("Now server is running on port 8080")
	fmt.Println("Test with POST      : curl -g --request POST 'http://localhost:8080/graphql?query={hello}'")
	r.Run() // listen and serve on 0.0.0.0:8080
}

graphql-go-tools result:

❯ wrk -t12 -c400 -d5s --timeout 10s --script=golang/post.lua --latency http://localhost:8080/graphql
Running 5s test @ http://localhost:8080/graphql
  12 threads and 400 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency    69.30ms   95.08ms 848.21ms   86.50%
    Req/Sec     1.00k   278.66     2.77k    71.52%
  Latency Distribution
     50%   26.68ms
     75%  109.12ms
     90%  196.78ms
     99%  408.77ms
  59497 requests in 5.09s, 7.60MB read
Requests/sec:  11684.25
Transfer/sec:      1.49MB

gqlgen result:

❯ wrk -t12 -c400 -d5s --timeout 10s --script=golang/post.lua --latency http://localhost:8080/graphql
Running 5s test @ http://localhost:8080/graphql
  12 threads and 400 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency     5.02ms    8.17ms 151.58ms   92.29%
    Req/Sec    10.34k     2.78k   36.27k    84.75%
  Latency Distribution
     50%    2.56ms
     75%    7.05ms
     90%   12.13ms
     99%   27.94ms
  631983 requests in 5.10s, 80.76MB read
Requests/sec: 123909.34
Transfer/sec:     15.83MB
sijad

comment created time in 16 days

issue commentjensneuse/graphql-go-tools

question about implementing dynamic data sources

thanks, I'm looking for a way to pass an struct instance (e.g. f *Friend) to datasource resolver (e.g. func (f *Friend) FullName() string) or func FullName(f *Friend) string)) resolver should be able to access to the object instance somehow, one way might be to recreate TypeFieldConfiguration with each request and pass the instance via config, I'm note sure how efficient that'd be though or is there a better way?

sijad

comment created time in 17 days

issue openedjensneuse/graphql-go-tools

question about implementing dynamic data sources

I'm trying to create dynamic data source to be able define resolvers similar to samsarahq/thunder:

type Friend struct {
  FirstName string
  LastName string
}

func (f *Friend) FullName() string {
  return fmt.Sprintf("%s %s", f.FirstName, f.LastName)
}

I need to pass parent value (f *Friend) to its resolvers, but I'm not sure how this can be implemented using TypeFieldConfiguration and datasources.

I really appreciate any hints or examples.

created time in 17 days

startedrealadvisor/rgm

started time in 17 days

issue openedappleboy/golang-graphql-benchmark

more complex query for benchmark

can you please use a more complex query and schema for benchmark?

created time in 19 days

startedappleboy/golang-graphql-benchmark

started time in 19 days

startedcnlohr/rawdrawandroid

started time in 19 days

startedadi1090x/CustomArch

started time in 19 days

startedsphawes/index

started time in 19 days

startedskypjack/entt

started time in 19 days

startedyemount/pose-animator

started time in 19 days

push eventsijad/gentle

Sajjad Hashemian

commit sha 1fffc4c73442aa243f0b323698727ac67ba87906

remove redunant file

view details

push time in 21 days

push eventsijad/gentle

Sajjad Hashemian

commit sha 79458dc27b6fc0cd3ca9631f5d44de255dcb28a7

init

view details

push time in 21 days

create barnchsijad/gentle

branch : master

created branch time in 21 days

created repositorysijad/gentle

WIP

created time in 21 days

startedKDE/krita

started time in 25 days

startedyahoo/elide

started time in 25 days

startedhayes/giraphql

started time in 25 days

startedphuoc-ng/1loc

started time in a month

startedcyrildiagne/ar-cutpaste

started time in a month

startedpoloclub/cnn-explainer

started time in a month

startedthebuilder/react-intersection-observer

started time in a month

issue commentfacebookincubator/ent

Exception Translation

I found it here 🤫. it might be outdated.

cliedeman

comment created time in a month

startedpodgorskiy/ALAE

started time in a month

startedMichalLytek/type-graphql

started time in a month

startednvim-treesitter/completion-treesitter

started time in a month

issue openedprisma/prisma-client-js

Ability to add hooks for CRUD query builder

Problem

currently it's not possible to add hooks to alter queries (e.g. add where conditions). this feature is need for example to implement authorization in model level.

Solution

adding hooks for CRUD functions to add conditions would allow implementing privacy in model level.

Additional context

ent has privacy which allows to define permissions in data models. prisma should allow something similar.

created time in a month

issue closedfacebookincubator/ent

Feature: Computed fields

add ability to add virtual fields to Models which are not stored in database.

// ent/schema/user.go

type User struct {
	ent.Schema
}

// Fields of the User.
func (User) Fields() []ent.Field {
	return []ent.Field{
		field.String("first_name").,
		field.String("last_name"),
		field.String("full_name").Computed()
	}
}

// ent/user_resolvers.go

func UserFullNameResolver(u User) string {
  return u.firstName + " " + u.lastName
}

closed time in a month

sijad

issue commentfacebookincubator/ent

Feature: Computed fields

yes, I'm not sure why I didn't find it sooner... thanks!

sijad

comment created time in a month

issue openedprisma/prisma

Ability to add hooks for CRUD query builder

Problem

currently it's not possible to add hooks to alter queries (e.g. add where conditions). this feature is need for example to implement authorization in model level.

Solution

adding hooks for CRUD functions to add conditions would allow implementing privacy in model level.

Additional context

ent has privacy which allows to define permissions in data models. prisma should allow something similar.

created time in a month

issue openedfacebookincubator/ent

Feature: Computed fields

add ability to add virtual fields to Models which are not stored in database.

// ent/schema/user.go

type User struct {
	ent.Schema
}

// Fields of the User.
func (User) Fields() []ent.Field {
	return []ent.Field{
		field.String("first_name").,
		field.String("last_name"),
		field.String("full_name").Computed()
	}
}

// ent/user_resolvers.go

func UserFullNameResolver(u User) string {
  return u.firstName + " " + u.lastName
}

created time in a month

startedgraphql-nexus/nexus

started time in a month

startedzeusdeux/use-is-in-viewport

started time in a month

startedresume/resume.github.com

started time in a month

startedbansal-io/pattern.css

started time in a month

issue commentblitz-js/blitz

Fix CLI test failure — always fails on first test run

I can't reproduce this, is this fixed?

flybayer

comment created time in a month

startedsnowjs/cli

started time in a month

startedurbit/sigil-js

started time in a month

startedbikeshaving/crank

started time in a month

issue commentblitz-js/blitz

Don't run the lambda warming code if not serverless

I can take this if you want

flybayer

comment created time in a month

push eventsijad/test-store

Sajjad Hashemian

commit sha c18d723e111996563a966e3e87f93bee0aea3b19

test

view details

push time in a month

create barnchsijad/test-store

branch : master

created branch time in a month

created repositorysijad/test-store

created time in a month

startedkutlugsahin/react-smooth-dnd

started time in a month

pull request commentblitz-js/blitz

Generate prisma client into project instead of node_modules

is it possible to download possible binaries using @prisma/fetch-engine and include all of them in production?

flybayer

comment created time in a month

pull request commentblitz-js/blitz

Generate prisma client into project instead of node_modules

this can be related to https://github.com/zeit/now/issues/2824

flybayer

comment created time in a month

pull request commentblitz-js/blitz

Generate prisma client into project instead of node_modules

can I take a look? if yes, let me know how can I reproduce it please

flybayer

comment created time in a month

more