diff --git a/adapter/adapter.go b/adapter/adapter.go index 411069fbf5..31706a2eed 100644 --- a/adapter/adapter.go +++ b/adapter/adapter.go @@ -163,10 +163,17 @@ func (p *Proxy) MarshalJSON() ([]byte, error) { mapping["alive"] = p.alive.Load() mapping["name"] = p.Name() mapping["udp"] = p.SupportUDP() - mapping["xudp"] = p.SupportXUDP() - mapping["tfo"] = p.SupportTFO() - mapping["mptcp"] = p.SupportMPTCP() - mapping["smux"] = p.SupportSMUX() + mapping["uot"] = p.SupportUOT() + + proxyInfo := p.ProxyInfo() + mapping["xudp"] = proxyInfo.XUDP + mapping["tfo"] = proxyInfo.TFO + mapping["mptcp"] = proxyInfo.MPTCP + mapping["smux"] = proxyInfo.SMUX + mapping["interface"] = proxyInfo.Interface + mapping["dialer-proxy"] = proxyInfo.DialerProxy + mapping["routing-mark"] = proxyInfo.RoutingMark + return json.Marshal(mapping) } diff --git a/adapter/inbound/listen.go b/adapter/inbound/listen.go index 318c9675db..ad944006a2 100644 --- a/adapter/inbound/listen.go +++ b/adapter/inbound/listen.go @@ -2,7 +2,9 @@ package inbound import ( "context" + "fmt" "net" + "net/netip" "sync" "github.com/metacubex/mihomo/component/keepalive" @@ -42,6 +44,27 @@ func MPTCP() bool { } func ListenContext(ctx context.Context, network, address string) (net.Listener, error) { + switch network { // like net.Resolver.internetAddrList but filter domain to avoid call net.Resolver.lookupIPAddr + case "tcp", "tcp4", "tcp6", "udp", "udp4", "udp6", "ip", "ip4", "ip6": + if host, port, err := net.SplitHostPort(address); err == nil { + switch host { + case "localhost": + switch network { + case "tcp6", "udp6", "ip6": + address = net.JoinHostPort("::1", port) + default: + address = net.JoinHostPort("127.0.0.1", port) + } + case "": // internetAddrList can handle this special case + break + default: + if _, err := netip.ParseAddr(host); err != nil { // not ip + return nil, fmt.Errorf("invalid network address: %s", address) + } + } + } + } + mutex.RLock() defer mutex.RUnlock() return lc.Listen(ctx, network, address) diff --git a/adapter/outbound/base.go b/adapter/outbound/base.go index 93e8d9795e..dd226f74a7 100644 --- a/adapter/outbound/base.go +++ b/adapter/outbound/base.go @@ -85,24 +85,15 @@ func (b *Base) SupportUDP() bool { return b.udp } -// SupportXUDP implements C.ProxyAdapter -func (b *Base) SupportXUDP() bool { - return b.xudp -} - -// SupportTFO implements C.ProxyAdapter -func (b *Base) SupportTFO() bool { - return b.tfo -} - -// SupportMPTCP implements C.ProxyAdapter -func (b *Base) SupportMPTCP() bool { - return b.mpTcp -} - -// SupportSMUX implements C.ProxyAdapter -func (b *Base) SupportSMUX() bool { - return false +// ProxyInfo implements C.ProxyAdapter +func (b *Base) ProxyInfo() (info C.ProxyInfo) { + info.XUDP = b.xudp + info.TFO = b.tfo + info.MPTCP = b.mpTcp + info.SMUX = false + info.Interface = b.iface + info.RoutingMark = b.rmark + return } // IsL3Protocol implements C.ProxyAdapter diff --git a/adapter/outbound/http.go b/adapter/outbound/http.go index ebb1d67cc5..54e05f9db3 100644 --- a/adapter/outbound/http.go +++ b/adapter/outbound/http.go @@ -92,6 +92,13 @@ func (h *Http) SupportWithDialer() C.NetWork { return C.TCP } +// ProxyInfo implements C.ProxyAdapter +func (h *Http) ProxyInfo() C.ProxyInfo { + info := h.Base.ProxyInfo() + info.DialerProxy = h.option.DialerProxy + return info +} + func (h *Http) shakeHand(metadata *C.Metadata, rw io.ReadWriter) error { addr := metadata.RemoteAddress() HeaderString := "CONNECT " + addr + " HTTP/1.1\r\n" diff --git a/adapter/outbound/hysteria.go b/adapter/outbound/hysteria.go index 55c66c455b..b0edab0293 100644 --- a/adapter/outbound/hysteria.go +++ b/adapter/outbound/hysteria.go @@ -87,6 +87,13 @@ func (h *Hysteria) genHdc(ctx context.Context, opts ...dialer.Option) utils.Pack } } +// ProxyInfo implements C.ProxyAdapter +func (h *Hysteria) ProxyInfo() C.ProxyInfo { + info := h.Base.ProxyInfo() + info.DialerProxy = h.option.DialerProxy + return info +} + type HysteriaOption struct { BasicOption Name string `proxy:"name"` diff --git a/adapter/outbound/hysteria2.go b/adapter/outbound/hysteria2.go index c1a255a766..e7a9adaee4 100644 --- a/adapter/outbound/hysteria2.go +++ b/adapter/outbound/hysteria2.go @@ -96,6 +96,13 @@ func closeHysteria2(h *Hysteria2) { } } +// ProxyInfo implements C.ProxyAdapter +func (h *Hysteria2) ProxyInfo() C.ProxyInfo { + info := h.Base.ProxyInfo() + info.DialerProxy = h.option.DialerProxy + return info +} + func NewHysteria2(option Hysteria2Option) (*Hysteria2, error) { addr := net.JoinHostPort(option.Server, strconv.Itoa(option.Port)) var salamanderPassword string diff --git a/adapter/outbound/mieru.go b/adapter/outbound/mieru.go index c87a7c8cb2..6ee7c7bcd3 100644 --- a/adapter/outbound/mieru.go +++ b/adapter/outbound/mieru.go @@ -62,6 +62,13 @@ func (m *Mieru) DialContext(ctx context.Context, metadata *C.Metadata, _ ...dial return NewConn(c, m), nil } +// ProxyInfo implements C.ProxyAdapter +func (m *Mieru) ProxyInfo() C.ProxyInfo { + info := m.Base.ProxyInfo() + info.DialerProxy = m.option.DialerProxy + return info +} + func NewMieru(option MieruOption) (*Mieru, error) { config, err := buildMieruClientConfig(option) if err != nil { diff --git a/adapter/outbound/shadowsocks.go b/adapter/outbound/shadowsocks.go index 1dcfe6dd52..34057c5ae8 100644 --- a/adapter/outbound/shadowsocks.go +++ b/adapter/outbound/shadowsocks.go @@ -197,6 +197,13 @@ func (ss *ShadowSocks) SupportWithDialer() C.NetWork { return C.ALLNet } +// ProxyInfo implements C.ProxyAdapter +func (ss *ShadowSocks) ProxyInfo() C.ProxyInfo { + info := ss.Base.ProxyInfo() + info.DialerProxy = ss.option.DialerProxy + return info +} + // ListenPacketOnStreamConn implements C.ProxyAdapter func (ss *ShadowSocks) ListenPacketOnStreamConn(ctx context.Context, c net.Conn, metadata *C.Metadata) (_ C.PacketConn, err error) { if ss.option.UDPOverTCP { diff --git a/adapter/outbound/shadowsocksr.go b/adapter/outbound/shadowsocksr.go index 437695b4c8..d0752e79dd 100644 --- a/adapter/outbound/shadowsocksr.go +++ b/adapter/outbound/shadowsocksr.go @@ -122,6 +122,13 @@ func (ssr *ShadowSocksR) SupportWithDialer() C.NetWork { return C.ALLNet } +// ProxyInfo implements C.ProxyAdapter +func (ssr *ShadowSocksR) ProxyInfo() C.ProxyInfo { + info := ssr.Base.ProxyInfo() + info.DialerProxy = ssr.option.DialerProxy + return info +} + func NewShadowSocksR(option ShadowSocksROption) (*ShadowSocksR, error) { // SSR protocol compatibility // https://github.com/metacubex/mihomo/pull/2056 diff --git a/adapter/outbound/singmux.go b/adapter/outbound/singmux.go index 5cc4e748b1..26a8d26ea5 100644 --- a/adapter/outbound/singmux.go +++ b/adapter/outbound/singmux.go @@ -97,8 +97,10 @@ func (s *SingMux) SupportUOT() bool { return true } -func (s *SingMux) SupportSMUX() bool { - return true +func (s *SingMux) ProxyInfo() C.ProxyInfo { + info := s.ProxyAdapter.ProxyInfo() + info.SMUX = true + return info } func closeSingMux(s *SingMux) { diff --git a/adapter/outbound/snell.go b/adapter/outbound/snell.go index f6a4b4f9aa..f4b94787e6 100644 --- a/adapter/outbound/snell.go +++ b/adapter/outbound/snell.go @@ -141,6 +141,13 @@ func (s *Snell) SupportUOT() bool { return true } +// ProxyInfo implements C.ProxyAdapter +func (s *Snell) ProxyInfo() C.ProxyInfo { + info := s.Base.ProxyInfo() + info.DialerProxy = s.option.DialerProxy + return info +} + func NewSnell(option SnellOption) (*Snell, error) { addr := net.JoinHostPort(option.Server, strconv.Itoa(option.Port)) psk := []byte(option.Psk) @@ -204,7 +211,7 @@ func NewSnell(option SnellOption) (*Snell, error) { if err != nil { return nil, err } - + return streamConn(c, streamOption{psk, option.Version, addr, obfsOption}), nil }) } diff --git a/adapter/outbound/socks5.go b/adapter/outbound/socks5.go index 1908167abc..b8dd3b39dc 100644 --- a/adapter/outbound/socks5.go +++ b/adapter/outbound/socks5.go @@ -171,6 +171,13 @@ func (ss *Socks5) ListenPacketContext(ctx context.Context, metadata *C.Metadata, return newPacketConn(&socksPacketConn{PacketConn: pc, rAddr: bindUDPAddr, tcpConn: c}, ss), nil } +// ProxyInfo implements C.ProxyAdapter +func (ss *Socks5) ProxyInfo() C.ProxyInfo { + info := ss.Base.ProxyInfo() + info.DialerProxy = ss.option.DialerProxy + return info +} + func NewSocks5(option Socks5Option) (*Socks5, error) { var tlsConfig *tls.Config if option.TLS { diff --git a/adapter/outbound/ssh.go b/adapter/outbound/ssh.go index 9e23b463dd..d746842d4d 100644 --- a/adapter/outbound/ssh.go +++ b/adapter/outbound/ssh.go @@ -121,6 +121,13 @@ func closeSsh(s *Ssh) { _ = s.client.Close() } +// ProxyInfo implements C.ProxyAdapter +func (s *Ssh) ProxyInfo() C.ProxyInfo { + info := s.Base.ProxyInfo() + info.DialerProxy = s.option.DialerProxy + return info +} + func NewSsh(option SshOption) (*Ssh, error) { addr := net.JoinHostPort(option.Server, strconv.Itoa(option.Port)) diff --git a/adapter/outbound/trojan.go b/adapter/outbound/trojan.go index b3a611af05..b626543963 100644 --- a/adapter/outbound/trojan.go +++ b/adapter/outbound/trojan.go @@ -244,6 +244,13 @@ func (t *Trojan) SupportUOT() bool { return true } +// ProxyInfo implements C.ProxyAdapter +func (t *Trojan) ProxyInfo() C.ProxyInfo { + info := t.Base.ProxyInfo() + info.DialerProxy = t.option.DialerProxy + return info +} + func NewTrojan(option TrojanOption) (*Trojan, error) { addr := net.JoinHostPort(option.Server, strconv.Itoa(option.Port)) diff --git a/adapter/outbound/tuic.go b/adapter/outbound/tuic.go index 666e72fad2..eaacb8177a 100644 --- a/adapter/outbound/tuic.go +++ b/adapter/outbound/tuic.go @@ -146,6 +146,13 @@ func (t *Tuic) dialWithDialer(ctx context.Context, dialer C.Dialer) (transport * return } +// ProxyInfo implements C.ProxyAdapter +func (t *Tuic) ProxyInfo() C.ProxyInfo { + info := t.Base.ProxyInfo() + info.DialerProxy = t.option.DialerProxy + return info +} + func NewTuic(option TuicOption) (*Tuic, error) { addr := net.JoinHostPort(option.Server, strconv.Itoa(option.Port)) serverName := option.Server diff --git a/adapter/outbound/vless.go b/adapter/outbound/vless.go index c9f060b211..229da4c981 100644 --- a/adapter/outbound/vless.go +++ b/adapter/outbound/vless.go @@ -378,6 +378,13 @@ func (v *Vless) SupportUOT() bool { return true } +// ProxyInfo implements C.ProxyAdapter +func (v *Vless) ProxyInfo() C.ProxyInfo { + info := v.Base.ProxyInfo() + info.DialerProxy = v.option.DialerProxy + return info +} + func parseVlessAddr(metadata *C.Metadata, xudp bool) *vless.DstAddr { var addrType byte var addr []byte diff --git a/adapter/outbound/vmess.go b/adapter/outbound/vmess.go index 8797374dd8..f7de4e8e7f 100644 --- a/adapter/outbound/vmess.go +++ b/adapter/outbound/vmess.go @@ -388,6 +388,13 @@ func (v *Vmess) SupportWithDialer() C.NetWork { return C.ALLNet } +// ProxyInfo implements C.ProxyAdapter +func (v *Vmess) ProxyInfo() C.ProxyInfo { + info := v.Base.ProxyInfo() + info.DialerProxy = v.option.DialerProxy + return info +} + // ListenPacketOnStreamConn implements C.ProxyAdapter func (v *Vmess) ListenPacketOnStreamConn(ctx context.Context, c net.Conn, metadata *C.Metadata) (_ C.PacketConn, err error) { // vmess use stream-oriented udp with a special address, so we need a net.UDPAddr diff --git a/adapter/outbound/wireguard.go b/adapter/outbound/wireguard.go index ca732baae4..2834d32447 100644 --- a/adapter/outbound/wireguard.go +++ b/adapter/outbound/wireguard.go @@ -611,32 +611,11 @@ func (r *refProxyAdapter) SupportUDP() bool { return false } -func (r *refProxyAdapter) SupportXUDP() bool { +func (r *refProxyAdapter) ProxyInfo() C.ProxyInfo { if r.proxyAdapter != nil { - return r.proxyAdapter.SupportXUDP() + return r.proxyAdapter.ProxyInfo() } - return false -} - -func (r *refProxyAdapter) SupportTFO() bool { - if r.proxyAdapter != nil { - return r.proxyAdapter.SupportTFO() - } - return false -} - -func (r *refProxyAdapter) SupportMPTCP() bool { - if r.proxyAdapter != nil { - return r.proxyAdapter.SupportMPTCP() - } - return false -} - -func (r *refProxyAdapter) SupportSMUX() bool { - if r.proxyAdapter != nil { - return r.proxyAdapter.SupportSMUX() - } - return false + return C.ProxyInfo{} } func (r *refProxyAdapter) MarshalJSON() ([]byte, error) { diff --git a/adapter/provider/parser.go b/adapter/provider/parser.go index b0db5db340..b305df7f89 100644 --- a/adapter/provider/parser.go +++ b/adapter/provider/parser.go @@ -66,6 +66,7 @@ type proxyProviderSchema struct { ExcludeFilter string `provider:"exclude-filter,omitempty"` ExcludeType string `provider:"exclude-type,omitempty"` DialerProxy string `provider:"dialer-proxy,omitempty"` + SizeLimit int64 `provider:"size-limit,omitempty"` HealthCheck healthCheckSchema `provider:"health-check,omitempty"` Override OverrideSchema `provider:"override,omitempty"` @@ -111,7 +112,7 @@ func ParseProxyProvider(name string, mapping map[string]any) (types.ProxyProvide return nil, fmt.Errorf("%w: %s", errSubPath, path) } } - vehicle = resource.NewHTTPVehicle(schema.URL, path, schema.Proxy, schema.Header, resource.DefaultHttpTimeout) + vehicle = resource.NewHTTPVehicle(schema.URL, path, schema.Proxy, schema.Header, resource.DefaultHttpTimeout, schema.SizeLimit) default: return nil, fmt.Errorf("%w: %s", errVehicleType, schema.Type) } diff --git a/component/resource/vehicle.go b/component/resource/vehicle.go index 7c3cb1c2a1..18cebf002c 100644 --- a/component/resource/vehicle.go +++ b/component/resource/vehicle.go @@ -84,12 +84,13 @@ func NewFileVehicle(path string) *FileVehicle { } type HTTPVehicle struct { - url string - path string - proxy string - header http.Header - timeout time.Duration - provider types.ProxyProvider + url string + path string + proxy string + header http.Header + timeout time.Duration + sizeLimit int64 + provider types.ProxyProvider } func (h *HTTPVehicle) Url() string { @@ -151,7 +152,11 @@ func (h *HTTPVehicle) Read(ctx context.Context, oldHash utils.HashType) (buf []b err = errors.New(resp.Status) return } - buf, err = io.ReadAll(resp.Body) + var reader io.Reader = resp.Body + if h.sizeLimit > 0 { + reader = io.LimitReader(reader, h.sizeLimit) + } + buf, err = io.ReadAll(reader) if err != nil { return } @@ -166,12 +171,13 @@ func (h *HTTPVehicle) Read(ctx context.Context, oldHash utils.HashType) (buf []b return } -func NewHTTPVehicle(url string, path string, proxy string, header http.Header, timeout time.Duration) *HTTPVehicle { +func NewHTTPVehicle(url string, path string, proxy string, header http.Header, timeout time.Duration, sizeLimit int64) *HTTPVehicle { return &HTTPVehicle{ - url: url, - path: path, - proxy: proxy, - header: header, - timeout: timeout, + url: url, + path: path, + proxy: proxy, + header: header, + timeout: timeout, + sizeLimit: sizeLimit, } } diff --git a/component/updater/update_geo.go b/component/updater/update_geo.go index bba0dabd2e..719a521515 100644 --- a/component/updater/update_geo.go +++ b/component/updater/update_geo.go @@ -45,7 +45,7 @@ func SetGeoUpdateInterval(newGeoUpdateInterval int) { } func UpdateMMDB() (err error) { - vehicle := resource.NewHTTPVehicle(geodata.MmdbUrl(), C.Path.MMDB(), "", nil, defaultHttpTimeout) + vehicle := resource.NewHTTPVehicle(geodata.MmdbUrl(), C.Path.MMDB(), "", nil, defaultHttpTimeout, 0) var oldHash utils.HashType if buf, err := os.ReadFile(vehicle.Path()); err == nil { oldHash = utils.MakeHash(buf) @@ -76,7 +76,7 @@ func UpdateMMDB() (err error) { } func UpdateASN() (err error) { - vehicle := resource.NewHTTPVehicle(geodata.ASNUrl(), C.Path.ASN(), "", nil, defaultHttpTimeout) + vehicle := resource.NewHTTPVehicle(geodata.ASNUrl(), C.Path.ASN(), "", nil, defaultHttpTimeout, 0) var oldHash utils.HashType if buf, err := os.ReadFile(vehicle.Path()); err == nil { oldHash = utils.MakeHash(buf) @@ -109,7 +109,7 @@ func UpdateASN() (err error) { func UpdateGeoIp() (err error) { geoLoader, err := geodata.GetGeoDataLoader("standard") - vehicle := resource.NewHTTPVehicle(geodata.GeoIpUrl(), C.Path.GeoIP(), "", nil, defaultHttpTimeout) + vehicle := resource.NewHTTPVehicle(geodata.GeoIpUrl(), C.Path.GeoIP(), "", nil, defaultHttpTimeout, 0) var oldHash utils.HashType if buf, err := os.ReadFile(vehicle.Path()); err == nil { oldHash = utils.MakeHash(buf) @@ -139,7 +139,7 @@ func UpdateGeoIp() (err error) { func UpdateGeoSite() (err error) { geoLoader, err := geodata.GetGeoDataLoader("standard") - vehicle := resource.NewHTTPVehicle(geodata.GeoSiteUrl(), C.Path.GeoSite(), "", nil, defaultHttpTimeout) + vehicle := resource.NewHTTPVehicle(geodata.GeoSiteUrl(), C.Path.GeoSite(), "", nil, defaultHttpTimeout, 0) var oldHash utils.HashType if buf, err := os.ReadFile(vehicle.Path()); err == nil { oldHash = utils.MakeHash(buf) diff --git a/constant/adapters.go b/constant/adapters.go index 01c1b6cf30..d500cd8034 100644 --- a/constant/adapters.go +++ b/constant/adapters.go @@ -100,15 +100,24 @@ type Dialer interface { ListenPacket(ctx context.Context, network, address string, rAddrPort netip.AddrPort) (net.PacketConn, error) } +type ProxyInfo struct { + XUDP bool + TFO bool + MPTCP bool + SMUX bool + Interface string + RoutingMark int + DialerProxy string +} + type ProxyAdapter interface { Name() string Type() AdapterType Addr() string SupportUDP() bool - SupportXUDP() bool - SupportTFO() bool - SupportMPTCP() bool - SupportSMUX() bool + + // ProxyInfo contains some extra information maybe useful for MarshalJSON + ProxyInfo() ProxyInfo MarshalJSON() ([]byte, error) // Deprecated: use DialContextWithDialer and ListenPacketWithDialer instead. diff --git a/docs/config.yaml b/docs/config.yaml index e75e5bd59b..5e83eea376 100644 --- a/docs/config.yaml +++ b/docs/config.yaml @@ -930,6 +930,7 @@ proxy-providers: interval: 3600 path: ./provider1.yaml # 默认只允许存储在 mihomo 的 Home Dir,如果想存储到任意位置,添加环境变量 SKIP_SAFE_PATH_CHECK=1 proxy: DIRECT + # size-limit: 10240 # 限制下载文件最大为10kb,默认为0即不限制文件大小 header: User-Agent: - "Clash/v1.18.0" @@ -977,6 +978,7 @@ rule-providers: type: http # http 的 path 可空置,默认储存路径为 homedir 的 rules 文件夹,文件名为 url 的 md5 url: "url" proxy: DIRECT + # size-limit: 10240 # 限制下载文件最大为10kb,默认为0即不限制文件大小 rule2: behavior: classical interval: 259200 diff --git a/go.mod b/go.mod index 3f1d0c1b55..c096c6c14a 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/metacubex/mihomo -go 1.22 +go 1.23 require ( github.com/3andne/restls-client-go v0.1.6 @@ -28,7 +28,7 @@ require ( github.com/metacubex/sing-shadowsocks2 v0.2.2 github.com/metacubex/sing-tun v0.2.7-0.20241106120309-53606a70db98 github.com/metacubex/sing-vmess v0.1.9-0.20240719134745-1df6fb20bbf9 - github.com/metacubex/sing-wireguard v0.0.0-20240924052438-b0976fc59ea3 + github.com/metacubex/sing-wireguard v0.0.0-20241126021510-0827d417b589 github.com/metacubex/tfo-go v0.0.0-20241006021335-daedaf0ca7aa github.com/metacubex/utls v1.6.6 github.com/metacubex/wireguard-go v0.0.0-20240922131502-c182e7471181 @@ -52,10 +52,10 @@ require ( gitlab.com/go-extension/aes-ccm v0.0.0-20230221065045-e58665ef23c7 go.uber.org/automaxprocs v1.6.0 go4.org/netipx v0.0.0-20231129151722-fdeea329fbba - golang.org/x/crypto v0.28.0 + golang.org/x/crypto v0.29.0 golang.org/x/exp v0.0.0-20240904232852-e7e105dedf7e // lastest version compatible with golang1.20 - golang.org/x/net v0.30.0 - golang.org/x/sys v0.26.0 + golang.org/x/net v0.31.0 + golang.org/x/sys v0.27.0 google.golang.org/protobuf v1.35.1 gopkg.in/yaml.v3 v3.0.1 lukechampine.com/blake3 v1.3.0 @@ -88,7 +88,7 @@ require ( github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 // indirect github.com/mailru/easyjson v0.7.7 // indirect github.com/mdlayher/socket v0.4.1 // indirect - github.com/metacubex/gvisor v0.0.0-20240320004321-933faba989ec // indirect + github.com/metacubex/gvisor v0.0.0-20241126021258-5b028898cc5a // indirect github.com/oasisprotocol/deoxysii v0.0.0-20220228165953-2091330c22b7 // indirect github.com/onsi/ginkgo/v2 v2.9.5 // indirect github.com/pierrec/lz4/v4 v4.1.14 // indirect @@ -111,9 +111,9 @@ require ( gitlab.com/yawning/bsaes.git v0.0.0-20190805113838-0a714cd429ec // indirect go.uber.org/mock v0.4.0 // indirect golang.org/x/mod v0.20.0 // indirect - golang.org/x/sync v0.8.0 // indirect - golang.org/x/text v0.19.0 // indirect - golang.org/x/time v0.5.0 // indirect + golang.org/x/sync v0.9.0 // indirect + golang.org/x/text v0.20.0 // indirect + golang.org/x/time v0.7.0 // indirect golang.org/x/tools v0.24.0 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20240610135401-a8a62080eff3 // indirect google.golang.org/grpc v1.64.1 // indirect diff --git a/go.sum b/go.sum index 51485ca53c..4cd722c780 100644 --- a/go.sum +++ b/go.sum @@ -107,26 +107,29 @@ github.com/metacubex/chacha v0.1.0 h1:tg9RSJ18NvL38cCWNyYH1eiG6qDCyyXIaTLQthon0s github.com/metacubex/chacha v0.1.0/go.mod h1:Djn9bPZxLTXbJFSeyo0/qzEzQI+gUSSzttuzZM75GH8= github.com/metacubex/gopacket v1.1.20-0.20230608035415-7e2f98a3e759 h1:cjd4biTvOzK9ubNCCkQ+ldc4YSH/rILn53l/xGBFHHI= github.com/metacubex/gopacket v1.1.20-0.20230608035415-7e2f98a3e759/go.mod h1:UHOv2xu+RIgLwpXca7TLrXleEd4oR3sPatW6IF8wU88= -github.com/metacubex/gvisor v0.0.0-20240320004321-933faba989ec h1:HxreOiFTUrJXJautEo8rnE1uKTVGY8wtZepY1Tii/Nc= -github.com/metacubex/gvisor v0.0.0-20240320004321-933faba989ec/go.mod h1:8BVmQ+3cxjqzWElafm24rb2Ae4jRI6vAXNXWqWjfrXw= -github.com/metacubex/quic-go v0.48.2-0.20241105005628-a3e65bac65b2 h1:1prpWzQnhN/LgGTMA6nz86MGcppDUOwfRkhxPOnrzAk= +github.com/metacubex/gvisor v0.0.0-20241126021258-5b028898cc5a h1:cZ6oNVrsmsi3SNlnSnRio4zOgtQq+/XidwsaNgKICcg= +github.com/metacubex/gvisor v0.0.0-20241126021258-5b028898cc5a/go.mod h1:xBw/SYJPgUMPQ1tklV/brGn2nxhfr3BnvBzNlyi4Nic= github.com/metacubex/quic-go v0.48.2-0.20241105005628-a3e65bac65b2/go.mod h1:AiZ+UPgrkO1DTnmiAX4b+kRoV1Vfc65UkYD7RbFlIZA= +github.com/metacubex/quic-go v0.48.3-0.20241126053724-b69fea3888da h1:Mq6cbHbPTLLTUfA9scrwBmOGkvl6y99E3WmtMIMqo30= +github.com/metacubex/quic-go v0.48.3-0.20241126053724-b69fea3888da/go.mod h1:AiZ+UPgrkO1DTnmiAX4b+kRoV1Vfc65UkYD7RbFlIZA= github.com/metacubex/randv2 v0.2.0 h1:uP38uBvV2SxYfLj53kuvAjbND4RUDfFJjwr4UigMiLs= github.com/metacubex/randv2 v0.2.0/go.mod h1:kFi2SzrQ5WuneuoLLCMkABtiBu6VRrMrWFqSPyj2cxY= -github.com/metacubex/sing v0.0.0-20241105005934-13bf5e941908 h1:cZYdGEQKfLsw//TI7dk9bdplz48zitpEDbDGusB9d40= github.com/metacubex/sing v0.0.0-20241105005934-13bf5e941908/go.mod h1:ARkL0gM13/Iv5VCZmci/NuoOlePoIsW0m7BWfln/Hak= +github.com/metacubex/sing v0.0.0-20241121030428-33b6ebc52000 h1:gUbMXcQXhXGj0vCpCVFTUyIH7TMpD1dpTcNv/MCS+ok= +github.com/metacubex/sing v0.0.0-20241121030428-33b6ebc52000/go.mod h1:ARkL0gM13/Iv5VCZmci/NuoOlePoIsW0m7BWfln/Hak= github.com/metacubex/sing-quic v0.0.0-20240827003841-cd97758ed8b4 h1:HobpULaPK6OoxrHMmgcwLkwwIduXVmwdcznwUfH1GQM= github.com/metacubex/sing-quic v0.0.0-20240827003841-cd97758ed8b4/go.mod h1:g7Mxj7b7zm7YVqD975mk/hSmrb0A0G4bVvIMr2MMzn8= github.com/metacubex/sing-shadowsocks v0.2.8 h1:wIhlaigswzjPw4hej75sEvWte3QR0+AJRafgwBHO5B4= github.com/metacubex/sing-shadowsocks v0.2.8/go.mod h1:X3x88XtJpBxG0W0/ECOJL6Ib0SJ3xdniAkU/6/RMWU0= github.com/metacubex/sing-shadowsocks2 v0.2.2 h1:eaf42uVx4Lr21S6MDYs0ZdTvGA0GEhDpb9no4+gdXPo= github.com/metacubex/sing-shadowsocks2 v0.2.2/go.mod h1:BhOug03a/RbI7y6hp6q+6ITM1dXjnLTmeWBHSTwvv2Q= -github.com/metacubex/sing-tun v0.2.7-0.20241106120309-53606a70db98 h1:vW0QDrzUc4k1yi3A76lDW064zonPj880QFcpTD58u7A= github.com/metacubex/sing-tun v0.2.7-0.20241106120309-53606a70db98/go.mod h1:GRcrj7VnhvYFsS34cv0J2qTVm5h9DvQuGwliVyVLVvE= +github.com/metacubex/sing-tun v0.4.2 h1:fwrQp3P536Pswu6gR1FJ+8GH55e+t2+B8LHIjwRtWbc= +github.com/metacubex/sing-tun v0.4.2/go.mod h1:V0N4rr0dWPBEE20ESkTXdbtx2riQYcb6YtwC5w/9wl0= github.com/metacubex/sing-vmess v0.1.9-0.20240719134745-1df6fb20bbf9 h1:OAXiCosqY8xKDp3pqTW3qbrCprZ1l6WkrXSFSCwyY4I= github.com/metacubex/sing-vmess v0.1.9-0.20240719134745-1df6fb20bbf9/go.mod h1:olVkD4FChQ5gKMHG4ZzuD7+fMkJY1G8vwOKpRehjrmY= -github.com/metacubex/sing-wireguard v0.0.0-20240924052438-b0976fc59ea3 h1:xg71VmzLS6ByAzi/57phwDvjE+dLLs+ozH00k4DnOns= -github.com/metacubex/sing-wireguard v0.0.0-20240924052438-b0976fc59ea3/go.mod h1:6nitcmzPDL3MXnLdhu6Hm126Zk4S1fBbX3P7jxUxSFw= +github.com/metacubex/sing-wireguard v0.0.0-20241126021510-0827d417b589 h1:Z6bNy0HLTjx6BKIkV48sV/yia/GP8Bnyb5JQuGgSGzg= +github.com/metacubex/sing-wireguard v0.0.0-20241126021510-0827d417b589/go.mod h1:4NclTLIZuk+QkHVCGrP87rHi/y8YjgPytxTgApJNMhc= github.com/metacubex/tfo-go v0.0.0-20241006021335-daedaf0ca7aa h1:9mcjV+RGZVC3reJBNDjjNPyS8PmFG97zq56X7WNaFO4= github.com/metacubex/tfo-go v0.0.0-20241006021335-daedaf0ca7aa/go.mod h1:4tLB5c8U0CxpkFM+AJJB77jEaVDbLH5XQvy42vAGsWw= github.com/metacubex/utls v1.6.6 h1:3D12YKHTf2Z41UPhQU2dWerNWJ5TVQD9gKoQ+H+iLC8= @@ -240,8 +243,8 @@ go4.org/netipx v0.0.0-20231129151722-fdeea329fbba h1:0b9z3AuHCjxk0x/opv64kcgZLBs go4.org/netipx v0.0.0-20231129151722-fdeea329fbba/go.mod h1:PLyyIXexvUFg3Owu6p/WfdlivPbZJsZdgWZlrGope/Y= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.28.0 h1:GBDwsMXVQi34v5CCYUm2jkJvu4cbtru2U4TN2PSyQnw= -golang.org/x/crypto v0.28.0/go.mod h1:rmgy+3RHxRZMyY0jjAJShp2zgEdOqj2AO7U0pYmeQ7U= +golang.org/x/crypto v0.29.0 h1:L5SG1JTTXupVV3n6sUqMTeWbjAyfPwoda2DLX8J8FrQ= +golang.org/x/crypto v0.29.0/go.mod h1:+F4F4N5hv6v38hfeYwTdx20oUvLLc+QfrE9Ax9HtgRg= golang.org/x/exp v0.0.0-20240904232852-e7e105dedf7e h1:I88y4caeGeuDQxgdoFPUq097j7kNfw6uvuiNxUBfcBk= golang.org/x/exp v0.0.0-20240904232852-e7e105dedf7e/go.mod h1:akd2r19cwCdwSwWeIdzYQGa/EZZyqcOdwWiwj5L5eKQ= golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= @@ -250,11 +253,11 @@ golang.org/x/mod v0.20.0 h1:utOm6MM3R3dnawAiJgn0y+xvuYRsm1RKM/4giyfDgV0= golang.org/x/mod v0.20.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.30.0 h1:AcW1SDZMkb8IpzCdQUaIq2sP4sZ4zw+55h6ynffypl4= -golang.org/x/net v0.30.0/go.mod h1:2wGyMJ5iFasEhkwi13ChkO/t1ECNC4X4eBKkVFyYFlU= +golang.org/x/net v0.31.0 h1:68CPQngjLL0r2AlUKiSxtQFKvzRVbnzLwMUn5SzcLHo= +golang.org/x/net v0.31.0/go.mod h1:P4fl1q7dY2hnZFxEk4pPSkDHF+QqjitcnDjUQyMM+pM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ= -golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/sync v0.9.0 h1:fEo0HyrW1GIgZdpbhCRO0PkJajUS5H9IFUztCgEo2jQ= +golang.org/x/sync v0.9.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190606203320-7fc4e5ec1444/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -271,15 +274,15 @@ golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo= -golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/term v0.25.0 h1:WtHI/ltw4NvSUig5KARz9h521QvRC8RmF/cuYqifU24= +golang.org/x/sys v0.27.0 h1:wBqf8DvsY9Y/2P8gAfPDEYNuS30J4lPHJxXSb/nJZ+s= +golang.org/x/sys v0.27.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.25.0/go.mod h1:RPyXicDX+6vLxogjjRxjgD2TKtmAO6NZBsBRfrOLu7M= +golang.org/x/term v0.26.0 h1:WEQa6V3Gja/BhNxg540hBip/kkaYtRg3cxg4oXSw4AU= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.19.0 h1:kTxAhCbGbxhK0IwgSKiMO5awPoDQ0RpfiVYBfK860YM= -golang.org/x/text v0.19.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= -golang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk= -golang.org/x/time v0.5.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM= +golang.org/x/text v0.20.0 h1:gK/Kv2otX8gz+wn7Rmb3vT96ZwuoxnQlY+HlJVj7Qug= +golang.org/x/text v0.20.0/go.mod h1:D4IsuqiFMhST5bX19pQ9ikHC2GsaKyk/oF+pn3ducp4= +golang.org/x/time v0.7.0 h1:ntUhktv3OPE6TgYxXWv9vKvUSJyIFJlyohwbkEwPrKQ= +golang.org/x/time v0.7.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM= golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.24.0 h1:J1shsA93PJUEVaUSaay7UXAyE8aimq3GW0pjlolpa24= golang.org/x/tools v0.24.0/go.mod h1:YhNqVBIfWHdzvTLs0d8LCuMhkKUgSUKldakyV7W/WDQ= diff --git a/rules/provider/parse.go b/rules/provider/parse.go index 3bd8f54c8e..b04096fb3c 100644 --- a/rules/provider/parse.go +++ b/rules/provider/parse.go @@ -16,13 +16,14 @@ var ( ) type ruleProviderSchema struct { - Type string `provider:"type"` - Behavior string `provider:"behavior"` - Path string `provider:"path,omitempty"` - URL string `provider:"url,omitempty"` - Proxy string `provider:"proxy,omitempty"` - Format string `provider:"format,omitempty"` - Interval int `provider:"interval,omitempty"` + Type string `provider:"type"` + Behavior string `provider:"behavior"` + Path string `provider:"path,omitempty"` + URL string `provider:"url,omitempty"` + Proxy string `provider:"proxy,omitempty"` + Format string `provider:"format,omitempty"` + Interval int `provider:"interval,omitempty"` + SizeLimit int64 `provider:"size-limit,omitempty"` } func ParseRuleProvider(name string, mapping map[string]interface{}, parse func(tp, payload, target string, params []string, subRules map[string][]C.Rule) (parsed C.Rule, parseErr error)) (P.RuleProvider, error) { @@ -53,7 +54,7 @@ func ParseRuleProvider(name string, mapping map[string]interface{}, parse func(t return nil, fmt.Errorf("%w: %s", errSubPath, path) } } - vehicle = resource.NewHTTPVehicle(schema.URL, path, schema.Proxy, nil, resource.DefaultHttpTimeout) + vehicle = resource.NewHTTPVehicle(schema.URL, path, schema.Proxy, nil, resource.DefaultHttpTimeout, schema.SizeLimit) default: return nil, fmt.Errorf("unsupported vehicle type: %s", schema.Type) }