From ebb6bca65cb936ebb2aba9316dcae4cab45e49ec Mon Sep 17 00:00:00 2001 From: mzz2017 Date: Thu, 26 Aug 2021 23:25:18 +0800 Subject: [PATCH] fix: tproxy cannot start and load balance panic --- service/core/iptables/tproxy.go | 2 +- service/core/v2ray/api.go | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/service/core/iptables/tproxy.go b/service/core/iptables/tproxy.go index a9d050af..00580c88 100644 --- a/service/core/iptables/tproxy.go +++ b/service/core/iptables/tproxy.go @@ -184,7 +184,7 @@ ip -6 rule del fwmark 1 table 100 ip -6 route del local ::/0 dev lo table 100 ip6tables -w 2 -t mangle -F SSTP_ONCE -ip6tables -w 2 -t mangle -D PREROUTING -m socket -j SSTP_ONCE +ip6tables -w 2 -t mangle -D PREROUTING -m socket --restore-skmark -j SSTP_ONCE ip6tables -w 2 -t mangle -X SSTP_ONCE ip6tables -w 2 -t mangle -F TP_OUT ip6tables -w 2 -t mangle -D OUTPUT -j TP_OUT diff --git a/service/core/v2ray/api.go b/service/core/v2ray/api.go index 9687f76b..1716a549 100644 --- a/service/core/v2ray/api.go +++ b/service/core/v2ray/api.go @@ -63,6 +63,7 @@ func getObservatoryResponse(conn *grpc.ClientConn) (r *pb.GetOutboundStatusRespo func observatoryProducer() { const product = "observatory" var conn *grpc.ClientConn +nextLoop: for { if ApiPort() == 0 { time.Sleep(ApiFeedInterval) @@ -91,7 +92,11 @@ func observatoryProducer() { css := configure.GetConnectedServers() for i := range outboundStatus { _ = mapper.AutoMapper(outboundStatus[i], &os[i]) - os[i].Which = css.Get()[tag2WhichIndex[os[i].OutboundTag]] + index := tag2WhichIndex[os[i].OutboundTag] + if index >= css.Len() { + continue nextLoop + } + os[i].Which = css.Get()[index] } ApiFeed.ProductMessage(product, os) }