flomesh-io / ztm

ZTM (Zero Trust Mesh) is a privacy-first open-source decentralized network software based on HTTP/2 tunnels. Experience boundless connectivity and mesh the globe!
Apache License 2.0
330 stars 30 forks source link

GET /api/meshes/{mesh}/ca error #6

Closed yyk808 closed 5 months ago

yyk808 commented 5 months ago

This seems to be a typo in https://github.com/flomesh-io/ztm/blob/fd82b841fc6dc12df0e0a386c788409bf2b95989/agent/main.js#L110

The property ca isn't stored in obj.config but obj itself directly.

By calling this api, we shall get error log like this:

{ "name": "Error", "message": "cannot read property of undefined", "cause": null, "stack": "In (anonymous function at line 108 column 12) at line 110 column 44 in /main.js\nIn (anonymous function at line 273 column 19) at line 275 column 22 in /main.js\nIn at line 293 column 36 in /main.js\n" }

However, it can be fixed easily. After changing obj.config.ca to obj.ca , everything works fine.

tip:

structure of obj:

{
    "connected": true,
    "errors": [
        "string"
    ],
    "name": "string",
    "ca": "string",
    "agent": {
    "name": "string",
    "id": "string",
    "certificate": "string",
    "privateKey": "string"
    },
    "bootstraps": [
        "string"
    ]
}
pajama-coder commented 5 months ago

Yes, it's a typo. Thanks for your pull request.