yichya / luci-app-xray

(Almost) full feature Xray client for OpenWrt
Mozilla Public License 2.0
543 stars 317 forks source link

panic: runtime error: invalid memory address or nil pointer dereference #237

Closed varathongue closed 8 months ago

varathongue commented 1 year ago

Hello, I'm getting this error after starting xray service:

root@OpenWrt:~# /etc/init.d/xray start
xray[22205]: Generating Xray configuration files...
xray[22205]: Starting Xray from /usr/bin/xray
xray[22205]: Using procd_set_param limits nofile=8192 16384
xray[22205]: Setting dnsmasq and firewall for transparent proxy...
xray[22205]: # Generated dnsmasq configurations by luci-app-xray strict-order server=/#/127.0.0.1#5300 server=127.0.0.1#5300
xray[22205]: Generating firewall4 rules...
Reference error: left-hand side expression is null
In /usr/share/xray/firewall_include.ut, line 15, byte 59:

 `    push(wan_fw_ips_no_dns, split(general.secure_dns, ":")[0]);`
  Near here -------------------------------------------------^

xray[22205]: Triggering firewall4 restart...
transparent-proxy-ipset[22461]: default gateway available at 192.168.101.191
root@OpenWrt:~# 

Logread shows :

root@OpenWrt:~# logread -f
Sat Oct 29 17:19:36 2022 user.warn xray[23171]: Generating Xray configuration files...
Sat Oct 29 17:19:36 2022 user.warn xray[23171]: Starting Xray from /usr/bin/xray
Sat Oct 29 17:19:36 2022 user.warn xray[23171]: Using procd_set_param limits nofile=8192 16384
Sat Oct 29 17:19:36 2022 user.warn xray[23171]: Setting dnsmasq and firewall for transparent proxy...
Sat Oct 29 17:19:36 2022 user.warn xray[23171]: # Generated dnsmasq configurations by luci-app-xray strict-order server=/#/127.0.0.1#5300 server=127.0.0.1#5300
Sat Oct 29 17:19:36 2022 daemon.info dnsmasq[1]: exiting on receipt of SIGTERM
Sat Oct 29 17:19:40 2022 daemon.info dnsmasq[1]: started, version 2.86 cachesize 150
Sat Oct 29 17:19:40 2022 daemon.info dnsmasq[1]: DNS service limited to local subnets
Sat Oct 29 17:19:40 2022 daemon.info dnsmasq[1]: compile time options: IPv6 GNU-getopt no-DBus UBus no-i18n no-IDN DHCP DHCPv6 no-Lua TFTP conntrack ipset auth cryptohash DNSSEC no-ID loop-detect inotify dumpfile
Sat Oct 29 17:19:40 2022 daemon.info dnsmasq[1]: UBus support enabled: connected to system bus
Sat Oct 29 17:19:40 2022 daemon.info dnsmasq-dhcp[1]: DHCP, IP range 192.168.101.100 -- 192.168.101.249, lease time 12h
Sat Oct 29 17:19:40 2022 daemon.info dnsmasq[1]: using nameserver 127.0.0.1#5300 for domain #
Sat Oct 29 17:19:40 2022 daemon.info dnsmasq[1]: using nameserver 127.0.0.1#5300
Sat Oct 29 17:19:40 2022 daemon.info dnsmasq[1]: using only locally-known addresses for test
Sat Oct 29 17:19:40 2022 daemon.info dnsmasq[1]: using only locally-known addresses for onion
Sat Oct 29 17:19:40 2022 daemon.info dnsmasq[1]: using only locally-known addresses for localhost
Sat Oct 29 17:19:40 2022 daemon.info dnsmasq[1]: using only locally-known addresses for local
Sat Oct 29 17:19:40 2022 daemon.info dnsmasq[1]: using only locally-known addresses for invalid
Sat Oct 29 17:19:40 2022 daemon.info dnsmasq[1]: using only locally-known addresses for bind
Sat Oct 29 17:19:40 2022 daemon.info dnsmasq[1]: using only locally-known addresses for lan
Sat Oct 29 17:19:40 2022 daemon.info dnsmasq[1]: reading /tmp/resolv.conf.d/resolv.conf.auto
Sat Oct 29 17:19:40 2022 daemon.info dnsmasq[1]: using nameserver 127.0.0.1#5300 for domain #
Sat Oct 29 17:19:40 2022 daemon.info dnsmasq[1]: using nameserver 127.0.0.1#5300
Sat Oct 29 17:19:40 2022 daemon.info dnsmasq[1]: using nameserver 4.2.2.2#53
Sat Oct 29 17:19:40 2022 daemon.info dnsmasq[1]: using nameserver 8.8.8.8#53
Sat Oct 29 17:19:40 2022 daemon.info dnsmasq[1]: using nameserver 192.168.99.1#53
Sat Oct 29 17:19:40 2022 daemon.info dnsmasq[1]: using nameserver fd87:65b9:22c4::1#53
Sat Oct 29 17:19:40 2022 daemon.info dnsmasq[1]: using only locally-known addresses for test
Sat Oct 29 17:19:40 2022 daemon.info dnsmasq[1]: using only locally-known addresses for onion
Sat Oct 29 17:19:40 2022 daemon.info dnsmasq[1]: using only locally-known addresses for localhost
Sat Oct 29 17:19:40 2022 daemon.info dnsmasq[1]: using only locally-known addresses for local
Sat Oct 29 17:19:40 2022 daemon.info dnsmasq[1]: using only locally-known addresses for invalid
Sat Oct 29 17:19:40 2022 daemon.info dnsmasq[1]: using only locally-known addresses for bind
Sat Oct 29 17:19:40 2022 daemon.info dnsmasq[1]: using only locally-known addresses for lan
Sat Oct 29 17:19:40 2022 daemon.info dnsmasq[1]: read /etc/hosts - 4 addresses
Sat Oct 29 17:19:40 2022 daemon.info dnsmasq[1]: read /tmp/hosts/dhcp.cfg01411c - 2 addresses
Sat Oct 29 17:19:40 2022 daemon.info dnsmasq[1]: read /tmp/hosts/odhcpd - 2 addresses
Sat Oct 29 17:19:40 2022 daemon.info dnsmasq-dhcp[1]: read /etc/ethers - 0 addresses
Sat Oct 29 17:19:40 2022 user.warn xray[23171]: Generating firewall4 rules...
Sat Oct 29 17:19:40 2022 user.warn xray[23171]: Triggering firewall4 restart...
Sat Oct 29 17:19:40 2022 user.info transparent-proxy-ipset[23426]: default gateway available at 192.168.99.191
Sat Oct 29 17:19:40 2022 daemon.info xray[23438]: Xray 1.6.0 (Xray, Penetrates Everything.) OpenWrt (go1.18.4 linux/arm64)
Sat Oct 29 17:19:40 2022 daemon.info xray[23438]: A unified platform for anti-censorship.
Sat Oct 29 17:19:40 2022 daemon.err xray[23438]: 2022/10/29 17:19:40 Using confdir from arg: /var/etc/xray
Sat Oct 29 17:19:40 2022 daemon.info xray[23438]: 2022/10/29 17:19:40 [Info] infra/conf/serial: Reading config: /var/etc/xray/config.json
Sat Oct 29 17:19:40 2022 daemon.err xray[23438]: panic: runtime error: invalid memory address or nil pointer dereference
Sat Oct 29 17:19:40 2022 daemon.err xray[23438]: [signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0xcb64c0]
Sat Oct 29 17:19:40 2022 daemon.err xray[23438]:
Sat Oct 29 17:19:40 2022 daemon.err xray[23438]: goroutine 1 [running]:
Sat Oct 29 17:19:40 2022 daemon.err xray[23438]: github.com/xtls/xray-core/infra/conf.FakeDNSPostProcessingStage.Process({}, 0x4000222dd0)
Sat Oct 29 17:19:40 2022 daemon.err xray[23438]:    github.com/xtls/xray-core/infra/conf/fakedns.go:65 +0x90
Sat Oct 29 17:19:40 2022 daemon.err xray[23438]: github.com/xtls/xray-core/infra/conf.PostProcessConfigureFile(0x400026d800?)
Sat Oct 29 17:19:40 2022 daemon.err xray[23438]:    github.com/xtls/xray-core/infra/conf/lint.go:18 +0x90
Sat Oct 29 17:19:40 2022 daemon.err xray[23438]: github.com/xtls/xray-core/infra/conf.(*Config).Build(0x4000222dd0)
Sat Oct 29 17:19:40 2022 daemon.err xray[23438]:    github.com/xtls/xray-core/infra/conf/xray.go:556 +0x2c
Sat Oct 29 17:19:40 2022 daemon.err xray[23438]: github.com/xtls/xray-core/infra/conf/serial.BuildConfig({0x400021c540, 0x1, 0x400018fc58?}, {0x400021c5a0, 0x1, 0x4edc88?})
Sat Oct 29 17:19:40 2022 daemon.err xray[23438]:    github.com/xtls/xray-core/infra/conf/serial/builder.go:29 +0x54
Sat Oct 29 17:19:40 2022 daemon.err xray[23438]: github.com/xtls/xray-core/core.LoadConfig({0xf63221, 0x4}, {0xdcb760?, 0x400023a090?})
Sat Oct 29 17:19:40 2022 daemon.err xray[23438]:    github.com/xtls/xray-core/core/config.go:117 +0x2f4
Sat Oct 29 17:19:40 2022 daemon.err xray[23438]: main.startXray()
Sat Oct 29 17:19:40 2022 daemon.err xray[23438]:    github.com/xtls/xray-core/main/run.go:185 +0xa8
Sat Oct 29 17:19:40 2022 daemon.err xray[23438]: main.executeRun(0x1745be0?, {0x40000c4020?, 0x400005a768?, 0x439abc?})
Sat Oct 29 17:19:40 2022 daemon.err xray[23438]:    github.com/xtls/xray-core/main/run.go:65 +0x2c
Sat Oct 29 17:19:40 2022 daemon.err xray[23438]: github.com/xtls/xray-core/main/commands/base.Execute()
Sat Oct 29 17:19:40 2022 daemon.err xray[23438]:    github.com/xtls/xray-core/main/commands/base/execute.go:64 +0x5c8
Sat Oct 29 17:19:40 2022 daemon.err xray[23438]: main.main()
Sat Oct 29 17:19:40 2022 daemon.err xray[23438]:    github.com/xtls/xray-core/main/main.go:22 +0x1e8

this is how my config looks like :

config xray 'enabled'
    option enabled '0'

config xray 'config'
    option confdir '/etc/xray'
    list conffiles '/etc/xray/config.json'
    option datadir '/usr/share/xray'
    option format 'json'

config general
    option xray_bin '/usr/bin/xray'
    option tproxy_port_tcp '1080'
    option tproxy_port_udp '1081'
    option socks_port '1082'
    option http_port '1083'
    option lan_ifaces 'br-lan'
    option dns_port '5300'
    option dns_count '0'
    option mark '255'
    option loglevel 'warning'
    option handshake '4'
    option conn_idle '300'
    option uplink_only '2'
    option downlink_only '5'
    option buffer_size '512'
    option transparent_proxy_enable '1'
    option main_server 'cfg044a8f'
    option tproxy_udp_server 'cfg044a8f'
    option tproxy_sniffing '1'
    option route_only '1'
    option routing_domain_strategy 'IPOnDemand'
    option fast_dns '192.168.101.1'

config servers
    option alias 'name'
    option server 'X.X.X.X'
    option domain_strategy 'UseIPv4'
    option server_port 'XXXXX'
    option password 'u-u-i-d'
    option protocol 'vless'
    option vless_encryption 'none'
    option vless_tls 'xtls'
    option vless_flow 'xtls-rprx-direct'
    option vless_xtls_host 'sub.domain.example'
    option vless_xtls_insecure '1'
    option transport 'tcp'
    option tcp_guise 'none'
    option dialer_proxy 'disabled'

I've just compiled luci-app-xray | 1.22.0-1 using openwrt-sdk-22.03.2-PLatform-gcc-11.2.0_musl.Linux-x86_64 after running the OpenWrt :

root@OpenWrt:~# nft --version
nftables v1.0.2 (Lester Gooch)
root@OpenWrt:~# cat /etc/openwrt_release 
DISTRIB_ID='OpenWrt'
DISTRIB_RELEASE='22.03.2'
DISTRIB_REVISION='r19803-9a599fee93'

installed packages

root@OpenWrt:~# opkg list-installed
base-files - 1494-r19803-9a599fee93
busybox - 1.35.0-4
ca-bundle - 20211016-1
cgi-io - 2022-08-10-901b0f04-21
dnsmasq-full - 2.86-14
dropbear - 2022.82-2
firewall4 - 2022-10-14-4fbf6d75-1
fstools - 2022-06-02-93369be0-2
fwtool - 2019-11-12-8f7fe925-1
getrandom - 2021-08-03-205defb5-2
hostapd-common - 2022-01-16-cff80b4f-13.1
ipset - 7.15-2
iw - 5.16-1
iwinfo - 2022-08-19-0dad3e66-1
jansson4 - 2.13.1-2
jshn - 2022-05-15-d2223ef9-1
jsonfilter - 2018-02-04-c7e938d6-1
kernel - 5.10.146-1-78b7feac8241898bca1ce7844c52d6a2
kmod-cfg80211 - 5.10.146+5.15.58-1-1
kmod-crypto-aead - 5.10.146-1
kmod-crypto-ccm - 5.10.146-1
kmod-crypto-cmac - 5.10.146-1
kmod-crypto-crc32c - 5.10.146-1
kmod-crypto-ctr - 5.10.146-1
kmod-crypto-gcm - 5.10.146-1
kmod-crypto-gf128 - 5.10.146-1
kmod-crypto-ghash - 5.10.146-1
kmod-crypto-hash - 5.10.146-1
kmod-crypto-hmac - 5.10.146-1
kmod-crypto-manager - 5.10.146-1
kmod-crypto-null - 5.10.146-1
kmod-crypto-rng - 5.10.146-1
kmod-crypto-seqiv - 5.10.146-1
kmod-crypto-sha256 - 5.10.146-1
kmod-gpio-button-hotplug - 5.10.146-3
kmod-hwmon-core - 5.10.146-1
kmod-ipt-core - 5.10.146-1
kmod-ipt-ipset - 5.10.146-1
kmod-leds-gpio - 5.10.146-1
kmod-lib-crc-ccitt - 5.10.146-1
kmod-lib-crc32c - 5.10.146-1
kmod-mac80211 - 5.10.146+5.15.58-1-1
kmod-mt76-connac - 5.10.146+2022-09-06-d7054646-4
kmod-mt76-core - 5.10.146+2022-09-06-d7054646-4
kmod-mt7615-common - 5.10.146+2022-09-06-d7054646-4
kmod-mt7615-firmware - 5.10.146+2022-09-06-d7054646-4
kmod-mt7615e - 5.10.146+2022-09-06-d7054646-4
kmod-mt7915e - 5.10.146+2022-09-06-d7054646-4
kmod-nf-conntrack - 5.10.146-1
kmod-nf-conntrack-netlink - 5.10.146-1
kmod-nf-conntrack6 - 5.10.146-1
kmod-nf-flow - 5.10.146-1
kmod-nf-ipt - 5.10.146-1
kmod-nf-log - 5.10.146-1
kmod-nf-log6 - 5.10.146-1
kmod-nf-nat - 5.10.146-1
kmod-nf-reject - 5.10.146-1
kmod-nf-reject6 - 5.10.146-1
kmod-nf-tproxy - 5.10.146-1
kmod-nfnetlink - 5.10.146-1
kmod-nft-core - 5.10.146-1
kmod-nft-fib - 5.10.146-1
kmod-nft-nat - 5.10.146-1
kmod-nft-offload - 5.10.146-1
kmod-nft-tproxy - 5.10.146-1
kmod-nls-base - 5.10.146-1
kmod-ppp - 5.10.146-1
kmod-pppoe - 5.10.146-1
kmod-pppox - 5.10.146-1
kmod-slhc - 5.10.146-1
kmod-thermal - 5.10.146-1
kmod-usb-core - 5.10.146-1
kmod-usb-xhci-hcd - 5.10.146-1
kmod-usb3 - 5.10.146-1
libblobmsg-json20220515 - 2022-05-15-d2223ef9-1
libc - 1.2.3-4
libgcc1 - 11.2.0-4
libgmp10 - 6.2.1-1
libipset13 - 7.15-2
libiwinfo-data - 2022-08-19-0dad3e66-1
libiwinfo-lua - 2022-08-19-0dad3e66-1
libiwinfo20210430 - 2022-08-19-0dad3e66-1
libjson-c5 - 0.15-2
libjson-script20220515 - 2022-05-15-d2223ef9-1
liblua5.1.5 - 5.1.5-10
liblucihttp-lua - 2022-07-08-6e68a106-1
liblucihttp0 - 2022-07-08-6e68a106-1
libmnl0 - 1.0.5-1
libnetfilter-conntrack3 - 1.0.9-2
libnettle8 - 3.7.3-2
libnfnetlink0 - 1.0.2-1
libnftnl11 - 1.2.1-1
libnl-tiny1 - 2021-11-21-8e0555fb-1
libpthread - 1.2.3-4
libubox20220515 - 2022-05-15-d2223ef9-1
libubus-lua - 2022-06-01-2bebf93c-1
libubus20220601 - 2022-06-01-2bebf93c-1
libuci20130104 - 2021-10-22-f84f49f0-6
libuclient20201210 - 2021-05-14-6a6011df-1
libucode20220812 - 2022-10-07-4ae70721-1
libustream-wolfssl20201210 - 2022-01-16-868fd881-2
libwolfssl5.5.1.ee39414e - 5.5.1-stable-3
logd - 2021-08-03-205defb5-2
lua - 5.1.5-10
luci - git-20.074.84698-ead5e81
luci-app-firewall - git-22.089.67563-7e3c1b4
luci-app-opkg - git-22.273.29004-9f6876b
luci-app-xray - 1.22.0-1
luci-base - git-22.288.45147-96ec0cd
luci-lib-base - git-20.232.39649-1f6dc29
luci-lib-ip - git-20.250.76529-62505bd
luci-lib-jsonc - git-22.097.61921-7513345
luci-lib-nixio - git-20.234.06894-c4a4e43
luci-mod-admin-full - git-19.253.48496-3f93650
luci-mod-network - git-22.244.54818-b13d8c7
luci-mod-status - git-22.189.48501-6731190
luci-mod-system - git-22.264.46172-b6b7da4
luci-proto-ipv6 - git-21.148.48881-79947af
luci-proto-ppp - git-21.158.38888-88b9d84
luci-ssl - git-20.244.36115-e10f954
luci-theme-bootstrap - git-22.288.45147-96ec0cd
mtd - 26
netifd - 2022-08-25-76d2d41b-1
nftables-json - 1.0.2-2.1
odhcp6c - 2022-08-05-7d21e8d8-18
odhcpd-ipv6only - 2022-03-22-860ca900-1
openwrt-keyring - 2022-03-25-62471e69-3
opkg - 2022-02-24-d038e5b6-1
ppp - 2.4.9.git-2021-01-04-3
ppp-mod-pppoe - 2.4.9.git-2021-01-04-3
procd - 2022-06-01-7a009685-1
procd-seccomp - 2022-06-01-7a009685-1
procd-ujail - 2022-06-01-7a009685-1
px5g-wolfssl - 5.1
rpcd - 2022-09-21-8c852b65-1
rpcd-mod-file - 2022-09-21-8c852b65-1
rpcd-mod-iwinfo - 2022-09-21-8c852b65-1
rpcd-mod-luci - 20210614
rpcd-mod-rrdns - 20170710
ubi-utils - 2.1.4-1
uboot-envtools - 2022.01-32
ubox - 2021-08-03-205defb5-2
ubus - 2022-06-01-2bebf93c-1
ubusd - 2022-06-01-2bebf93c-1
uci - 2021-10-22-f84f49f0-6
uclient-fetch - 2021-05-14-6a6011df-1
ucode - 2022-10-07-4ae70721-1
ucode-mod-fs - 2022-10-07-4ae70721-1
ucode-mod-ubus - 2022-10-07-4ae70721-1
ucode-mod-uci - 2022-10-07-4ae70721-1
uhttpd - 2022-08-12-e3395cd9-1
uhttpd-mod-ubus - 2022-08-12-e3395cd9-1
urandom-seed - 3
urngd - 2020-01-21-c7f7b6b6-1
usign - 2020-05-23-f1f65026-1
v2ray-geoip - 202209170841-1
wireless-regdb - 2022.08.12-1
wpad-basic-wolfssl - 2022-01-16-cff80b4f-13.1
xray-core - 1.6.0-3
yichya commented 1 year ago

Your configurations seems missing option secure_dns setting under config general. Try replacing your configuration file with the default one provided with this package.