mirror of
https://github.com/XTLS/Xray-core.git
synced 2026-05-08 14:13:22 +00:00
API: Fix potential nil pointer dereference in executeAddRules() (#5749)
Fixes https://github.com/XTLS/Xray-core/issues/5748 --------- Co-authored-by: 风扇滑翔翼 <Fangliding.fshxy@outlook.com>
This commit is contained in:
@@ -18,6 +18,8 @@ var cmdAddRules = &base.Command{
|
||||
Add routing rules to Xray.
|
||||
|
||||
Arguments:
|
||||
<c1.json> [c2.json]...
|
||||
The configs with the rules to be added. Must be in the xray config format and must have the "routing" field
|
||||
|
||||
-s, -server <server:port>
|
||||
The API server address. Default 127.0.0.1:8080
|
||||
@@ -63,6 +65,11 @@ func executeAddRules(cmd *base.Command, args []string) {
|
||||
if err != nil {
|
||||
base.Fatalf("failed to decode %s: %s", arg, err)
|
||||
}
|
||||
|
||||
if conf.RouterConfig == nil {
|
||||
base.Fatalf("failed to add routing rule: config did not have \"routing\" field")
|
||||
}
|
||||
|
||||
rcs = append(rcs, *conf.RouterConfig)
|
||||
}
|
||||
if len(rcs) == 0 {
|
||||
|
||||
Reference in New Issue
Block a user