fix: when 'data' is nil, panic occurs
https://github.com/MetaCubeX/mihomo/blob/f020b20ab932bd68108fed34323add4d20e7236e/common/structure/structure.go#L74 It has been ensured that the decode input parameter data is not nil. Is there a clear location that causes panic? Could you add a unit test?
https://github.com/MetaCubeX/mihomo/blob/f020b20ab932bd68108fed34323add4d20e7236e/common/structure/structure.go#L251
The location where the panic occurred is /common/structure/structure.go:251. The error reported at that time was because dataVal was Zero, which caused the dataValue.Type() call in the default branch to throw panic. The original error message is
panic: reflect: call of reflect.Value.Type on zero Value
After searching, it was found that the value of h2-opts.path in the configuration was set to nil. The original source of the configuration is not yet known. Related unit tests have been added.
After searching, it was found that the value of
h2-opts.pathin the configuration was set tonil.
It seems that the value in the map is not checked. Just add the check here.https://github.com/MetaCubeX/mihomo/blob/f020b20ab932bd68108fed34323add4d20e7236e/common/structure/structure.go#L370
https://github.com/MetaCubeX/mihomo/commit/3f6823ba49a5f82fa0ca7355ce75a94346d057a2