Coder Social home page Coder Social logo

Comments (7)

 avatar commented on May 18, 2024

这个问题我之前有仔细想过,前几天加的那些 struct 真的是让人头晕眼花……
Qt有自带的JSON库,这个不是问题,我个人比较喜欢使用强类型的struct + template,你说的 "access": null 确实也很不好看
这个修改提议待定
ADDED: 可能会加到TODO里面

from qv2ray.

 avatar commented on May 18, 2024
{
    "log": {
        "access": "",
        "error": "",
        "loglevel": ""
    },
    "api": {
        "tag": "",
        "services": []
    },
    "dns": {
        "hosts": {},
        "servers": []
    },
    "routing": {
        "domainStrategy": "",
        "rules": [],
        "balancers": []
    },
    "inbounds": [
        {
            "port": 0,
            "listen": "",
            "protocol": "",
            "settings": {
                "timeout": 0,
                "accounts": [],
                "allowTransparent": false,
                "userLevel": 0
            },
            "tag": ""
        }
    ],
    "outbounds": [
        {
            "sendThrough": "",
            "protocol": "",
            "settings": {
                "vnext": [],
                "clients": [],
                "disableInsecureEncryption": false
            },
            "tag": "",
            "streamSettings": {
                "network": "",
                "security": "",
                "sockopt": {
                    "mark": 0,
                    "tcpFastOpen": false,
                    "tproxy": ""
                },
                "tcpSettings": {
                    "header": {
                        "type": "",
                        "request": {
                            "version": "",
                            "method": "",
                            "path": [],
                            "headers": {}
                        },
                        "response": {
                            "version": "",
                            "status": "",
                            "reason": "",
                            "headers": {}
                        }
                    }
                },
                "tlsSettings": {
                    "serverName": "",
                    "allowInsecure": false,
                    "alpn": [],
                    "certificates": [],
                    "disableSystemRoot": false
                },
                "kcpSettings": {
                    "mtu": 0,
                    "tti": 0,
                    "uplinkCapacity": 0,
                    "downlinkCapacity": 0,
                    "congestion": false,
                    "readBufferSize": 0,
                    "writeBufferSize": 0,
                    "header": {
                        "type": ""
                    }
                },
                "wsSettings": {
                    "path": "",
                    "headers": {}
                },
                "httpSettings": {
                    "host": [],
                    "path": ""
                },
                "dsSettings": {
                    "path": ""
                },
                "quicSettings": {
                    "security": "",
                    "key": "",
                    "header": {
                        "type": ""
                    }
                }
            },
            "proxySettings": {
                "tag": ""
            },
            "mux": {
                "enabled": false,
                "concurrency": 0
            }
        }
    ],
    "transport": {
        "tcpSettings": {
            "header": {
                "type": "",
                "request": {
                    "version": "",
                    "method": "",
                    "path": [],
                    "headers": {}
                },
                "response": {
                    "version": "",
                    "status": "",
                    "reason": "",
                    "headers": {}
                }
            }
        },
        "kcpSettings": {
            "mtu": 0,
            "tti": 0,
            "uplinkCapacity": 0,
            "downlinkCapacity": 0,
            "congestion": false,
            "readBufferSize": 0,
            "writeBufferSize": 0,
            "header": {
                "type": ""
            }
        },
        "wsSettings": {
            "path": "",
            "headers": {}
        },
        "httpSettings": {
            "host": [],
            "path": ""
        },
        "dsSettings": {
            "path": ""
        },
        "quicSettings": {
            "security": "",
            "key": "",
            "header": {
                "type": ""
            }
        }
    },
    "stats": {
        "_": false
    },
    "reverse": {
        "bridges": [],
        "portals": []
    },
    "policy": {
        "level": {},
        "system": []
    }
}

目前来讲这个 HTTP 进 VMess 出 的默认空配置 struct JSON 序列化后得到的是以上结果,
如果使用你说的JSON库而不是struct进行操作的话,会出现大量

jsonRootObject["inbounds"][0]["settings"]["vnext"]["uid"] = myUid;
jsonRootObject["inbounds"][0]["settings"]["vnext"]["alterid"] = myAlterid;
......

类似弱类型代码出现,比较不友好

from qv2ray.

 avatar commented on May 18, 2024

另外,削减掉目前没有实现的 RootObject::TransportSettings 后,整个JSON只有 不到 150 行,不存在很难看的 null 现象

v2ray-core的config.json是动态变化的

  • AFAIK,大多数JSON是一次性配置,不会更改很多次

from qv2ray.

 avatar commented on May 18, 2024

Added: 相比于 ‘struct template’ json 确实会方便一些
@ZLplLQc

from qv2ray.

 avatar commented on May 18, 2024

只是个建议。

from qv2ray.

 avatar commented on May 18, 2024

现已决定使用 JSON 库实现配置文件读写
谢谢

from qv2ray.

 avatar commented on May 18, 2024

#18 部分对于类型要求很高的仍然使用了 struct,但主体使用的是 QJsonObject

from qv2ray.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.