| 1 | package inboundscip-go gomod v2ray.com/core . `v2ray.com/core/app/proxyman/inbound`/ |
| 2 | |
| 3 | import ( |
| 4 | "contextscip-go gomod github.com/golang/go/src go1.15 context/" |
| 5 | |
| 6 | "v2ray.com/corescip-go gomod v2ray.com/core . `v2ray.com/core`/" |
| 7 | "v2ray.com/core/app/proxymanscip-go gomod v2ray.com/core . `v2ray.com/core/app/proxyman`/" |
| 8 | "v2ray.com/core/commonscip-go gomod v2ray.com/core . `v2ray.com/core/common`/" |
| 9 | "v2ray.com/core/common/dicescip-go gomod v2ray.com/core . `v2ray.com/core/common/dice`/" |
| 10 | "v2ray.com/core/common/errorsscip-go gomod v2ray.com/core . `v2ray.com/core/common/errors`/" |
| 11 | "v2ray.com/core/common/muxscip-go gomod v2ray.com/core . `v2ray.com/core/common/mux`/" |
| 12 | "v2ray.com/core/common/netscip-go gomod v2ray.com/core . `v2ray.com/core/common/net`/" |
| 13 | "v2ray.com/core/features/policyscip-go gomod v2ray.com/core . `v2ray.com/core/features/policy`/" |
| 14 | "v2ray.com/core/features/statsscip-go gomod v2ray.com/core . `v2ray.com/core/features/stats`/" |
| 15 | "v2ray.com/core/proxyscip-go gomod v2ray.com/core . `v2ray.com/core/proxy`/" |
| 16 | "v2ray.com/core/transport/internetscip-go gomod v2ray.com/core . `v2ray.com/core/transport/internet`/" |
| 17 | ) |
| 18 | |
| 19 | func getStatCounterscip-go gomod v2ray.com/core . `v2ray.com/core/app/proxyman/inbound`/getStatCounter().(v *corescip-go gomod v2ray.com/core . `v2ray.com/core`/.Instancescip-go gomod v2ray.com/core . `v2ray.com/core`/Instance#, tag string) (statsscip-go gomod v2ray.com/core . `v2ray.com/core/features/stats`/.Counterscip-go gomod v2ray.com/core . `v2ray.com/core/features/stats`/Counter#, statsscip-go gomod v2ray.com/core . `v2ray.com/core/features/stats`/.Counterscip-go gomod v2ray.com/core . `v2ray.com/core/features/stats`/Counter#) { |
| 20 | var uplinkCounter statsscip-go gomod v2ray.com/core . `v2ray.com/core/features/stats`/.Counterscip-go gomod v2ray.com/core . `v2ray.com/core/features/stats`/Counter# |
| 21 | var downlinkCounter statsscip-go gomod v2ray.com/core . `v2ray.com/core/features/stats`/.Counterscip-go gomod v2ray.com/core . `v2ray.com/core/features/stats`/Counter# |
| 22 | |
| 23 | policy := v.GetFeaturescip-go gomod v2ray.com/core . `v2ray.com/core`/Instance#GetFeature().(policyscip-go gomod v2ray.com/core . `v2ray.com/core/features/policy`/.ManagerTypescip-go gomod v2ray.com/core . `v2ray.com/core/features/policy`/ManagerType().()).(policyscip-go gomod v2ray.com/core . `v2ray.com/core/features/policy`/.Managerscip-go gomod v2ray.com/core . `v2ray.com/core/features/policy`/Manager#) |
| 24 | if len(tag) > 0 && policy.ForSystemscip-go gomod v2ray.com/core . `v2ray.com/core/features/policy`/Manager#ForSystem.().Statsscip-go gomod v2ray.com/core . `v2ray.com/core/features/policy`/System#Stats..InboundUplinkscip-go gomod v2ray.com/core . `v2ray.com/core/features/policy`/SystemStats#InboundUplink. { |
| 25 | statsManager := v.GetFeaturescip-go gomod v2ray.com/core . `v2ray.com/core`/Instance#GetFeature().(statsscip-go gomod v2ray.com/core . `v2ray.com/core/features/stats`/.ManagerTypescip-go gomod v2ray.com/core . `v2ray.com/core/features/stats`/ManagerType().()).(statsscip-go gomod v2ray.com/core . `v2ray.com/core/features/stats`/.Managerscip-go gomod v2ray.com/core . `v2ray.com/core/features/stats`/Manager#) |
| 26 | name := "inbound>>>" + tag + ">>>traffic>>>uplink" |
| 27 | c, _ := statsscip-go gomod v2ray.com/core . `v2ray.com/core/features/stats`/.GetOrRegisterCounterscip-go gomod v2ray.com/core . `v2ray.com/core/features/stats`/GetOrRegisterCounter().(statsManager, name) |
| 28 | if c != nil { |
| 29 | uplinkCounter = c |
| 30 | } |
| 31 | } |
| 32 | if len(tag) > 0 && policy.ForSystemscip-go gomod v2ray.com/core . `v2ray.com/core/features/policy`/Manager#ForSystem.().Statsscip-go gomod v2ray.com/core . `v2ray.com/core/features/policy`/System#Stats..InboundDownlinkscip-go gomod v2ray.com/core . `v2ray.com/core/features/policy`/SystemStats#InboundDownlink. { |
| 33 | statsManager := v.GetFeaturescip-go gomod v2ray.com/core . `v2ray.com/core`/Instance#GetFeature().(statsscip-go gomod v2ray.com/core . `v2ray.com/core/features/stats`/.ManagerTypescip-go gomod v2ray.com/core . `v2ray.com/core/features/stats`/ManagerType().()).(statsscip-go gomod v2ray.com/core . `v2ray.com/core/features/stats`/.Managerscip-go gomod v2ray.com/core . `v2ray.com/core/features/stats`/Manager#) |
| 34 | name := "inbound>>>" + tag + ">>>traffic>>>downlink" |
| 35 | c, _ := statsscip-go gomod v2ray.com/core . `v2ray.com/core/features/stats`/.GetOrRegisterCounterscip-go gomod v2ray.com/core . `v2ray.com/core/features/stats`/GetOrRegisterCounter().(statsManager, name) |
| 36 | if c != nil { |
| 37 | downlinkCounter = c |
| 38 | } |
| 39 | } |
| 40 | |
| 41 | return uplinkCounter, downlinkCounter |
| 42 | } |
| 43 | |
| 44 | type AlwaysOnInboundHandlerscip-go gomod v2ray.com/core . `v2ray.com/core/app/proxyman/inbound`/AlwaysOnInboundHandler# struct { |
| 45 | proxyscip-go gomod v2ray.com/core . `v2ray.com/core/app/proxyman/inbound`/AlwaysOnInboundHandler#proxy. proxyscip-go gomod v2ray.com/core . `v2ray.com/core/proxy`/.Inboundscip-go gomod v2ray.com/core . `v2ray.com/core/proxy`/Inbound# |
| 46 | workersscip-go gomod v2ray.com/core . `v2ray.com/core/app/proxyman/inbound`/AlwaysOnInboundHandler#workers. []workerscip-go gomod v2ray.com/core . `v2ray.com/core/app/proxyman/inbound`/worker# |
| 47 | muxscip-go gomod v2ray.com/core . `v2ray.com/core/app/proxyman/inbound`/AlwaysOnInboundHandler#mux. *muxscip-go gomod v2ray.com/core . `v2ray.com/core/common/mux`/.Serverscip-go gomod v2ray.com/core . `v2ray.com/core/common/mux`/Server# |
| 48 | tagscip-go gomod v2ray.com/core . `v2ray.com/core/app/proxyman/inbound`/AlwaysOnInboundHandler#tag. string |
| 49 | } |
| 50 | |
| 51 | func NewAlwaysOnInboundHandlerscip-go gomod v2ray.com/core . `v2ray.com/core/app/proxyman/inbound`/NewAlwaysOnInboundHandler().(ctx contextscip-go gomod github.com/golang/go/src go1.15 context/.Contextscip-go gomod github.com/golang/go/src go1.15 context/Context#, tag string, receiverConfig *proxymanscip-go gomod v2ray.com/core . `v2ray.com/core/app/proxyman`/.ReceiverConfigscip-go gomod v2ray.com/core . `v2ray.com/core/app/proxyman`/ReceiverConfig#, proxyConfig interface{}) (*AlwaysOnInboundHandlerscip-go gomod v2ray.com/core . `v2ray.com/core/app/proxyman/inbound`/AlwaysOnInboundHandler#, error) { |
| 52 | rawProxy, err := commonscip-go gomod v2ray.com/core . `v2ray.com/core/common`/.CreateObjectscip-go gomod v2ray.com/core . `v2ray.com/core/common`/CreateObject().(ctx, proxyConfig) |
| 53 | if err != nil { |
| 54 | return nil, err |
| 55 | } |
| 56 | p, ok := rawProxy.(proxyscip-go gomod v2ray.com/core . `v2ray.com/core/proxy`/.Inboundscip-go gomod v2ray.com/core . `v2ray.com/core/proxy`/Inbound#) |
| 57 | if !ok { |
| 58 | return nil, newErrorscip-go gomod v2ray.com/core . `v2ray.com/core/app/proxyman/inbound`/newError().("not an inbound proxy.") |
| 59 | } |
| 60 | |
| 61 | h := &AlwaysOnInboundHandlerscip-go gomod v2ray.com/core . `v2ray.com/core/app/proxyman/inbound`/AlwaysOnInboundHandler#{ |
| 62 | proxyscip-go gomod v2ray.com/core . `v2ray.com/core/app/proxyman/inbound`/AlwaysOnInboundHandler#proxy.: p, |
| 63 | muxscip-go gomod v2ray.com/core . `v2ray.com/core/app/proxyman/inbound`/AlwaysOnInboundHandler#mux.: muxscip-go gomod v2ray.com/core . `v2ray.com/core/common/mux`/.NewServerscip-go gomod v2ray.com/core . `v2ray.com/core/common/mux`/NewServer().(ctx), |
| 64 | tagscip-go gomod v2ray.com/core . `v2ray.com/core/app/proxyman/inbound`/AlwaysOnInboundHandler#tag.: tag, |
| 65 | } |
| 66 | |
| 67 | uplinkCounter, downlinkCounter := getStatCounterscip-go gomod v2ray.com/core . `v2ray.com/core/app/proxyman/inbound`/getStatCounter().(corescip-go gomod v2ray.com/core . `v2ray.com/core`/.MustFromContextscip-go gomod v2ray.com/core . `v2ray.com/core`/MustFromContext().(ctx), tag) |
| 68 | |
| 69 | nl := p.Networkscip-go gomod v2ray.com/core . `v2ray.com/core/proxy`/Inbound#Network.() |
| 70 | pr := receiverConfig.PortRangescip-go gomod v2ray.com/core . `v2ray.com/core/app/proxyman`/ReceiverConfig#PortRange. |
| 71 | address := receiverConfig.Listenscip-go gomod v2ray.com/core . `v2ray.com/core/app/proxyman`/ReceiverConfig#Listen..AsAddressscip-go gomod v2ray.com/core . `v2ray.com/core/common/net`/IPOrDomain#AsAddress().() |
| 72 | if address == nil { |
| 73 | address = netscip-go gomod v2ray.com/core . `v2ray.com/core/common/net`/.AnyIPscip-go gomod v2ray.com/core . `v2ray.com/core/common/net`/AnyIP. |
| 74 | } |
| 75 | |
| 76 | mss, err := internetscip-go gomod v2ray.com/core . `v2ray.com/core/transport/internet`/.ToMemoryStreamConfigscip-go gomod v2ray.com/core . `v2ray.com/core/transport/internet`/ToMemoryStreamConfig().(receiverConfig.StreamSettingsscip-go gomod v2ray.com/core . `v2ray.com/core/app/proxyman`/ReceiverConfig#StreamSettings.) |
| 77 | if err != nil { |
| 78 | return nil, newErrorscip-go gomod v2ray.com/core . `v2ray.com/core/app/proxyman/inbound`/newError().("failed to parse stream config").Basescip-go gomod v2ray.com/core . `v2ray.com/core/common/errors`/Error#Base().(err).AtWarningscip-go gomod v2ray.com/core . `v2ray.com/core/common/errors`/Error#AtWarning().() |
| 79 | } |
| 80 | |
| 81 | if receiverConfig.ReceiveOriginalDestinationscip-go gomod v2ray.com/core . `v2ray.com/core/app/proxyman`/ReceiverConfig#ReceiveOriginalDestination. { |
| 82 | if mss.SocketSettingsscip-go gomod v2ray.com/core . `v2ray.com/core/transport/internet`/MemoryStreamConfig#SocketSettings. == nil { |
| 83 | mss.SocketSettingsscip-go gomod v2ray.com/core . `v2ray.com/core/transport/internet`/MemoryStreamConfig#SocketSettings. = &internetscip-go gomod v2ray.com/core . `v2ray.com/core/transport/internet`/.SocketConfigscip-go gomod v2ray.com/core . `v2ray.com/core/transport/internet`/SocketConfig#{} |
| 84 | } |
| 85 | if mss.SocketSettingsscip-go gomod v2ray.com/core . `v2ray.com/core/transport/internet`/MemoryStreamConfig#SocketSettings..Tproxyscip-go gomod v2ray.com/core . `v2ray.com/core/transport/internet`/SocketConfig#Tproxy. == internetscip-go gomod v2ray.com/core . `v2ray.com/core/transport/internet`/.SocketConfig_Offscip-go gomod v2ray.com/core . `v2ray.com/core/transport/internet`/SocketConfig_Off. { |
| 86 | mss.SocketSettingsscip-go gomod v2ray.com/core . `v2ray.com/core/transport/internet`/MemoryStreamConfig#SocketSettings..Tproxyscip-go gomod v2ray.com/core . `v2ray.com/core/transport/internet`/SocketConfig#Tproxy. = internetscip-go gomod v2ray.com/core . `v2ray.com/core/transport/internet`/.SocketConfig_Redirectscip-go gomod v2ray.com/core . `v2ray.com/core/transport/internet`/SocketConfig_Redirect. |
| 87 | } |
| 88 | mss.SocketSettingsscip-go gomod v2ray.com/core . `v2ray.com/core/transport/internet`/MemoryStreamConfig#SocketSettings..ReceiveOriginalDestAddressscip-go gomod v2ray.com/core . `v2ray.com/core/transport/internet`/SocketConfig#ReceiveOriginalDestAddress. = true |
| 89 | } |
| 90 | if pr == nil { |
| 91 | if netscip-go gomod v2ray.com/core . `v2ray.com/core/common/net`/.HasNetworkscip-go gomod v2ray.com/core . `v2ray.com/core/common/net`/HasNetwork().(nl, netscip-go gomod v2ray.com/core . `v2ray.com/core/common/net`/.Network_UNIXscip-go gomod v2ray.com/core . `v2ray.com/core/common/net`/Network_UNIX.) { |
| 92 | newErrorscip-go gomod v2ray.com/core . `v2ray.com/core/app/proxyman/inbound`/newError().("creating unix domain socket worker on ", address).AtDebugscip-go gomod v2ray.com/core . `v2ray.com/core/common/errors`/Error#AtDebug().().WriteToLogscip-go gomod v2ray.com/core . `v2ray.com/core/common/errors`/Error#WriteToLog().() |
| 93 | |
| 94 | worker := &dsWorkerscip-go gomod v2ray.com/core . `v2ray.com/core/app/proxyman/inbound`/dsWorker#{ |
| 95 | addressscip-go gomod v2ray.com/core . `v2ray.com/core/app/proxyman/inbound`/dsWorker#address.: address, |
| 96 | proxyscip-go gomod v2ray.com/core . `v2ray.com/core/app/proxyman/inbound`/dsWorker#proxy.: p, |
| 97 | streamscip-go gomod v2ray.com/core . `v2ray.com/core/app/proxyman/inbound`/dsWorker#stream.: mss, |
| 98 | tagscip-go gomod v2ray.com/core . `v2ray.com/core/app/proxyman/inbound`/dsWorker#tag.: tag, |
| 99 | dispatcherscip-go gomod v2ray.com/core . `v2ray.com/core/app/proxyman/inbound`/dsWorker#dispatcher.: h.muxscip-go gomod v2ray.com/core . `v2ray.com/core/app/proxyman/inbound`/AlwaysOnInboundHandler#mux., |
| 100 | sniffingConfigscip-go gomod v2ray.com/core . `v2ray.com/core/app/proxyman/inbound`/dsWorker#sniffingConfig.: receiverConfig.GetEffectiveSniffingSettingsscip-go gomod v2ray.com/core . `v2ray.com/core/app/proxyman`/ReceiverConfig#GetEffectiveSniffingSettings().(), |
| 101 | uplinkCounterscip-go gomod v2ray.com/core . `v2ray.com/core/app/proxyman/inbound`/dsWorker#uplinkCounter.: uplinkCounter, |
| 102 | downlinkCounterscip-go gomod v2ray.com/core . `v2ray.com/core/app/proxyman/inbound`/dsWorker#downlinkCounter.: downlinkCounter, |
| 103 | ctxscip-go gomod v2ray.com/core . `v2ray.com/core/app/proxyman/inbound`/dsWorker#ctx.: ctx, |
| 104 | } |
| 105 | h.workersscip-go gomod v2ray.com/core . `v2ray.com/core/app/proxyman/inbound`/AlwaysOnInboundHandler#workers. = append(h.workersscip-go gomod v2ray.com/core . `v2ray.com/core/app/proxyman/inbound`/AlwaysOnInboundHandler#workers., worker) |
| 106 | } |
| 107 | } |
| 108 | if pr != nil { |
| 109 | for port := pr.Fromscip-go gomod v2ray.com/core . `v2ray.com/core/common/net`/PortRange#From.; port <= pr.Toscip-go gomod v2ray.com/core . `v2ray.com/core/common/net`/PortRange#To.; port++ { |
| 110 | if netscip-go gomod v2ray.com/core . `v2ray.com/core/common/net`/.HasNetworkscip-go gomod v2ray.com/core . `v2ray.com/core/common/net`/HasNetwork().(nl, netscip-go gomod v2ray.com/core . `v2ray.com/core/common/net`/.Network_TCPscip-go gomod v2ray.com/core . `v2ray.com/core/common/net`/Network_TCP.) { |
| 111 | newErrorscip-go gomod v2ray.com/core . `v2ray.com/core/app/proxyman/inbound`/newError().("creating stream worker on ", address, ":", port).AtDebugscip-go gomod v2ray.com/core . `v2ray.com/core/common/errors`/Error#AtDebug().().WriteToLogscip-go gomod v2ray.com/core . `v2ray.com/core/common/errors`/Error#WriteToLog().() |
| 112 | |
| 113 | worker := &tcpWorkerscip-go gomod v2ray.com/core . `v2ray.com/core/app/proxyman/inbound`/tcpWorker#{ |
| 114 | addressscip-go gomod v2ray.com/core . `v2ray.com/core/app/proxyman/inbound`/tcpWorker#address.: address, |
| 115 | portscip-go gomod v2ray.com/core . `v2ray.com/core/app/proxyman/inbound`/tcpWorker#port.: netscip-go gomod v2ray.com/core . `v2ray.com/core/common/net`/.Portscip-go gomod v2ray.com/core . `v2ray.com/core/common/net`/Port#(port), |
| 116 | proxyscip-go gomod v2ray.com/core . `v2ray.com/core/app/proxyman/inbound`/tcpWorker#proxy.: p, |
| 117 | streamscip-go gomod v2ray.com/core . `v2ray.com/core/app/proxyman/inbound`/tcpWorker#stream.: mss, |
| 118 | recvOrigDestscip-go gomod v2ray.com/core . `v2ray.com/core/app/proxyman/inbound`/tcpWorker#recvOrigDest.: receiverConfig.ReceiveOriginalDestinationscip-go gomod v2ray.com/core . `v2ray.com/core/app/proxyman`/ReceiverConfig#ReceiveOriginalDestination., |
| 119 | tagscip-go gomod v2ray.com/core . `v2ray.com/core/app/proxyman/inbound`/tcpWorker#tag.: tag, |
| 120 | dispatcherscip-go gomod v2ray.com/core . `v2ray.com/core/app/proxyman/inbound`/tcpWorker#dispatcher.: h.muxscip-go gomod v2ray.com/core . `v2ray.com/core/app/proxyman/inbound`/AlwaysOnInboundHandler#mux., |
| 121 | sniffingConfigscip-go gomod v2ray.com/core . `v2ray.com/core/app/proxyman/inbound`/tcpWorker#sniffingConfig.: receiverConfig.GetEffectiveSniffingSettingsscip-go gomod v2ray.com/core . `v2ray.com/core/app/proxyman`/ReceiverConfig#GetEffectiveSniffingSettings().(), |
| 122 | uplinkCounterscip-go gomod v2ray.com/core . `v2ray.com/core/app/proxyman/inbound`/tcpWorker#uplinkCounter.: uplinkCounter, |
| 123 | downlinkCounterscip-go gomod v2ray.com/core . `v2ray.com/core/app/proxyman/inbound`/tcpWorker#downlinkCounter.: downlinkCounter, |
| 124 | ctxscip-go gomod v2ray.com/core . `v2ray.com/core/app/proxyman/inbound`/tcpWorker#ctx.: ctx, |
| 125 | } |
| 126 | h.workersscip-go gomod v2ray.com/core . `v2ray.com/core/app/proxyman/inbound`/AlwaysOnInboundHandler#workers. = append(h.workersscip-go gomod v2ray.com/core . `v2ray.com/core/app/proxyman/inbound`/AlwaysOnInboundHandler#workers., worker) |
| 127 | } |
| 128 | |
| 129 | if netscip-go gomod v2ray.com/core . `v2ray.com/core/common/net`/.HasNetworkscip-go gomod v2ray.com/core . `v2ray.com/core/common/net`/HasNetwork().(nl, netscip-go gomod v2ray.com/core . `v2ray.com/core/common/net`/.Network_UDPscip-go gomod v2ray.com/core . `v2ray.com/core/common/net`/Network_UDP.) { |
| 130 | worker := &udpWorkerscip-go gomod v2ray.com/core . `v2ray.com/core/app/proxyman/inbound`/udpWorker#{ |
| 131 | tagscip-go gomod v2ray.com/core . `v2ray.com/core/app/proxyman/inbound`/udpWorker#tag.: tag, |
| 132 | proxyscip-go gomod v2ray.com/core . `v2ray.com/core/app/proxyman/inbound`/udpWorker#proxy.: p, |
| 133 | addressscip-go gomod v2ray.com/core . `v2ray.com/core/app/proxyman/inbound`/udpWorker#address.: address, |
| 134 | portscip-go gomod v2ray.com/core . `v2ray.com/core/app/proxyman/inbound`/udpWorker#port.: netscip-go gomod v2ray.com/core . `v2ray.com/core/common/net`/.Portscip-go gomod v2ray.com/core . `v2ray.com/core/common/net`/Port#(port), |
| 135 | dispatcherscip-go gomod v2ray.com/core . `v2ray.com/core/app/proxyman/inbound`/udpWorker#dispatcher.: h.muxscip-go gomod v2ray.com/core . `v2ray.com/core/app/proxyman/inbound`/AlwaysOnInboundHandler#mux., |
| 136 | uplinkCounterscip-go gomod v2ray.com/core . `v2ray.com/core/app/proxyman/inbound`/udpWorker#uplinkCounter.: uplinkCounter, |
| 137 | downlinkCounterscip-go gomod v2ray.com/core . `v2ray.com/core/app/proxyman/inbound`/udpWorker#downlinkCounter.: downlinkCounter, |
| 138 | streamscip-go gomod v2ray.com/core . `v2ray.com/core/app/proxyman/inbound`/udpWorker#stream.: mss, |
| 139 | } |
| 140 | h.workersscip-go gomod v2ray.com/core . `v2ray.com/core/app/proxyman/inbound`/AlwaysOnInboundHandler#workers. = append(h.workersscip-go gomod v2ray.com/core . `v2ray.com/core/app/proxyman/inbound`/AlwaysOnInboundHandler#workers., worker) |
| 141 | } |
| 142 | } |
| 143 | } |
| 144 | |
| 145 | return h, nil |
| 146 | } |
| 147 | |
| 148 | // Start implements common.Runnable. |
| 149 | func (h *AlwaysOnInboundHandlerscip-go gomod v2ray.com/core . `v2ray.com/core/app/proxyman/inbound`/AlwaysOnInboundHandler#) Startscip-go gomod v2ray.com/core . `v2ray.com/core/app/proxyman/inbound`/AlwaysOnInboundHandler#Start().() error { |
| 150 | for _, worker := range h.workersscip-go gomod v2ray.com/core . `v2ray.com/core/app/proxyman/inbound`/AlwaysOnInboundHandler#workers. { |
| 151 | if err := worker.Startscip-go gomod v2ray.com/core . `v2ray.com/core/app/proxyman/inbound`/worker#Start.(); err != nil { |
| 152 | return err |
| 153 | } |
| 154 | } |
| 155 | return nil |
| 156 | } |
| 157 | |
| 158 | // Close implements common.Closable. |
| 159 | func (h *AlwaysOnInboundHandlerscip-go gomod v2ray.com/core . `v2ray.com/core/app/proxyman/inbound`/AlwaysOnInboundHandler#) Closescip-go gomod v2ray.com/core . `v2ray.com/core/app/proxyman/inbound`/AlwaysOnInboundHandler#Close().() error { |
| 160 | var errs []error |
| 161 | for _, worker := range h.workersscip-go gomod v2ray.com/core . `v2ray.com/core/app/proxyman/inbound`/AlwaysOnInboundHandler#workers. { |
| 162 | errs = append(errs, worker.Closescip-go gomod v2ray.com/core . `v2ray.com/core/app/proxyman/inbound`/worker#Close.()) |
| 163 | } |
| 164 | errs = append(errs, h.muxscip-go gomod v2ray.com/core . `v2ray.com/core/app/proxyman/inbound`/AlwaysOnInboundHandler#mux..Closescip-go gomod v2ray.com/core . `v2ray.com/core/common/mux`/Server#Close().()) |
| 165 | if err := errorsscip-go gomod v2ray.com/core . `v2ray.com/core/common/errors`/.Combinescip-go gomod v2ray.com/core . `v2ray.com/core/common/errors`/Combine().(errs...); err != nil { |
| 166 | return newErrorscip-go gomod v2ray.com/core . `v2ray.com/core/app/proxyman/inbound`/newError().("failed to close all resources").Basescip-go gomod v2ray.com/core . `v2ray.com/core/common/errors`/Error#Base().(err) |
| 167 | } |
| 168 | return nil |
| 169 | } |
| 170 | |
| 171 | func (h *AlwaysOnInboundHandlerscip-go gomod v2ray.com/core . `v2ray.com/core/app/proxyman/inbound`/AlwaysOnInboundHandler#) GetRandomInboundProxyscip-go gomod v2ray.com/core . `v2ray.com/core/app/proxyman/inbound`/AlwaysOnInboundHandler#GetRandomInboundProxy().() (interface{}, netscip-go gomod v2ray.com/core . `v2ray.com/core/common/net`/.Portscip-go gomod v2ray.com/core . `v2ray.com/core/common/net`/Port#, int) { |
| 172 | if len(h.workersscip-go gomod v2ray.com/core . `v2ray.com/core/app/proxyman/inbound`/AlwaysOnInboundHandler#workers.) == 0 { |
| 173 | return nil, 0, 0 |
| 174 | } |
| 175 | w := h.workersscip-go gomod v2ray.com/core . `v2ray.com/core/app/proxyman/inbound`/AlwaysOnInboundHandler#workers.[dicescip-go gomod v2ray.com/core . `v2ray.com/core/common/dice`/.Rollscip-go gomod v2ray.com/core . `v2ray.com/core/common/dice`/Roll().(len(h.workersscip-go gomod v2ray.com/core . `v2ray.com/core/app/proxyman/inbound`/AlwaysOnInboundHandler#workers.))] |
| 176 | return w.Proxyscip-go gomod v2ray.com/core . `v2ray.com/core/app/proxyman/inbound`/worker#Proxy.(), w.Portscip-go gomod v2ray.com/core . `v2ray.com/core/app/proxyman/inbound`/worker#Port.(), 9999 |
| 177 | } |
| 178 | |
| 179 | func (h *AlwaysOnInboundHandlerscip-go gomod v2ray.com/core . `v2ray.com/core/app/proxyman/inbound`/AlwaysOnInboundHandler#) Tagscip-go gomod v2ray.com/core . `v2ray.com/core/app/proxyman/inbound`/AlwaysOnInboundHandler#Tag().() string { |
| 180 | return h.tagscip-go gomod v2ray.com/core . `v2ray.com/core/app/proxyman/inbound`/AlwaysOnInboundHandler#tag. |
| 181 | } |
| 182 | |
| 183 | func (h *AlwaysOnInboundHandlerscip-go gomod v2ray.com/core . `v2ray.com/core/app/proxyman/inbound`/AlwaysOnInboundHandler#) GetInboundscip-go gomod v2ray.com/core . `v2ray.com/core/app/proxyman/inbound`/AlwaysOnInboundHandler#GetInbound().() proxyscip-go gomod v2ray.com/core . `v2ray.com/core/proxy`/.Inboundscip-go gomod v2ray.com/core . `v2ray.com/core/proxy`/Inbound# { |
| 184 | return h.proxyscip-go gomod v2ray.com/core . `v2ray.com/core/app/proxyman/inbound`/AlwaysOnInboundHandler#proxy. |
| 185 | } |