mirror of
https://github.com/bolucat/Archive.git
synced 2026-04-22 16:07:49 +08:00
Update On Fri Apr 19 20:26:22 CEST 2024
This commit is contained in:
@@ -621,3 +621,4 @@ Update On Mon Apr 15 20:26:48 CEST 2024
|
||||
Update On Tue Apr 16 20:28:30 CEST 2024
|
||||
Update On Wed Apr 17 20:28:12 CEST 2024
|
||||
Update On Thu Apr 18 20:29:16 CEST 2024
|
||||
Update On Fri Apr 19 20:26:11 CEST 2024
|
||||
|
||||
@@ -9,7 +9,7 @@ buildscript {
|
||||
repositories {
|
||||
mavenCentral()
|
||||
google()
|
||||
maven("https://maven.kr328.app/releases")
|
||||
maven("https://raw.githubusercontent.com/MetaCubeX/maven-backup/main/releases")
|
||||
}
|
||||
dependencies {
|
||||
classpath(libs.build.android)
|
||||
@@ -24,7 +24,7 @@ subprojects {
|
||||
repositories {
|
||||
mavenCentral()
|
||||
google()
|
||||
maven("https://maven.kr328.app/releases")
|
||||
maven("https://raw.githubusercontent.com/MetaCubeX/maven-backup/main/releases")
|
||||
}
|
||||
|
||||
val isApp = name == "app"
|
||||
|
||||
@@ -6,8 +6,8 @@ After=network.target NetworkManager.service systemd-networkd.service iwd.service
|
||||
Type=simple
|
||||
LimitNPROC=500
|
||||
LimitNOFILE=1000000
|
||||
CapabilityBoundingSet=CAP_NET_ADMIN CAP_NET_RAW CAP_NET_BIND_SERVICE CAP_SYS_TIME CAP_SYS_PTRACE CAP_DAC_READ_SEARCH
|
||||
AmbientCapabilities=CAP_NET_ADMIN CAP_NET_RAW CAP_NET_BIND_SERVICE CAP_SYS_TIME CAP_SYS_PTRACE CAP_DAC_READ_SEARCH
|
||||
CapabilityBoundingSet=CAP_NET_ADMIN CAP_NET_RAW CAP_NET_BIND_SERVICE CAP_SYS_TIME CAP_SYS_PTRACE CAP_DAC_READ_SEARCH CAP_DAC_OVERRIDE
|
||||
AmbientCapabilities=CAP_NET_ADMIN CAP_NET_RAW CAP_NET_BIND_SERVICE CAP_SYS_TIME CAP_SYS_PTRACE CAP_DAC_READ_SEARCH CAP_DAC_OVERRIDE
|
||||
Restart=always
|
||||
ExecStartPre=/usr/bin/sleep 2s
|
||||
ExecStart=/usr/bin/mihomo -d /etc/mihomo
|
||||
|
||||
@@ -177,6 +177,11 @@ jobs:
|
||||
else
|
||||
ARCH=${{matrix.jobs.goarch}}
|
||||
fi
|
||||
PackageVersion=$(curl -s "https://api.github.com/repos/MetaCubeX/mihomo/releases/latest" | grep -o '"tag_name": "[^"]*' | grep -o '[^"]*$' | sed 's/v//g' )
|
||||
if [ $(git branch | awk -F ' ' '{print $2}') = "Alpha" ]; then
|
||||
PackageVersion="$(echo "${PackageVersion}" | awk -F '.' '{$NF = $NF + 1; print}' OFS='.')-${VERSION}"
|
||||
fi
|
||||
|
||||
mkdir -p mihomo-${{matrix.jobs.goos}}-${{matrix.jobs.output}}-${VERSION}/DEBIAN
|
||||
mkdir -p mihomo-${{matrix.jobs.goos}}-${{matrix.jobs.output}}-${VERSION}/usr/bin
|
||||
mkdir -p mihomo-${{matrix.jobs.goos}}-${{matrix.jobs.output}}-${VERSION}/etc/mihomo
|
||||
@@ -194,7 +199,7 @@ jobs:
|
||||
|
||||
cat > mihomo-${{matrix.jobs.goos}}-${{matrix.jobs.output}}-${VERSION}/DEBIAN/control <<EOF
|
||||
Package: mihomo
|
||||
Version: 1.18.2-${VERSION}
|
||||
Version: ${PackageVersion}
|
||||
Section:
|
||||
Priority: extra
|
||||
Architecture: ${ARCH}
|
||||
|
||||
@@ -89,14 +89,14 @@ func (d *dnsPacketConn) WriteTo(p []byte, addr net.Addr) (n int, err error) {
|
||||
return len(p), nil
|
||||
}
|
||||
|
||||
ctx, cancel := context.WithTimeout(d.ctx, resolver.DefaultDnsRelayTimeout)
|
||||
defer cancel()
|
||||
|
||||
buf := pool.Get(resolver.SafeDnsPacketSize)
|
||||
put := func() { _ = pool.Put(buf) }
|
||||
copy(buf, p) // avoid p be changed after WriteTo returned
|
||||
|
||||
go func() { // don't block the WriteTo function
|
||||
ctx, cancel := context.WithTimeout(d.ctx, resolver.DefaultDnsRelayTimeout)
|
||||
defer cancel()
|
||||
|
||||
buf, err = resolver.RelayDnsPacket(ctx, buf[:len(p)], buf)
|
||||
if err != nil {
|
||||
put()
|
||||
|
||||
@@ -89,27 +89,26 @@ func ParseProxyGroup(config map[string]any, proxyMap map[string]C.Proxy, provide
|
||||
groupOption.ExpectedStatus = status
|
||||
|
||||
if len(groupOption.Use) != 0 {
|
||||
list, err := getProviders(providersMap, groupOption.Use)
|
||||
PDs, err := getProviders(providersMap, groupOption.Use)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("%s: %w", groupName, err)
|
||||
}
|
||||
|
||||
// if test URL is empty, use the first health check URL of providers
|
||||
if groupOption.URL == "" {
|
||||
for _, p := range list {
|
||||
if p.HealthCheckURL() != "" {
|
||||
groupOption.URL = p.HealthCheckURL()
|
||||
for _, pd := range PDs {
|
||||
if pd.HealthCheckURL() != "" {
|
||||
groupOption.URL = pd.HealthCheckURL()
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if groupOption.URL == "" {
|
||||
groupOption.URL = C.DefaultTestURL
|
||||
}
|
||||
} else {
|
||||
addTestUrlToProviders(PDs, groupOption.URL, expectedStatus, groupOption.Filter, uint(groupOption.Interval))
|
||||
}
|
||||
|
||||
// different proxy groups use different test URL
|
||||
addTestUrlToProviders(list, groupOption.URL, expectedStatus, groupOption.Filter, uint(groupOption.Interval))
|
||||
providers = append(providers, list...)
|
||||
providers = append(providers, PDs...)
|
||||
}
|
||||
|
||||
if len(groupOption.Proxies) != 0 {
|
||||
@@ -140,7 +139,7 @@ func ParseProxyGroup(config map[string]any, proxyMap map[string]C.Proxy, provide
|
||||
return nil, fmt.Errorf("%s: %w", groupName, err)
|
||||
}
|
||||
|
||||
providers = append(providers, pd)
|
||||
providers = append([]types.ProxyProvider{pd}, providers...)
|
||||
providersMap[groupName] = pd
|
||||
}
|
||||
|
||||
|
||||
@@ -44,14 +44,16 @@ type proxyProviderSchema struct {
|
||||
Type string `provider:"type"`
|
||||
Path string `provider:"path,omitempty"`
|
||||
URL string `provider:"url,omitempty"`
|
||||
Proxy string `provider:"proxy,omitempty"`
|
||||
Interval int `provider:"interval,omitempty"`
|
||||
Filter string `provider:"filter,omitempty"`
|
||||
ExcludeFilter string `provider:"exclude-filter,omitempty"`
|
||||
ExcludeType string `provider:"exclude-type,omitempty"`
|
||||
DialerProxy string `provider:"dialer-proxy,omitempty"`
|
||||
|
||||
HealthCheck healthCheckSchema `provider:"health-check,omitempty"`
|
||||
Override OverrideSchema `provider:"override,omitempty"`
|
||||
HealthCheck healthCheckSchema `provider:"health-check,omitempty"`
|
||||
Override OverrideSchema `provider:"override,omitempty"`
|
||||
Header map[string][]string `provider:"header,omitempty"`
|
||||
}
|
||||
|
||||
func ParseProxyProvider(name string, mapping map[string]any) (types.ProxyProvider, error) {
|
||||
@@ -86,16 +88,14 @@ func ParseProxyProvider(name string, mapping map[string]any) (types.ProxyProvide
|
||||
path := C.Path.Resolve(schema.Path)
|
||||
vehicle = resource.NewFileVehicle(path)
|
||||
case "http":
|
||||
path := C.Path.GetPathByHash("proxies", schema.URL)
|
||||
if schema.Path != "" {
|
||||
path := C.Path.Resolve(schema.Path)
|
||||
path = C.Path.Resolve(schema.Path)
|
||||
if !features.CMFA && !C.Path.IsSafePath(path) {
|
||||
return nil, fmt.Errorf("%w: %s", errSubPath, path)
|
||||
}
|
||||
vehicle = resource.NewHTTPVehicle(schema.URL, path)
|
||||
} else {
|
||||
path := C.Path.GetPathByHash("proxies", schema.URL)
|
||||
vehicle = resource.NewHTTPVehicle(schema.URL, path)
|
||||
}
|
||||
vehicle = resource.NewHTTPVehicle(schema.URL, path, schema.Proxy, schema.Header)
|
||||
default:
|
||||
return nil, fmt.Errorf("%w: %s", errVehicleType, schema.Type)
|
||||
}
|
||||
|
||||
@@ -124,8 +124,8 @@ func (pp *proxySetProvider) getSubscriptionInfo() {
|
||||
go func() {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), time.Second*90)
|
||||
defer cancel()
|
||||
resp, err := mihomoHttp.HttpRequest(ctx, pp.Vehicle().(*resource.HTTPVehicle).Url(),
|
||||
http.MethodGet, http.Header{"User-Agent": {C.UA}}, nil)
|
||||
resp, err := mihomoHttp.HttpRequestWithProxy(ctx, pp.Vehicle().(*resource.HTTPVehicle).Url(),
|
||||
http.MethodGet, http.Header{"User-Agent": {C.UA}}, nil, pp.Vehicle().Proxy())
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
@@ -133,8 +133,8 @@ func (pp *proxySetProvider) getSubscriptionInfo() {
|
||||
|
||||
userInfoStr := strings.TrimSpace(resp.Header.Get("subscription-userinfo"))
|
||||
if userInfoStr == "" {
|
||||
resp2, err := mihomoHttp.HttpRequest(ctx, pp.Vehicle().(*resource.HTTPVehicle).Url(),
|
||||
http.MethodGet, http.Header{"User-Agent": {"Quantumultx"}}, nil)
|
||||
resp2, err := mihomoHttp.HttpRequestWithProxy(ctx, pp.Vehicle().(*resource.HTTPVehicle).Url(),
|
||||
http.MethodGet, http.Header{"User-Agent": {"Quantumultx"}}, nil, pp.Vehicle().Proxy())
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package dhcp
|
||||
import (
|
||||
"context"
|
||||
"net"
|
||||
"net/netip"
|
||||
"runtime"
|
||||
|
||||
"github.com/metacubex/mihomo/component/dialer"
|
||||
@@ -24,5 +25,5 @@ func ListenDHCPClient(ctx context.Context, ifaceName string) (net.PacketConn, er
|
||||
options = append(options, dialer.WithFallbackBind(true))
|
||||
}
|
||||
|
||||
return dialer.ListenPacket(ctx, "udp4", listenAddr, options...)
|
||||
return dialer.ListenPacket(ctx, "udp4", listenAddr, netip.AddrPortFrom(netip.AddrFrom4([4]byte{255, 255, 255, 255}), 67), options...)
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@ func fallbackBindIfaceToDialer(ifaceName string, dialer *net.Dialer, network str
|
||||
return nil
|
||||
}
|
||||
|
||||
func fallbackBindIfaceToListenConfig(ifaceName string, _ *net.ListenConfig, network, address string) (string, error) {
|
||||
func fallbackBindIfaceToListenConfig(ifaceName string, _ *net.ListenConfig, network, address string, rAddrPort netip.AddrPort) (string, error) {
|
||||
_, port, err := net.SplitHostPort(address)
|
||||
if err != nil {
|
||||
port = "0"
|
||||
|
||||
@@ -46,7 +46,7 @@ func bindIfaceToDialer(ifaceName string, dialer *net.Dialer, _ string, _ netip.A
|
||||
return nil
|
||||
}
|
||||
|
||||
func bindIfaceToListenConfig(ifaceName string, lc *net.ListenConfig, _, address string) (string, error) {
|
||||
func bindIfaceToListenConfig(ifaceName string, lc *net.ListenConfig, _, address string, rAddrPort netip.AddrPort) (string, error) {
|
||||
ifaceObj, err := iface.ResolveInterface(ifaceName)
|
||||
if err != nil {
|
||||
return "", err
|
||||
|
||||
@@ -35,7 +35,7 @@ func bindIfaceToDialer(ifaceName string, dialer *net.Dialer, _ string, _ netip.A
|
||||
return nil
|
||||
}
|
||||
|
||||
func bindIfaceToListenConfig(ifaceName string, lc *net.ListenConfig, _, address string) (string, error) {
|
||||
func bindIfaceToListenConfig(ifaceName string, lc *net.ListenConfig, _, address string, rAddrPort netip.AddrPort) (string, error) {
|
||||
addControlToListenConfig(lc, bindControl(ifaceName))
|
||||
|
||||
return address, nil
|
||||
|
||||
@@ -11,8 +11,8 @@ func bindIfaceToDialer(ifaceName string, dialer *net.Dialer, network string, des
|
||||
return fallbackBindIfaceToDialer(ifaceName, dialer, network, destination)
|
||||
}
|
||||
|
||||
func bindIfaceToListenConfig(ifaceName string, lc *net.ListenConfig, network, address string) (string, error) {
|
||||
return fallbackBindIfaceToListenConfig(ifaceName, lc, network, address)
|
||||
func bindIfaceToListenConfig(ifaceName string, lc *net.ListenConfig, network, address string, rAddrPort netip.AddrPort) (string, error) {
|
||||
return fallbackBindIfaceToListenConfig(ifaceName, lc, network, address, rAddrPort)
|
||||
}
|
||||
|
||||
func ParseNetwork(network string, addr netip.Addr) string {
|
||||
|
||||
@@ -36,7 +36,7 @@ func bind6(handle syscall.Handle, ifaceIdx int) error {
|
||||
return err
|
||||
}
|
||||
|
||||
func bindControl(ifaceIdx int) controlFn {
|
||||
func bindControl(ifaceIdx int, rAddrPort netip.AddrPort) controlFn {
|
||||
return func(ctx context.Context, network, address string, c syscall.RawConn) (err error) {
|
||||
addrPort, err := netip.ParseAddrPort(address)
|
||||
if err == nil && !addrPort.Addr().IsGlobalUnicast() {
|
||||
@@ -55,7 +55,7 @@ func bindControl(ifaceIdx int) controlFn {
|
||||
innerErr = bind4err
|
||||
case "udp6":
|
||||
// golang will set network to udp6 when listenUDP on wildcard ip (eg: ":0", "")
|
||||
if (!addrPort.Addr().IsValid() || addrPort.Addr().IsUnspecified()) && bind6err != nil {
|
||||
if (!addrPort.Addr().IsValid() || addrPort.Addr().IsUnspecified()) && bind6err != nil && rAddrPort.Addr().Unmap().Is4() {
|
||||
// try bind ipv6, if failed, ignore. it's a workaround for windows disable interface ipv6
|
||||
if bind4err != nil {
|
||||
innerErr = fmt.Errorf("%w (%s)", bind6err, bind4err)
|
||||
@@ -76,23 +76,23 @@ func bindControl(ifaceIdx int) controlFn {
|
||||
}
|
||||
}
|
||||
|
||||
func bindIfaceToDialer(ifaceName string, dialer *net.Dialer, _ string, _ netip.Addr) error {
|
||||
func bindIfaceToDialer(ifaceName string, dialer *net.Dialer, _ string, destination netip.Addr) error {
|
||||
ifaceObj, err := iface.ResolveInterface(ifaceName)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
addControlToDialer(dialer, bindControl(ifaceObj.Index))
|
||||
addControlToDialer(dialer, bindControl(ifaceObj.Index, netip.AddrPortFrom(destination, 0)))
|
||||
return nil
|
||||
}
|
||||
|
||||
func bindIfaceToListenConfig(ifaceName string, lc *net.ListenConfig, _, address string) (string, error) {
|
||||
func bindIfaceToListenConfig(ifaceName string, lc *net.ListenConfig, _, address string, rAddrPort netip.AddrPort) (string, error) {
|
||||
ifaceObj, err := iface.ResolveInterface(ifaceName)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
addControlToListenConfig(lc, bindControl(ifaceObj.Index))
|
||||
addControlToListenConfig(lc, bindControl(ifaceObj.Index, rAddrPort))
|
||||
return address, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -78,7 +78,7 @@ func DialContext(ctx context.Context, network, address string, options ...Option
|
||||
}
|
||||
}
|
||||
|
||||
func ListenPacket(ctx context.Context, network, address string, options ...Option) (net.PacketConn, error) {
|
||||
func ListenPacket(ctx context.Context, network, address string, rAddrPort netip.AddrPort, options ...Option) (net.PacketConn, error) {
|
||||
if features.CMFA && DefaultSocketHook != nil {
|
||||
return listenPacketHooked(ctx, network, address)
|
||||
}
|
||||
@@ -91,7 +91,7 @@ func ListenPacket(ctx context.Context, network, address string, options ...Optio
|
||||
if cfg.fallbackBind {
|
||||
bind = fallbackBindIfaceToListenConfig
|
||||
}
|
||||
addr, err := bind(cfg.interfaceName, lc, network, address)
|
||||
addr, err := bind(cfg.interfaceName, lc, network, address, rAddrPort)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -133,11 +133,9 @@ func dialContext(ctx context.Context, network string, destination netip.Addr, po
|
||||
|
||||
var address string
|
||||
if IP4PEnable {
|
||||
NewDestination, NewPort := lookupIP4P(destination.String(), port)
|
||||
address = net.JoinHostPort(NewDestination, NewPort)
|
||||
} else {
|
||||
address = net.JoinHostPort(destination.String(), port)
|
||||
destination, port = lookupIP4P(destination, port)
|
||||
}
|
||||
address = net.JoinHostPort(destination.String(), port)
|
||||
|
||||
netDialer := opt.netDialer
|
||||
switch netDialer.(type) {
|
||||
@@ -385,7 +383,7 @@ func (d Dialer) ListenPacket(ctx context.Context, network, address string, rAddr
|
||||
// avoid "The requested address is not valid in its context."
|
||||
opt = WithInterface("")
|
||||
}
|
||||
return ListenPacket(ctx, ParseNetwork(network, rAddrPort.Addr()), address, opt)
|
||||
return ListenPacket(ctx, ParseNetwork(network, rAddrPort.Addr()), address, rAddrPort, opt)
|
||||
}
|
||||
|
||||
func NewDialer(options ...Option) Dialer {
|
||||
@@ -399,13 +397,13 @@ func GetIP4PEnable(enableIP4PConvert bool) {
|
||||
|
||||
// kanged from https://github.com/heiher/frp/blob/ip4p/client/ip4p.go
|
||||
|
||||
func lookupIP4P(addr string, port string) (string, string) {
|
||||
ip := net.ParseIP(addr)
|
||||
func lookupIP4P(addr netip.Addr, port string) (netip.Addr, string) {
|
||||
ip := addr.AsSlice()
|
||||
if ip[0] == 0x20 && ip[1] == 0x01 &&
|
||||
ip[2] == 0x00 && ip[3] == 0x00 {
|
||||
addr = net.IPv4(ip[12], ip[13], ip[14], ip[15]).String()
|
||||
addr = netip.AddrFrom4([4]byte{ip[12], ip[13], ip[14], ip[15]})
|
||||
port = strconv.Itoa(int(ip[10])<<8 + int(ip[11]))
|
||||
log.Debugln("Convert IP4P address %s to %s", ip, net.JoinHostPort(addr, port))
|
||||
log.Debugln("Convert IP4P address %s to %s", ip, net.JoinHostPort(addr.String(), port))
|
||||
return addr, port
|
||||
}
|
||||
return addr, port
|
||||
|
||||
@@ -17,7 +17,10 @@ import (
|
||||
)
|
||||
|
||||
func HttpRequest(ctx context.Context, url, method string, header map[string][]string, body io.Reader) (*http.Response, error) {
|
||||
UA := C.UA
|
||||
return HttpRequestWithProxy(ctx, url, method, header, body, "")
|
||||
}
|
||||
|
||||
func HttpRequestWithProxy(ctx context.Context, url, method string, header map[string][]string, body io.Reader, specialProxy string) (*http.Response, error) {
|
||||
method = strings.ToUpper(method)
|
||||
urlRes, err := URL.Parse(url)
|
||||
if err != nil {
|
||||
@@ -32,7 +35,7 @@ func HttpRequest(ctx context.Context, url, method string, header map[string][]st
|
||||
}
|
||||
|
||||
if _, ok := header["User-Agent"]; !ok {
|
||||
req.Header.Set("User-Agent", UA)
|
||||
req.Header.Set("User-Agent", C.UA)
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
@@ -54,7 +57,7 @@ func HttpRequest(ctx context.Context, url, method string, header map[string][]st
|
||||
TLSHandshakeTimeout: 10 * time.Second,
|
||||
ExpectContinueTimeout: 1 * time.Second,
|
||||
DialContext: func(ctx context.Context, network, address string) (net.Conn, error) {
|
||||
if conn, err := inner.HandleTcp(address); err == nil {
|
||||
if conn, err := inner.HandleTcp(address, specialProxy); err == nil {
|
||||
return conn, nil
|
||||
} else {
|
||||
d := net.Dialer{}
|
||||
@@ -66,5 +69,4 @@ func HttpRequest(ctx context.Context, url, method string, header map[string][]st
|
||||
|
||||
client := http.Client{Transport: transport}
|
||||
return client.Do(req)
|
||||
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ var (
|
||||
|
||||
var interfaces = singledo.NewSingle[map[string]*Interface](time.Second * 20)
|
||||
|
||||
func ResolveInterface(name string) (*Interface, error) {
|
||||
func Interfaces() (map[string]*Interface, error) {
|
||||
value, err, _ := interfaces.Do(func() (map[string]*Interface, error) {
|
||||
ifaces, err := net.Interfaces()
|
||||
if err != nil {
|
||||
@@ -69,11 +69,15 @@ func ResolveInterface(name string) (*Interface, error) {
|
||||
|
||||
return r, nil
|
||||
})
|
||||
return value, err
|
||||
}
|
||||
|
||||
func ResolveInterface(name string) (*Interface, error) {
|
||||
ifaces, err := Interfaces()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
ifaces := value
|
||||
iface, ok := ifaces[name]
|
||||
if !ok {
|
||||
return nil, ErrIfaceNotFound
|
||||
@@ -82,6 +86,21 @@ func ResolveInterface(name string) (*Interface, error) {
|
||||
return iface, nil
|
||||
}
|
||||
|
||||
func IsLocalIp(ip netip.Addr) (bool, error) {
|
||||
ifaces, err := Interfaces()
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
for _, iface := range ifaces {
|
||||
for _, addr := range iface.Addrs {
|
||||
if addr.Contains(ip) {
|
||||
return true, nil
|
||||
}
|
||||
}
|
||||
}
|
||||
return false, nil
|
||||
}
|
||||
|
||||
func FlushCache() {
|
||||
interfaces.Reset()
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
"net/netip"
|
||||
|
||||
"github.com/metacubex/mihomo/common/callback"
|
||||
"github.com/metacubex/mihomo/component/iface"
|
||||
C "github.com/metacubex/mihomo/constant"
|
||||
|
||||
"github.com/puzpuzpuz/xsync/v3"
|
||||
@@ -15,13 +16,13 @@ var ErrReject = errors.New("reject loopback connection")
|
||||
|
||||
type Detector struct {
|
||||
connMap *xsync.MapOf[netip.AddrPort, struct{}]
|
||||
packetConnMap *xsync.MapOf[netip.AddrPort, struct{}]
|
||||
packetConnMap *xsync.MapOf[uint16, struct{}]
|
||||
}
|
||||
|
||||
func NewDetector() *Detector {
|
||||
return &Detector{
|
||||
connMap: xsync.NewMapOf[netip.AddrPort, struct{}](),
|
||||
packetConnMap: xsync.NewMapOf[netip.AddrPort, struct{}](),
|
||||
packetConnMap: xsync.NewMapOf[uint16, struct{}](),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,9 +50,10 @@ func (l *Detector) NewPacketConn(conn C.PacketConn) C.PacketConn {
|
||||
if !connAddr.IsValid() {
|
||||
return conn
|
||||
}
|
||||
l.packetConnMap.Store(connAddr, struct{}{})
|
||||
port := connAddr.Port()
|
||||
l.packetConnMap.Store(port, struct{}{})
|
||||
return callback.NewCloseCallbackPacketConn(conn, func() {
|
||||
l.packetConnMap.Delete(connAddr)
|
||||
l.packetConnMap.Delete(port)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -71,7 +73,16 @@ func (l *Detector) CheckPacketConn(metadata *C.Metadata) error {
|
||||
if !connAddr.IsValid() {
|
||||
return nil
|
||||
}
|
||||
if _, ok := l.packetConnMap.Load(connAddr); ok {
|
||||
|
||||
isLocalIp, err := iface.IsLocalIp(connAddr.Addr())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if !isLocalIp && !connAddr.Addr().IsLoopback() {
|
||||
return nil
|
||||
}
|
||||
|
||||
if _, ok := l.packetConnMap.Load(connAddr.Port()); ok {
|
||||
return fmt.Errorf("%w to: %s", ErrReject, metadata.RemoteAddress())
|
||||
}
|
||||
return nil
|
||||
|
||||
@@ -46,7 +46,7 @@ func RelayDnsConn(ctx context.Context, conn net.Conn, readTimeout time.Duration)
|
||||
ctx, cancel := context.WithTimeout(ctx, DefaultDnsRelayTimeout)
|
||||
defer cancel()
|
||||
inData := buff[:n]
|
||||
msg, err := RelayDnsPacket(ctx, inData, buff)
|
||||
msg, err := relayDnsPacket(ctx, inData, buff, 0)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -69,7 +69,7 @@ func RelayDnsConn(ctx context.Context, conn net.Conn, readTimeout time.Duration)
|
||||
return nil
|
||||
}
|
||||
|
||||
func RelayDnsPacket(ctx context.Context, payload []byte, target []byte) ([]byte, error) {
|
||||
func relayDnsPacket(ctx context.Context, payload []byte, target []byte, maxSize int) ([]byte, error) {
|
||||
msg := &D.Msg{}
|
||||
if err := msg.Unpack(payload); err != nil {
|
||||
return nil, err
|
||||
@@ -83,6 +83,14 @@ func RelayDnsPacket(ctx context.Context, payload []byte, target []byte) ([]byte,
|
||||
}
|
||||
|
||||
r.SetRcode(msg, r.Rcode)
|
||||
if maxSize > 0 {
|
||||
r.Truncate(maxSize)
|
||||
}
|
||||
r.Compress = true
|
||||
return r.PackBuffer(target)
|
||||
}
|
||||
|
||||
// RelayDnsPacket will truncate udp message up to SafeDnsPacketSize
|
||||
func RelayDnsPacket(ctx context.Context, payload []byte, target []byte) ([]byte, error) {
|
||||
return relayDnsPacket(ctx, payload, target, SafeDnsPacketSize)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
package resolver
|
||||
|
||||
import "sync"
|
||||
|
||||
var blacklist struct {
|
||||
Map map[string]struct{}
|
||||
Mutex sync.Mutex
|
||||
}
|
||||
|
||||
func init() {
|
||||
blacklist.Map = make(map[string]struct{})
|
||||
}
|
||||
|
||||
func AddSystemDnsBlacklist(names ...string) {
|
||||
blacklist.Mutex.Lock()
|
||||
defer blacklist.Mutex.Unlock()
|
||||
for _, name := range names {
|
||||
blacklist.Map[name] = struct{}{}
|
||||
}
|
||||
}
|
||||
|
||||
func RemoveSystemDnsBlacklist(names ...string) {
|
||||
blacklist.Mutex.Lock()
|
||||
defer blacklist.Mutex.Unlock()
|
||||
for _, name := range names {
|
||||
delete(blacklist.Map, name)
|
||||
}
|
||||
}
|
||||
|
||||
func IsSystemDnsBlacklisted(names ...string) bool {
|
||||
blacklist.Mutex.Lock()
|
||||
defer blacklist.Mutex.Unlock()
|
||||
for _, name := range names {
|
||||
if _, ok := blacklist.Map[name]; ok {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
@@ -28,13 +28,19 @@ func (f *FileVehicle) Read() ([]byte, error) {
|
||||
return os.ReadFile(f.path)
|
||||
}
|
||||
|
||||
func (f *FileVehicle) Proxy() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func NewFileVehicle(path string) *FileVehicle {
|
||||
return &FileVehicle{path: path}
|
||||
}
|
||||
|
||||
type HTTPVehicle struct {
|
||||
url string
|
||||
path string
|
||||
url string
|
||||
path string
|
||||
proxy string
|
||||
header http.Header
|
||||
}
|
||||
|
||||
func (h *HTTPVehicle) Url() string {
|
||||
@@ -49,10 +55,14 @@ func (h *HTTPVehicle) Path() string {
|
||||
return h.path
|
||||
}
|
||||
|
||||
func (h *HTTPVehicle) Proxy() string {
|
||||
return h.proxy
|
||||
}
|
||||
|
||||
func (h *HTTPVehicle) Read() ([]byte, error) {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), time.Second*20)
|
||||
defer cancel()
|
||||
resp, err := mihomoHttp.HttpRequest(ctx, h.url, http.MethodGet, nil, nil)
|
||||
resp, err := mihomoHttp.HttpRequestWithProxy(ctx, h.url, http.MethodGet, h.header, nil, h.proxy)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -67,6 +77,6 @@ func (h *HTTPVehicle) Read() ([]byte, error) {
|
||||
return buf, nil
|
||||
}
|
||||
|
||||
func NewHTTPVehicle(url string, path string) *HTTPVehicle {
|
||||
return &HTTPVehicle{url, path}
|
||||
func NewHTTPVehicle(url string, path string, proxy string, header http.Header) *HTTPVehicle {
|
||||
return &HTTPVehicle{url, path, proxy, header}
|
||||
}
|
||||
|
||||
@@ -91,10 +91,11 @@ type Inbound struct {
|
||||
|
||||
// Controller config
|
||||
type Controller struct {
|
||||
ExternalController string `json:"-"`
|
||||
ExternalControllerTLS string `json:"-"`
|
||||
ExternalUI string `json:"-"`
|
||||
Secret string `json:"-"`
|
||||
ExternalController string `json:"-"`
|
||||
ExternalControllerTLS string `json:"-"`
|
||||
ExternalControllerUnix string `json:"-"`
|
||||
ExternalUI string `json:"-"`
|
||||
Secret string `json:"-"`
|
||||
}
|
||||
|
||||
// NTP config
|
||||
@@ -304,6 +305,7 @@ type RawConfig struct {
|
||||
LogLevel log.LogLevel `yaml:"log-level" json:"log-level"`
|
||||
IPv6 bool `yaml:"ipv6" json:"ipv6"`
|
||||
ExternalController string `yaml:"external-controller"`
|
||||
ExternalControllerUnix string `yaml:"external-controller-unix"`
|
||||
ExternalControllerTLS string `yaml:"external-controller-tls"`
|
||||
ExternalUI string `yaml:"external-ui"`
|
||||
ExternalUIURL string `yaml:"external-ui-url" json:"external-ui-url"`
|
||||
@@ -413,7 +415,7 @@ func UnmarshalRawConfig(buf []byte) (*RawConfig, error) {
|
||||
ProxyGroup: []map[string]any{},
|
||||
TCPConcurrent: false,
|
||||
FindProcessMode: P.FindProcessStrict,
|
||||
GlobalUA: "clash.meta",
|
||||
GlobalUA: "clash.meta/" + C.Version,
|
||||
Tun: RawTun{
|
||||
Enable: false,
|
||||
Device: "",
|
||||
@@ -678,10 +680,11 @@ func parseGeneral(cfg *RawConfig) (*General, error) {
|
||||
InboundMPTCP: cfg.InboundMPTCP,
|
||||
},
|
||||
Controller: Controller{
|
||||
ExternalController: cfg.ExternalController,
|
||||
ExternalUI: cfg.ExternalUI,
|
||||
Secret: cfg.Secret,
|
||||
ExternalControllerTLS: cfg.ExternalControllerTLS,
|
||||
ExternalController: cfg.ExternalController,
|
||||
ExternalUI: cfg.ExternalUI,
|
||||
Secret: cfg.Secret,
|
||||
ExternalControllerUnix: cfg.ExternalControllerUnix,
|
||||
ExternalControllerTLS: cfg.ExternalControllerTLS,
|
||||
},
|
||||
UnifiedDelay: cfg.UnifiedDelay,
|
||||
Mode: cfg.Mode,
|
||||
|
||||
@@ -31,6 +31,7 @@ func (v VehicleType) String() string {
|
||||
type Vehicle interface {
|
||||
Read() ([]byte, error)
|
||||
Path() string
|
||||
Proxy() string
|
||||
Type() VehicleType
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/metacubex/mihomo/component/resolver"
|
||||
"github.com/metacubex/mihomo/log"
|
||||
|
||||
D "github.com/miekg/dns"
|
||||
@@ -39,6 +40,9 @@ func (c *systemClient) getDnsClients() ([]dnsClient, error) {
|
||||
if nameservers, err = dnsReadConfig(); err == nil {
|
||||
log.Debugln("[DNS] system dns update to %s", nameservers)
|
||||
for _, addr := range nameservers {
|
||||
if resolver.IsSystemDnsBlacklisted(addr) {
|
||||
continue
|
||||
}
|
||||
if _, ok := c.dnsClients[addr]; !ok {
|
||||
clients := transform(
|
||||
[]NameServer{{
|
||||
|
||||
@@ -8,15 +8,15 @@ mixed-port: 10801 # HTTP(S) 和 SOCKS 代理混合端口
|
||||
|
||||
allow-lan: true # 允许局域网连接
|
||||
bind-address: "*" # 绑定 IP 地址,仅作用于 allow-lan 为 true,'*'表示所有地址
|
||||
authentication: # http,socks入口的验证用户名,密码
|
||||
authentication: # http,socks 入口的验证用户名,密码
|
||||
- "username:password"
|
||||
skip-auth-prefixes: # 设置跳过验证的IP段
|
||||
skip-auth-prefixes: # 设置跳过验证的 IP 段
|
||||
- 127.0.0.1/8
|
||||
- ::1/128
|
||||
lan-allowed-ips: # 允许连接的 IP 地址段,仅作用于 allow-lan 为 true, 默认值为0.0.0.0/0和::/0
|
||||
lan-allowed-ips: # 允许连接的 IP 地址段,仅作用于 allow-lan 为 true, 默认值为 0.0.0.0/0 和::/0
|
||||
- 0.0.0.0/0
|
||||
- ::/0
|
||||
lan-disallowed-ips: # 禁止连接的 IP 地址段, 黑名单优先级高于白名单, 默认值为空
|
||||
lan-disallowed-ips: # 禁止连接的 IP 地址段,黑名单优先级高于白名单,默认值为空
|
||||
- 192.168.0.3/32
|
||||
|
||||
# find-process-mode has 3 values:always, strict, off
|
||||
@@ -58,6 +58,11 @@ external-controller: 0.0.0.0:9093 # RESTful API 监听地址
|
||||
external-controller-tls: 0.0.0.0:9443 # RESTful API HTTPS 监听地址,需要配置 tls 部分配置文件
|
||||
# secret: "123456" # `Authorization:Bearer ${secret}`
|
||||
|
||||
# RESTful API Unix socket 监听地址( windows版本大于17063也可以使用,即大于等于1803/RS4版本即可使用 )
|
||||
# !!!注意: 从Unix socket访问api接口不会验证secret, 如果开启请自行保证安全问题 !!!
|
||||
# 测试方法: curl -v --unix-socket "mihomo.sock" http://localhost/
|
||||
external-controller-unix: mihomo.sock
|
||||
|
||||
# tcp-concurrent: true # TCP 并发连接所有 IP, 将使用最快握手的 TCP
|
||||
|
||||
# 配置 WEB UI 目录,使用 http://{{external-controller}}/ui 访问
|
||||
@@ -109,9 +114,9 @@ tun:
|
||||
# auto-detect-interface: true # 自动识别出口网卡
|
||||
# auto-route: true # 配置路由表
|
||||
# mtu: 9000 # 最大传输单元
|
||||
# gso: false # 启用通用分段卸载, 仅支持 Linux
|
||||
# gso: false # 启用通用分段卸载,仅支持 Linux
|
||||
# gso-max-size: 65536 # 通用分段卸载包的最大大小
|
||||
# strict-route: true # 将所有连接路由到tun来防止泄漏,但你的设备将无法其他设备被访问
|
||||
# strict-route: true # 将所有连接路由到 tun 来防止泄漏,但你的设备将无法其他设备被访问
|
||||
inet4-route-address: # 启用 auto-route 时使用自定义路由而不是默认路由
|
||||
- 0.0.0.0/1
|
||||
- 128.0.0.0/1
|
||||
@@ -119,9 +124,9 @@ tun:
|
||||
- "::/1"
|
||||
- "8000::/1"
|
||||
# endpoint-independent-nat: false # 启用独立于端点的 NAT
|
||||
# include-interface: # 限制被路由的接口。默认不限制, 与 `exclude-interface` 冲突
|
||||
# include-interface: # 限制被路由的接口。默认不限制,与 `exclude-interface` 冲突
|
||||
# - "lan0"
|
||||
# exclude-interface: # 排除路由的接口, 与 `include-interface` 冲突
|
||||
# exclude-interface: # 排除路由的接口,与 `include-interface` 冲突
|
||||
# - "lan1"
|
||||
# include-uid: # UID 规则仅在 Linux 下被支持,并且需要 auto-route
|
||||
# - 0
|
||||
@@ -143,7 +148,7 @@ tun:
|
||||
# exclude-package: # 排除被路由的 Android 应用包名
|
||||
# - com.android.captiveportallogin
|
||||
|
||||
#ebpf配置
|
||||
#ebpf 配置
|
||||
ebpf:
|
||||
auto-redir: # redirect 模式,仅支持 TCP
|
||||
- eth0
|
||||
@@ -200,7 +205,7 @@ tunnels: # one line config
|
||||
target: target.com
|
||||
proxy: proxy
|
||||
|
||||
# DNS配置
|
||||
# DNS 配置
|
||||
dns:
|
||||
cache-algorithm: arc
|
||||
enable: false # 关闭将使用系统 DNS
|
||||
@@ -208,7 +213,7 @@ dns:
|
||||
listen: 0.0.0.0:53 # 开启 DNS 服务器监听
|
||||
# ipv6: false # false 将返回 AAAA 的空结果
|
||||
# ipv6-timeout: 300 # 单位:ms,内部双栈并发时,向上游查询 AAAA 时,等待 AAAA 的时间,默认 100ms
|
||||
# 用于解析 nameserver,fallback 以及其他DNS服务器配置的,DNS 服务域名
|
||||
# 用于解析 nameserver,fallback 以及其他 DNS 服务器配置的,DNS 服务域名
|
||||
# 只能使用纯 IP 地址,可使用加密 DNS
|
||||
default-nameserver:
|
||||
- 114.114.114.114
|
||||
@@ -222,12 +227,12 @@ dns:
|
||||
|
||||
# use-hosts: true # 查询 hosts
|
||||
|
||||
# 配置不使用fake-ip的域名
|
||||
# 配置不使用 fake-ip 的域名
|
||||
# fake-ip-filter:
|
||||
# - '*.lan'
|
||||
# - localhost.ptlogin2.qq.com
|
||||
|
||||
# DNS主要域名配置
|
||||
# DNS 主要域名配置
|
||||
# 支持 UDP,TCP,DoT,DoH,DoQ
|
||||
# 这部分为主要 DNS 配置,影响所有直连,确保使用对大陆解析精准的 DNS
|
||||
nameserver:
|
||||
@@ -239,7 +244,7 @@ dns:
|
||||
- https://mozilla.cloudflare-dns.com/dns-query#DNS&h3=true # 指定策略组和使用 HTTP/3
|
||||
- dhcp://en0 # dns from dhcp
|
||||
- quic://dns.adguard.com:784 # DNS over QUIC
|
||||
# - '8.8.8.8#en0' # 兼容指定DNS出口网卡
|
||||
# - '8.8.8.8#en0' # 兼容指定 DNS 出口网卡
|
||||
|
||||
# 当配置 fallback 时,会查询 nameserver 中返回的 IP 是否为 CN,非必要配置
|
||||
# 当不是 CN,则使用 fallback 中的 DNS 查询结果
|
||||
@@ -249,7 +254,6 @@ dns:
|
||||
# - 'tcp://1.1.1.1#ProxyGroupName' # 指定 DNS 过代理查询,ProxyGroupName 为策略组名或节点名,过代理配置优先于配置出口网卡,当找不到策略组或节点名则设置为出口网卡
|
||||
|
||||
# 专用于节点域名解析的 DNS 服务器,非必要配置项
|
||||
# 配置服务器若查询失败将使用 nameserver,非并发查询
|
||||
# proxy-server-nameserver:
|
||||
# - https://dns.google/dns-query
|
||||
# - tls://one.one.one.one
|
||||
@@ -338,7 +342,7 @@ proxies: # socks5
|
||||
# udp-over-tcp: false
|
||||
# ip-version: ipv4 # 设置节点使用 IP 版本,可选:dual,ipv4,ipv6,ipv4-prefer,ipv6-prefer。默认使用 dual
|
||||
# ipv4:仅使用 IPv4 ipv6:仅使用 IPv6
|
||||
# ipv4-prefer:优先使用 IPv4 对于 TCP 会进行双栈解析,并发链接但是优先使用 IPv4 链接,
|
||||
# ipv4-prefer:优先使用 IPv4 对于 TCP 会进行双栈解析,并发链接但是优先使用 IPv4 链接,
|
||||
# UDP 则为双栈解析,获取结果中的第一个 IPv4
|
||||
# ipv6-prefer 同 ipv4-prefer
|
||||
# 现有协议都支持此参数,TCP 效果仅在开启 tcp-concurrent 生效
|
||||
@@ -350,7 +354,7 @@ proxies: # socks5
|
||||
# max-streams: 0 # Maximum multiplexed streams in a connection before opening a new connection. Conflict with max-connections and min-streams.
|
||||
# padding: false # Enable padding. Requires sing-box server version 1.3-beta9 or later.
|
||||
# statistic: false # 控制是否将底层连接显示在面板中,方便打断底层连接
|
||||
# only-tcp: false # 如果设置为true, smux的设置将不会对udp生效,udp连接会直接走底层协议
|
||||
# only-tcp: false # 如果设置为 true, smux 的设置将不会对 udp 生效,udp 连接会直接走底层协议
|
||||
|
||||
- name: "ss2"
|
||||
type: ss
|
||||
@@ -406,18 +410,18 @@ proxies: # socks5
|
||||
password: [YOUR_SS_PASSWORD]
|
||||
client-fingerprint:
|
||||
chrome # One of: chrome, ios, firefox or safari
|
||||
# 可以是chrome, ios, firefox, safari中的一个
|
||||
# 可以是 chrome, ios, firefox, safari 中的一个
|
||||
plugin: restls
|
||||
plugin-opts:
|
||||
host:
|
||||
"www.microsoft.com" # Must be a TLS 1.3 server
|
||||
# 应当是一个TLS 1.3 服务器
|
||||
# 应当是一个 TLS 1.3 服务器
|
||||
password: [YOUR_RESTLS_PASSWORD]
|
||||
version-hint: "tls13"
|
||||
# Control your post-handshake traffic through restls-script
|
||||
# Hide proxy behaviors like "tls in tls".
|
||||
# see https://github.com/3andne/restls/blob/main/Restls-Script:%20Hide%20Your%20Proxy%20Traffic%20Behavior.md
|
||||
# 用restls剧本来控制握手后的行为,隐藏"tls in tls"等特征
|
||||
# 用 restls 剧本来控制握手后的行为,隐藏"tls in tls"等特征
|
||||
# 详情:https://github.com/3andne/restls/blob/main/Restls-Script:%20%E9%9A%90%E8%97%8F%E4%BD%A0%E7%9A%84%E4%BB%A3%E7%90%86%E8%A1%8C%E4%B8%BA.md
|
||||
restls-script: "300?100<1,400~100,350~100,600~100,300~200,300~100"
|
||||
|
||||
@@ -429,18 +433,18 @@ proxies: # socks5
|
||||
password: [YOUR_SS_PASSWORD]
|
||||
client-fingerprint:
|
||||
chrome # One of: chrome, ios, firefox or safari
|
||||
# 可以是chrome, ios, firefox, safari中的一个
|
||||
# 可以是 chrome, ios, firefox, safari 中的一个
|
||||
plugin: restls
|
||||
plugin-opts:
|
||||
host:
|
||||
"vscode.dev" # Must be a TLS 1.2 server
|
||||
# 应当是一个TLS 1.2 服务器
|
||||
# 应当是一个 TLS 1.2 服务器
|
||||
password: [YOUR_RESTLS_PASSWORD]
|
||||
version-hint: "tls12"
|
||||
restls-script: "1000?100<1,500~100,350~100,600~100,400~200"
|
||||
|
||||
# vmess
|
||||
# cipher支持 auto/aes-128-gcm/chacha20-poly1305/none
|
||||
# cipher 支持 auto/aes-128-gcm/chacha20-poly1305/none
|
||||
- name: "vmess"
|
||||
type: vmess
|
||||
server: server
|
||||
@@ -680,11 +684,11 @@ proxies: # socks5
|
||||
port: 443
|
||||
# ports: 1000,2000-3000,5000 # port 不可省略
|
||||
# hop-interval: 15
|
||||
# up和down均不写或为0则使用BBR流控
|
||||
# up 和 down 均不写或为 0 则使用 BBR 流控
|
||||
# up: "30 Mbps" # 若不写单位,默认为 Mbps
|
||||
# down: "200 Mbps" # 若不写单位,默认为 Mbps
|
||||
password: yourpassword
|
||||
# obfs: salamander # 默认为空,如果填写则开启obfs,目前仅支持salamander
|
||||
# obfs: salamander # 默认为空,如果填写则开启 obfs,目前仅支持 salamander
|
||||
# obfs-password: yourpassword
|
||||
# sni: server.com
|
||||
# skip-cert-verify: false
|
||||
@@ -710,9 +714,9 @@ proxies: # socks5
|
||||
# reserved: [209,98,59]
|
||||
# 一个出站代理的标识。当值不为空时,将使用指定的 proxy 发出连接
|
||||
# dialer-proxy: "ss1"
|
||||
# remote-dns-resolve: true # 强制dns远程解析,默认值为false
|
||||
# dns: [ 1.1.1.1, 8.8.8.8 ] # 仅在remote-dns-resolve为true时生效
|
||||
# 如果peers不为空,该段落中的allowed-ips不可为空;前面段落的server,port,public-key,pre-shared-key均会被忽略,但private-key会被保留且只能在顶层指定
|
||||
# remote-dns-resolve: true # 强制 dns 远程解析,默认值为 false
|
||||
# dns: [ 1.1.1.1, 8.8.8.8 ] # 仅在 remote-dns-resolve 为 true 时生效
|
||||
# 如果 peers 不为空,该段落中的 allowed-ips 不可为空;前面段落的 server,port,public-key,pre-shared-key 均会被忽略,但 private-key 会被保留且只能在顶层指定
|
||||
# peers:
|
||||
# - server: 162.159.192.1
|
||||
# port: 2480
|
||||
@@ -726,9 +730,9 @@ proxies: # socks5
|
||||
server: www.example.com
|
||||
port: 10443
|
||||
type: tuic
|
||||
# tuicV4必须填写token (不可同时填写uuid和password)
|
||||
# tuicV4 必须填写 token(不可同时填写 uuid 和 password)
|
||||
token: TOKEN
|
||||
# tuicV5必须填写uuid和password(不可同时填写token)
|
||||
# tuicV5 必须填写 uuid 和 password(不可同时填写 token)
|
||||
uuid: 00000000-0000-0000-0000-000000000001
|
||||
password: PASSWORD_1
|
||||
# ip: 127.0.0.1 # for overwriting the DNS lookup result of the server address set in option 'server'
|
||||
@@ -746,8 +750,8 @@ proxies: # socks5
|
||||
# max-open-streams: 20 # default 100, too many open streams may hurt performance
|
||||
# sni: example.com
|
||||
#
|
||||
# meta和sing-box私有扩展,将ss-uot用于udp中继,开启此选项后udp-relay-mode将失效
|
||||
# 警告,与原版tuic不兼容!!!
|
||||
# meta 和 sing-box 私有扩展,将 ss-uot 用于 udp 中继,开启此选项后 udp-relay-mode 将失效
|
||||
# 警告,与原版 tuic 不兼容!!!
|
||||
# udp-over-stream: false
|
||||
# udp-over-stream-version: 1
|
||||
|
||||
@@ -780,12 +784,12 @@ proxies: # socks5
|
||||
password: password
|
||||
privateKey: path
|
||||
|
||||
# dns出站会将请求劫持到内部dns模块,所有请求均在内部处理
|
||||
# dns 出站会将请求劫持到内部 dns 模块,所有请求均在内部处理
|
||||
- name: "dns-out"
|
||||
type: dns
|
||||
proxy-groups:
|
||||
# 代理链,目前relay可以支持udp的只有vmess/vless/trojan/ss/ssr/tuic
|
||||
# wireguard目前不支持在relay中使用,请使用proxy中的dialer-proxy配置项
|
||||
# 代理链,目前 relay 可以支持 udp 的只有 vmess/vless/trojan/ss/ssr/tuic
|
||||
# wireguard 目前不支持在 relay 中使用,请使用 proxy 中的 dialer-proxy 配置项
|
||||
# Traffic: mihomo <-> http <-> vmess <-> ss1 <-> ss2 <-> Internet
|
||||
- name: "relay"
|
||||
type: relay
|
||||
@@ -859,10 +863,19 @@ proxy-groups:
|
||||
# Mihomo 格式的节点或支持 *ray 的分享格式
|
||||
proxy-providers:
|
||||
provider1:
|
||||
type: http # http 的 path 可空置,默认储存路径为 homedir的proxies文件夹,文件名为url的md5
|
||||
type: http # http 的 path 可空置,默认储存路径为 homedir 的 proxies 文件夹,文件名为 url 的 md5
|
||||
url: "url"
|
||||
interval: 3600
|
||||
path: ./provider1.yaml # 默认只允许存储在 mihomo 的 Home Dir,如果想存储到任意位置,添加环境变量 SKIP_SAFE_PATH_CHECK=1
|
||||
proxy: DIRECT
|
||||
header:
|
||||
User-Agent:
|
||||
- "Clash/v1.18.0"
|
||||
- "mihomo/1.18.3"
|
||||
# Accept:
|
||||
# - 'application/vnd.github.v3.raw'
|
||||
# Authorization:
|
||||
# - 'token 1231231'
|
||||
health-check:
|
||||
enable: true
|
||||
interval: 600
|
||||
@@ -892,8 +905,9 @@ rule-providers:
|
||||
behavior: classical # domain ipcidr
|
||||
interval: 259200
|
||||
path: /path/to/save/file.yaml # 默认只允许存储在 mihomo 的 Home Dir,如果想存储到任意位置,添加环境变量 SKIP_SAFE_PATH_CHECK=1
|
||||
type: http # http 的 path 可空置,默认储存路径为 homedir的rules文件夹,文件名为url的md5
|
||||
type: http # http 的 path 可空置,默认储存路径为 homedir 的 rules 文件夹,文件名为 url 的 md5
|
||||
url: "url"
|
||||
proxy: DIRECT
|
||||
rule2:
|
||||
behavior: classical
|
||||
interval: 259200
|
||||
@@ -942,7 +956,7 @@ listeners:
|
||||
port: 10808
|
||||
#listen: 0.0.0.0 # 默认监听 0.0.0.0
|
||||
# rule: sub-rule-name1 # 默认使用 rules,如果未找到 sub-rule 则直接使用 rules
|
||||
# proxy: proxy # 如果不为空则直接将该入站流量交由指定proxy处理
|
||||
# proxy: proxy # 如果不为空则直接将该入站流量交由指定 proxy 处理
|
||||
# udp: false # 默认 true
|
||||
|
||||
- name: http-in-1
|
||||
@@ -950,14 +964,14 @@ listeners:
|
||||
port: 10809
|
||||
listen: 0.0.0.0
|
||||
# rule: sub-rule-name1 # 默认使用 rules,如果未找到 sub-rule 则直接使用 rules
|
||||
# proxy: proxy # 如果不为空则直接将该入站流量交由指定proxy处理(当proxy不为空时,这里的proxy名称必须合法,否则会出错)
|
||||
# proxy: proxy # 如果不为空则直接将该入站流量交由指定 proxy 处理 (当 proxy 不为空时,这里的 proxy 名称必须合法,否则会出错)
|
||||
|
||||
- name: mixed-in-1
|
||||
type: mixed # HTTP(S) 和 SOCKS 代理混合
|
||||
port: 10810
|
||||
listen: 0.0.0.0
|
||||
# rule: sub-rule-name1 # 默认使用 rules,如果未找到 sub-rule 则直接使用 rules
|
||||
# proxy: proxy # 如果不为空则直接将该入站流量交由指定proxy处理(当proxy不为空时,这里的proxy名称必须合法,否则会出错)
|
||||
# proxy: proxy # 如果不为空则直接将该入站流量交由指定 proxy 处理 (当 proxy 不为空时,这里的 proxy 名称必须合法,否则会出错)
|
||||
# udp: false # 默认 true
|
||||
|
||||
- name: reidr-in-1
|
||||
@@ -965,14 +979,14 @@ listeners:
|
||||
port: 10811
|
||||
listen: 0.0.0.0
|
||||
# rule: sub-rule-name1 # 默认使用 rules,如果未找到 sub-rule 则直接使用 rules
|
||||
# proxy: proxy # 如果不为空则直接将该入站流量交由指定proxy处理(当proxy不为空时,这里的proxy名称必须合法,否则会出错)
|
||||
# proxy: proxy # 如果不为空则直接将该入站流量交由指定 proxy 处理 (当 proxy 不为空时,这里的 proxy 名称必须合法,否则会出错)
|
||||
|
||||
- name: tproxy-in-1
|
||||
type: tproxy
|
||||
port: 10812
|
||||
listen: 0.0.0.0
|
||||
# rule: sub-rule-name1 # 默认使用 rules,如果未找到 sub-rule 则直接使用 rules
|
||||
# proxy: proxy # 如果不为空则直接将该入站流量交由指定proxy处理(当proxy不为空时,这里的proxy名称必须合法,否则会出错)
|
||||
# proxy: proxy # 如果不为空则直接将该入站流量交由指定 proxy 处理 (当 proxy 不为空时,这里的 proxy 名称必须合法,否则会出错)
|
||||
# udp: false # 默认 true
|
||||
|
||||
- name: shadowsocks-in-1
|
||||
@@ -980,7 +994,7 @@ listeners:
|
||||
port: 10813
|
||||
listen: 0.0.0.0
|
||||
# rule: sub-rule-name1 # 默认使用 rules,如果未找到 sub-rule 则直接使用 rules
|
||||
# proxy: proxy # 如果不为空则直接将该入站流量交由指定proxy处理(当proxy不为空时,这里的proxy名称必须合法,否则会出错)
|
||||
# proxy: proxy # 如果不为空则直接将该入站流量交由指定 proxy 处理 (当 proxy 不为空时,这里的 proxy 名称必须合法,否则会出错)
|
||||
password: vlmpIPSyHH6f4S8WVPdRIHIlzmB+GIRfoH3aNJ/t9Gg=
|
||||
cipher: 2022-blake3-aes-256-gcm
|
||||
|
||||
@@ -989,13 +1003,13 @@ listeners:
|
||||
port: 10814
|
||||
listen: 0.0.0.0
|
||||
# rule: sub-rule-name1 # 默认使用 rules,如果未找到 sub-rule 则直接使用 rules
|
||||
# proxy: proxy # 如果不为空则直接将该入站流量交由指定proxy处理(当proxy不为空时,这里的proxy名称必须合法,否则会出错)
|
||||
# proxy: proxy # 如果不为空则直接将该入站流量交由指定 proxy 处理 (当 proxy 不为空时,这里的 proxy 名称必须合法,否则会出错)
|
||||
users:
|
||||
- username: 1
|
||||
uuid: 9d0cb9d0-964f-4ef6-897d-6c6b3ccf9e68
|
||||
alterId: 1
|
||||
# ws-path: "/" # 如果不为空则开启websocket传输层
|
||||
# 下面两项如果填写则开启tls(需要同时填写)
|
||||
# ws-path: "/" # 如果不为空则开启 websocket 传输层
|
||||
# 下面两项如果填写则开启 tls(需要同时填写)
|
||||
# certificate: ./server.crt
|
||||
# private-key: ./server.key
|
||||
|
||||
@@ -1004,10 +1018,10 @@ listeners:
|
||||
port: 10815
|
||||
listen: 0.0.0.0
|
||||
# rule: sub-rule-name1 # 默认使用 rules,如果未找到 sub-rule 则直接使用 rules
|
||||
# proxy: proxy # 如果不为空则直接将该入站流量交由指定proxy处理(当proxy不为空时,这里的proxy名称必须合法,否则会出错)
|
||||
# token: # tuicV4填写(可以同时填写users)
|
||||
# proxy: proxy # 如果不为空则直接将该入站流量交由指定 proxy 处理 (当 proxy 不为空时,这里的 proxy 名称必须合法,否则会出错)
|
||||
# token: # tuicV4 填写(可以同时填写 users)
|
||||
# - TOKEN
|
||||
# users: # tuicV5填写(可以同时填写token)
|
||||
# users: # tuicV5 填写(可以同时填写 token)
|
||||
# 00000000-0000-0000-0000-000000000000: PASSWORD_0
|
||||
# 00000000-0000-0000-0000-000000000001: PASSWORD_1
|
||||
# certificate: ./server.crt
|
||||
@@ -1024,25 +1038,25 @@ listeners:
|
||||
port: 10816
|
||||
listen: 0.0.0.0
|
||||
# rule: sub-rule-name1 # 默认使用 rules,如果未找到 sub-rule 则直接使用 rules
|
||||
# proxy: proxy # 如果不为空则直接将该入站流量交由指定proxy处理(当proxy不为空时,这里的proxy名称必须合法,否则会出错)
|
||||
# proxy: proxy # 如果不为空则直接将该入站流量交由指定 proxy 处理 (当 proxy 不为空时,这里的 proxy 名称必须合法,否则会出错)
|
||||
network: [tcp, udp]
|
||||
target: target.com
|
||||
|
||||
- name: tun-in-1
|
||||
type: tun
|
||||
# rule: sub-rule-name1 # 默认使用 rules,如果未找到 sub-rule 则直接使用 rules
|
||||
# proxy: proxy # 如果不为空则直接将该入站流量交由指定proxy处理(当proxy不为空时,这里的proxy名称必须合法,否则会出错)
|
||||
# proxy: proxy # 如果不为空则直接将该入站流量交由指定 proxy 处理 (当 proxy 不为空时,这里的 proxy 名称必须合法,否则会出错)
|
||||
stack: system # gvisor / mixed
|
||||
dns-hijack:
|
||||
- 0.0.0.0:53 # 需要劫持的 DNS
|
||||
# auto-detect-interface: false # 自动识别出口网卡
|
||||
# auto-route: false # 配置路由表
|
||||
# mtu: 9000 # 最大传输单元
|
||||
inet4-address: # 必须手动设置ipv4地址段
|
||||
inet4-address: # 必须手动设置 ipv4 地址段
|
||||
- 198.19.0.1/30
|
||||
inet6-address: # 必须手动设置ipv6地址段
|
||||
inet6-address: # 必须手动设置 ipv6 地址段
|
||||
- "fdfe:dcba:9877::1/126"
|
||||
# strict-route: true # 将所有连接路由到tun来防止泄漏,但你的设备将无法其他设备被访问
|
||||
# strict-route: true # 将所有连接路由到 tun 来防止泄漏,但你的设备将无法其他设备被访问
|
||||
# inet4-route-address: # 启用 auto-route 时使用自定义路由而不是默认路由
|
||||
# - 0.0.0.0/1
|
||||
# - 128.0.0.0/1
|
||||
@@ -1070,17 +1084,17 @@ listeners:
|
||||
# exclude-package: # 排除被路由的 Android 应用包名
|
||||
# - com.android.captiveportallogin
|
||||
# 入口配置与 Listener 等价,传入流量将和 socks,mixed 等入口一样按照 mode 所指定的方式进行匹配处理
|
||||
# shadowsocks,vmess 入口配置(传入流量将和socks,mixed等入口一样按照mode所指定的方式进行匹配处理)
|
||||
# shadowsocks,vmess 入口配置(传入流量将和 socks,mixed 等入口一样按照 mode 所指定的方式进行匹配处理)
|
||||
# ss-config: ss://2022-blake3-aes-256-gcm:vlmpIPSyHH6f4S8WVPdRIHIlzmB+GIRfoH3aNJ/t9Gg=@:23456
|
||||
# vmess-config: vmess://1:9d0cb9d0-964f-4ef6-897d-6c6b3ccf9e68@:12345
|
||||
|
||||
# tuic服务器入口(传入流量将和socks,mixed等入口一样按照mode所指定的方式进行匹配处理)
|
||||
# tuic 服务器入口(传入流量将和 socks,mixed 等入口一样按照 mode 所指定的方式进行匹配处理)
|
||||
# tuic-server:
|
||||
# enable: true
|
||||
# listen: 127.0.0.1:10443
|
||||
# token: # tuicV4填写(可以同时填写users)
|
||||
# token: # tuicV4 填写(可以同时填写 users)
|
||||
# - TOKEN
|
||||
# users: # tuicV5填写(可以同时填写token)
|
||||
# users: # tuicV5 填写(可以同时填写 token)
|
||||
# 00000000-0000-0000-0000-000000000000: PASSWORD_0
|
||||
# 00000000-0000-0000-0000-000000000001: PASSWORD_1
|
||||
# certificate: ./server.crt
|
||||
|
||||
@@ -20,10 +20,10 @@ require (
|
||||
github.com/mdlayher/netlink v1.7.2
|
||||
github.com/metacubex/gopacket v1.1.20-0.20230608035415-7e2f98a3e759
|
||||
github.com/metacubex/quic-go v0.42.1-0.20240319071510-a251e5c66a5c
|
||||
github.com/metacubex/sing-quic v0.0.0-20240310154810-47bca850fc01
|
||||
github.com/metacubex/sing-quic v0.0.0-20240409064816-c16ac6b1f4b4
|
||||
github.com/metacubex/sing-shadowsocks v0.2.6
|
||||
github.com/metacubex/sing-shadowsocks2 v0.2.0
|
||||
github.com/metacubex/sing-tun v0.2.1-0.20240405021556-f37a4aa3d060
|
||||
github.com/metacubex/sing-tun v0.2.6
|
||||
github.com/metacubex/sing-vmess v0.1.9-0.20231207122118-72303677451f
|
||||
github.com/metacubex/sing-wireguard v0.0.0-20240321042214-224f96122a63
|
||||
github.com/metacubex/tfo-go v0.0.0-20240228025757-be1269474a66
|
||||
@@ -34,7 +34,7 @@ require (
|
||||
github.com/puzpuzpuz/xsync/v3 v3.1.0
|
||||
github.com/sagernet/bbolt v0.0.0-20231014093535-ea5cb2fe9f0a
|
||||
github.com/sagernet/netlink v0.0.0-20220905062125-8043b4a9aa97
|
||||
github.com/sagernet/sing v0.3.6
|
||||
github.com/sagernet/sing v0.3.8
|
||||
github.com/sagernet/sing-mux v0.2.1-0.20240124034317-9bfb33698bb6
|
||||
github.com/sagernet/sing-shadowtls v0.1.4
|
||||
github.com/sagernet/utls v1.5.4
|
||||
@@ -47,11 +47,11 @@ require (
|
||||
github.com/zhangyunhao116/fastrand v0.3.0
|
||||
go.uber.org/automaxprocs v1.5.3
|
||||
go4.org/netipx v0.0.0-20231129151722-fdeea329fbba
|
||||
golang.org/x/crypto v0.21.0
|
||||
golang.org/x/crypto v0.22.0
|
||||
golang.org/x/exp v0.0.0-20240222234643-814bf88cf225
|
||||
golang.org/x/net v0.22.0
|
||||
golang.org/x/net v0.24.0
|
||||
golang.org/x/sync v0.6.0
|
||||
golang.org/x/sys v0.18.0
|
||||
golang.org/x/sys v0.19.0
|
||||
google.golang.org/protobuf v1.33.0
|
||||
gopkg.in/yaml.v3 v3.0.1
|
||||
lukechampine.com/blake3 v1.2.1
|
||||
@@ -110,4 +110,4 @@ require (
|
||||
golang.org/x/tools v0.18.0 // indirect
|
||||
)
|
||||
|
||||
replace github.com/sagernet/sing => github.com/metacubex/sing v0.0.0-20240313064558-c197257f6542
|
||||
replace github.com/sagernet/sing => github.com/metacubex/sing v0.0.0-20240408015159-aa61c96df764
|
||||
|
||||
@@ -106,16 +106,16 @@ github.com/metacubex/gvisor v0.0.0-20240320004321-933faba989ec h1:HxreOiFTUrJXJa
|
||||
github.com/metacubex/gvisor v0.0.0-20240320004321-933faba989ec/go.mod h1:8BVmQ+3cxjqzWElafm24rb2Ae4jRI6vAXNXWqWjfrXw=
|
||||
github.com/metacubex/quic-go v0.42.1-0.20240319071510-a251e5c66a5c h1:AhaPKvVqF3N/jXFmlW51Cf1+KddslKAsZqcdgGhZjr0=
|
||||
github.com/metacubex/quic-go v0.42.1-0.20240319071510-a251e5c66a5c/go.mod h1:iGx3Y1zynls/FjFgykLSqDcM81U0IKePRTXEz5g3iiQ=
|
||||
github.com/metacubex/sing v0.0.0-20240313064558-c197257f6542 h1:e9nBnrJBv3HzZVeSzJN0G2SADjebd2ZLF1F5dmsjUTc=
|
||||
github.com/metacubex/sing v0.0.0-20240313064558-c197257f6542/go.mod h1:+60H3Cm91RnL9dpVGWDPHt0zTQImO9Vfqt9a4rSambI=
|
||||
github.com/metacubex/sing-quic v0.0.0-20240310154810-47bca850fc01 h1:5INHs85Gp1JZsdF7fQp1pXUjfJOX2dhwZjuUQWJVSt8=
|
||||
github.com/metacubex/sing-quic v0.0.0-20240310154810-47bca850fc01/go.mod h1:WyY0zYxv+o+18R/Ece+QFontlgXoobKbNqbtYn2zjz8=
|
||||
github.com/metacubex/sing v0.0.0-20240408015159-aa61c96df764 h1:+czGKoynxYA90YaL3NlCAIJHnlqwoUlLWgmOhdm5ZU8=
|
||||
github.com/metacubex/sing v0.0.0-20240408015159-aa61c96df764/go.mod h1:+60H3Cm91RnL9dpVGWDPHt0zTQImO9Vfqt9a4rSambI=
|
||||
github.com/metacubex/sing-quic v0.0.0-20240409064816-c16ac6b1f4b4 h1:JB+BgUgQVicS1oGiw63c0xQWEAkUeuTylDy5WIaco7o=
|
||||
github.com/metacubex/sing-quic v0.0.0-20240409064816-c16ac6b1f4b4/go.mod h1:WyY0zYxv+o+18R/Ece+QFontlgXoobKbNqbtYn2zjz8=
|
||||
github.com/metacubex/sing-shadowsocks v0.2.6 h1:6oEB3QcsFYnNiFeoevcXrCwJ3sAablwVSgtE9R3QeFQ=
|
||||
github.com/metacubex/sing-shadowsocks v0.2.6/go.mod h1:zIkMeSnb8Mbf4hdqhw0pjzkn1d99YJ3JQm/VBg5WMTg=
|
||||
github.com/metacubex/sing-shadowsocks2 v0.2.0 h1:hqwT/AfI5d5UdPefIzR6onGHJfDXs5zgOM5QSgaM/9A=
|
||||
github.com/metacubex/sing-shadowsocks2 v0.2.0/go.mod h1:LCKF6j1P94zN8ZS+LXRK1gmYTVGB3squivBSXAFnOg8=
|
||||
github.com/metacubex/sing-tun v0.2.1-0.20240405021556-f37a4aa3d060 h1:SEkMqQlInU4KoyaISvEPKEzhDw0CnTr2TvIuj/hmEQ0=
|
||||
github.com/metacubex/sing-tun v0.2.1-0.20240405021556-f37a4aa3d060/go.mod h1:GfLZG/QgGpW9+BPjltzONrL5vVms86TWqmZ23J68ISc=
|
||||
github.com/metacubex/sing-tun v0.2.6 h1:frc58BqnIClqcC9KcYBfVAn5bgO6WW1ANKvZW3/HYAQ=
|
||||
github.com/metacubex/sing-tun v0.2.6/go.mod h1:4VsMwZH1IlgPGFK1ZbBomZ/B2MYkTgs2+gnBAr5GOIo=
|
||||
github.com/metacubex/sing-vmess v0.1.9-0.20231207122118-72303677451f h1:QjXrHKbTMBip/C+R79bvbfr42xH1gZl3uFb0RELdZiQ=
|
||||
github.com/metacubex/sing-vmess v0.1.9-0.20231207122118-72303677451f/go.mod h1:olVkD4FChQ5gKMHG4ZzuD7+fMkJY1G8vwOKpRehjrmY=
|
||||
github.com/metacubex/sing-wireguard v0.0.0-20240321042214-224f96122a63 h1:AGyIB55UfQm/0ZH0HtQO9u3l//yjtHUpjeRjjPGfGRI=
|
||||
@@ -222,8 +222,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.21.0 h1:X31++rzVUdKhX5sWmSOFZxx8UW/ldWx55cbf08iNAMA=
|
||||
golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs=
|
||||
golang.org/x/crypto v0.22.0 h1:g1v0xeRhjcugydODzvb3mEM9SQ0HGp9s/nh3COQ/C30=
|
||||
golang.org/x/crypto v0.22.0/go.mod h1:vr6Su+7cTlO45qkww3VDJlzDn0ctJvRgYbC2NvXHt+M=
|
||||
golang.org/x/exp v0.0.0-20240222234643-814bf88cf225 h1:LfspQV/FYTatPTr/3HzIcmiUFH7PGP+OQ6mgDYo3yuQ=
|
||||
golang.org/x/exp v0.0.0-20240222234643-814bf88cf225/go.mod h1:CxmFvTBINI24O/j8iY7H1xHzx2i4OsyguNBmN/uPtqc=
|
||||
golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
|
||||
@@ -232,8 +232,8 @@ golang.org/x/mod v0.15.0 h1:SernR4v+D55NyBH2QiEQrlBAnj1ECL6AGrA5+dPaMY8=
|
||||
golang.org/x/mod v0.15.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.22.0 h1:9sGLhx7iRIHEiX0oAJ3MRZMUCElJgy7Br1nO+AMN3Tc=
|
||||
golang.org/x/net v0.22.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg=
|
||||
golang.org/x/net v0.24.0 h1:1PcaxkF854Fu3+lvBIx5SYn9wRlBzzcnHZSiaFFAb0w=
|
||||
golang.org/x/net v0.24.0/go.mod h1:2Q7sJY5mzlzWjKtYUEXSlBWCdyaioyXzRB2RtU8KVE8=
|
||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.6.0 h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ=
|
||||
golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
|
||||
@@ -253,9 +253,10 @@ 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.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4=
|
||||
golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/term v0.18.0 h1:FcHjZXDMxI8mM3nwhX9HlKop4C0YQvCVCdwYl2wOtE8=
|
||||
golang.org/x/sys v0.19.0 h1:q5f1RH2jigJ1MoAWp2KTp3gm5zAGFUTarQZ5U386+4o=
|
||||
golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/term v0.19.0 h1:+ThwsDv+tYfnJFhF4L8jITxu1tdTWRTZpdsWgEgjL6Q=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
|
||||
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
|
||||
|
||||
@@ -21,6 +21,12 @@ func WithExternalController(externalController string) Option {
|
||||
}
|
||||
}
|
||||
|
||||
func WithExternalControllerUnix(externalControllerUnix string) Option {
|
||||
return func(cfg *config.Config) {
|
||||
cfg.General.ExternalControllerUnix = externalControllerUnix
|
||||
}
|
||||
}
|
||||
|
||||
func WithSecret(secret string) Option {
|
||||
return func(cfg *config.Config) {
|
||||
cfg.General.Secret = secret
|
||||
@@ -47,6 +53,10 @@ func Parse(options ...Option) error {
|
||||
cfg.General.Secret, cfg.TLS.Certificate, cfg.TLS.PrivateKey, cfg.General.LogLevel == log.DEBUG)
|
||||
}
|
||||
|
||||
if cfg.General.ExternalControllerUnix != "" {
|
||||
go route.StartUnix(cfg.General.ExternalControllerUnix, cfg.General.LogLevel == log.DEBUG)
|
||||
}
|
||||
|
||||
executor.ApplyConfig(cfg, true)
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -7,8 +7,11 @@ import (
|
||||
"encoding/json"
|
||||
"net"
|
||||
"net/http"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime/debug"
|
||||
"strings"
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
"github.com/metacubex/mihomo/adapter/inbound"
|
||||
@@ -47,15 +50,7 @@ func SetUIPath(path string) {
|
||||
uiPath = C.Path.Resolve(path)
|
||||
}
|
||||
|
||||
func Start(addr string, tlsAddr string, secret string,
|
||||
certificat, privateKey string, isDebug bool) {
|
||||
if serverAddr != "" {
|
||||
return
|
||||
}
|
||||
|
||||
serverAddr = addr
|
||||
serverSecret = secret
|
||||
|
||||
func router(isDebug bool, withAuth bool) *chi.Mux {
|
||||
r := chi.NewRouter()
|
||||
corsM := cors.New(cors.Options{
|
||||
AllowedOrigins: []string{"*"},
|
||||
@@ -77,7 +72,9 @@ func Start(addr string, tlsAddr string, secret string,
|
||||
}())
|
||||
}
|
||||
r.Group(func(r chi.Router) {
|
||||
r.Use(authentication)
|
||||
if withAuth {
|
||||
r.Use(authentication)
|
||||
}
|
||||
r.Get("/", hello)
|
||||
r.Get("/logs", getLogs)
|
||||
r.Get("/traffic", traffic)
|
||||
@@ -107,10 +104,21 @@ func Start(addr string, tlsAddr string, secret string,
|
||||
})
|
||||
})
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
||||
func Start(addr string, tlsAddr string, secret string,
|
||||
certificate, privateKey string, isDebug bool) {
|
||||
if serverAddr != "" {
|
||||
return
|
||||
}
|
||||
|
||||
serverAddr = addr
|
||||
serverSecret = secret
|
||||
|
||||
if len(tlsAddr) > 0 {
|
||||
go func() {
|
||||
c, err := CN.ParseCert(certificat, privateKey, C.Path)
|
||||
c, err := CN.ParseCert(certificate, privateKey, C.Path)
|
||||
if err != nil {
|
||||
log.Errorln("External controller tls listen error: %s", err)
|
||||
return
|
||||
@@ -125,7 +133,7 @@ func Start(addr string, tlsAddr string, secret string,
|
||||
serverAddr = l.Addr().String()
|
||||
log.Infoln("RESTful API tls listening at: %s", serverAddr)
|
||||
tlsServe := &http.Server{
|
||||
Handler: r,
|
||||
Handler: router(isDebug, true),
|
||||
TLSConfig: &tls.Config{
|
||||
Certificates: []tls.Certificate{c},
|
||||
},
|
||||
@@ -144,12 +152,45 @@ func Start(addr string, tlsAddr string, secret string,
|
||||
serverAddr = l.Addr().String()
|
||||
log.Infoln("RESTful API listening at: %s", serverAddr)
|
||||
|
||||
if err = http.Serve(l, r); err != nil {
|
||||
if err = http.Serve(l, router(isDebug, true)); err != nil {
|
||||
log.Errorln("External controller serve error: %s", err)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func StartUnix(addr string, isDebug bool) {
|
||||
addr = C.Path.Resolve(addr)
|
||||
|
||||
dir := filepath.Dir(addr)
|
||||
if _, err := os.Stat(dir); os.IsNotExist(err) {
|
||||
if err := os.MkdirAll(dir, 0o755); err != nil {
|
||||
log.Errorln("External controller unix listen error: %s", err)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// https://devblogs.microsoft.com/commandline/af_unix-comes-to-windows/
|
||||
//
|
||||
// Note: As mentioned above in the ‘security’ section, when a socket binds a socket to a valid pathname address,
|
||||
// a socket file is created within the filesystem. On Linux, the application is expected to unlink
|
||||
// (see the notes section in the man page for AF_UNIX) before any other socket can be bound to the same address.
|
||||
// The same applies to Windows unix sockets, except that, DeleteFile (or any other file delete API)
|
||||
// should be used to delete the socket file prior to calling bind with the same path.
|
||||
_ = syscall.Unlink(addr)
|
||||
|
||||
l, err := inbound.Listen("unix", addr)
|
||||
if err != nil {
|
||||
log.Errorln("External controller unix listen error: %s", err)
|
||||
return
|
||||
}
|
||||
serverAddr = l.Addr().String()
|
||||
log.Infoln("RESTful API unix listening at: %s", serverAddr)
|
||||
|
||||
if err = http.Serve(l, router(isDebug, false)); err != nil {
|
||||
log.Errorln("External controller unix serve error: %s", err)
|
||||
}
|
||||
}
|
||||
|
||||
func setPrivateNetworkAccess(next http.Handler) http.Handler {
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
if r.Method == http.MethodOptions && r.Header.Get("Access-Control-Request-Method") != "" {
|
||||
|
||||
@@ -16,7 +16,7 @@ func New(t C.Tunnel) {
|
||||
tunnel = t
|
||||
}
|
||||
|
||||
func HandleTcp(address string) (conn net.Conn, err error) {
|
||||
func HandleTcp(address string, proxy string) (conn net.Conn, err error) {
|
||||
if tunnel == nil {
|
||||
return nil, errors.New("tcp uninitialized")
|
||||
}
|
||||
@@ -28,6 +28,9 @@ func HandleTcp(address string) (conn net.Conn, err error) {
|
||||
metadata.Type = C.INNER
|
||||
metadata.DNSMode = C.DNSNormal
|
||||
metadata.Process = C.MihomoName
|
||||
if proxy != "" {
|
||||
metadata.SpecialProxy = proxy
|
||||
}
|
||||
if h, port, err := net.SplitHostPort(address); err == nil {
|
||||
if port, err := strconv.ParseUint(port, 10, 16); err == nil {
|
||||
metadata.DstPort = uint16(port)
|
||||
|
||||
@@ -12,6 +12,7 @@ import (
|
||||
"github.com/metacubex/mihomo/adapter/inbound"
|
||||
"github.com/metacubex/mihomo/component/dialer"
|
||||
"github.com/metacubex/mihomo/component/iface"
|
||||
"github.com/metacubex/mihomo/component/resolver"
|
||||
C "github.com/metacubex/mihomo/constant"
|
||||
LC "github.com/metacubex/mihomo/listener/config"
|
||||
"github.com/metacubex/mihomo/listener/sing"
|
||||
@@ -39,6 +40,8 @@ type Listener struct {
|
||||
networkUpdateMonitor tun.NetworkUpdateMonitor
|
||||
defaultInterfaceMonitor tun.DefaultInterfaceMonitor
|
||||
packageManager tun.PackageManager
|
||||
|
||||
dnsServerIp []string
|
||||
}
|
||||
|
||||
func CalculateInterfaceName(name string) (tunName string) {
|
||||
@@ -147,12 +150,16 @@ func New(options LC.Tun, tunnel C.Tunnel, additions ...inbound.Addition) (l *Lis
|
||||
|
||||
dnsAdds = append(dnsAdds, addrPort)
|
||||
}
|
||||
|
||||
var dnsServerIp []string
|
||||
for _, a := range options.Inet4Address {
|
||||
addrPort := netip.AddrPortFrom(a.Addr().Next(), 53)
|
||||
dnsServerIp = append(dnsServerIp, a.Addr().Next().String())
|
||||
dnsAdds = append(dnsAdds, addrPort)
|
||||
}
|
||||
for _, a := range options.Inet6Address {
|
||||
addrPort := netip.AddrPortFrom(a.Addr().Next(), 53)
|
||||
dnsServerIp = append(dnsServerIp, a.Addr().Next().String())
|
||||
dnsAdds = append(dnsAdds, addrPort)
|
||||
}
|
||||
|
||||
@@ -244,6 +251,10 @@ func New(options LC.Tun, tunnel C.Tunnel, additions ...inbound.Addition) (l *Lis
|
||||
return
|
||||
}
|
||||
|
||||
l.dnsServerIp = dnsServerIp
|
||||
// after tun.New sing-tun has set DNS to TUN interface
|
||||
resolver.AddSystemDnsBlacklist(dnsServerIp...)
|
||||
|
||||
stackOptions := tun.StackOptions{
|
||||
Context: context.TODO(),
|
||||
Tun: tunIf,
|
||||
@@ -336,6 +347,7 @@ func parseRange(uidRanges []ranges.Range[uint32], rangeList []string) ([]ranges.
|
||||
|
||||
func (l *Listener) Close() error {
|
||||
l.closed = true
|
||||
resolver.RemoveSystemDnsBlacklist(l.dnsServerIp...)
|
||||
return common.Close(
|
||||
l.tunStack,
|
||||
l.tunIf,
|
||||
|
||||
@@ -23,16 +23,17 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
version bool
|
||||
testConfig bool
|
||||
geodataMode bool
|
||||
homeDir string
|
||||
configFile string
|
||||
externalUI string
|
||||
externalController string
|
||||
secret string
|
||||
updateGeoMux sync.Mutex
|
||||
updatingGeo = false
|
||||
version bool
|
||||
testConfig bool
|
||||
geodataMode bool
|
||||
homeDir string
|
||||
configFile string
|
||||
externalUI string
|
||||
externalController string
|
||||
externalControllerUnix string
|
||||
secret string
|
||||
updateGeoMux sync.Mutex
|
||||
updatingGeo = false
|
||||
)
|
||||
|
||||
func init() {
|
||||
@@ -40,6 +41,7 @@ func init() {
|
||||
flag.StringVar(&configFile, "f", os.Getenv("CLASH_CONFIG_FILE"), "specify configuration file")
|
||||
flag.StringVar(&externalUI, "ext-ui", os.Getenv("CLASH_OVERRIDE_EXTERNAL_UI_DIR"), "override external ui directory")
|
||||
flag.StringVar(&externalController, "ext-ctl", os.Getenv("CLASH_OVERRIDE_EXTERNAL_CONTROLLER"), "override external controller address")
|
||||
flag.StringVar(&externalControllerUnix, "ext-ctl-unix", os.Getenv("CLASH_OVERRIDE_EXTERNAL_CONTROLLER_UNIX"), "override external controller unix address")
|
||||
flag.StringVar(&secret, "secret", os.Getenv("CLASH_OVERRIDE_SECRET"), "override secret for RESTful API")
|
||||
flag.BoolVar(&geodataMode, "m", false, "set geodata mode")
|
||||
flag.BoolVar(&version, "v", false, "show current version of mihomo")
|
||||
@@ -102,6 +104,9 @@ func main() {
|
||||
if externalController != "" {
|
||||
options = append(options, hub.WithExternalController(externalController))
|
||||
}
|
||||
if externalControllerUnix != "" {
|
||||
options = append(options, hub.WithExternalControllerUnix(externalControllerUnix))
|
||||
}
|
||||
if secret != "" {
|
||||
options = append(options, hub.WithSecret(secret))
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ type ruleProviderSchema struct {
|
||||
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"`
|
||||
}
|
||||
@@ -61,17 +62,14 @@ func ParseRuleProvider(name string, mapping map[string]interface{}, parse func(t
|
||||
path := C.Path.Resolve(schema.Path)
|
||||
vehicle = resource.NewFileVehicle(path)
|
||||
case "http":
|
||||
path := C.Path.GetPathByHash("rules", schema.URL)
|
||||
if schema.Path != "" {
|
||||
path := C.Path.Resolve(schema.Path)
|
||||
path = C.Path.Resolve(schema.Path)
|
||||
if !features.CMFA && !C.Path.IsSafePath(path) {
|
||||
return nil, fmt.Errorf("%w: %s", errSubPath, path)
|
||||
}
|
||||
vehicle = resource.NewHTTPVehicle(schema.URL, path)
|
||||
} else {
|
||||
path := C.Path.GetPathByHash("rules", schema.URL)
|
||||
vehicle = resource.NewHTTPVehicle(schema.URL, path)
|
||||
}
|
||||
|
||||
vehicle = resource.NewHTTPVehicle(schema.URL, path, schema.Proxy, nil)
|
||||
default:
|
||||
return nil, fmt.Errorf("unsupported vehicle type: %s", schema.Type)
|
||||
}
|
||||
|
||||
@@ -48,10 +48,10 @@ require (
|
||||
github.com/metacubex/gvisor v0.0.0-20240320004321-933faba989ec // indirect
|
||||
github.com/metacubex/mihomo v1.7.0 // indirect
|
||||
github.com/metacubex/quic-go v0.42.1-0.20240319071510-a251e5c66a5c // indirect
|
||||
github.com/metacubex/sing-quic v0.0.0-20240310154810-47bca850fc01 // indirect
|
||||
github.com/metacubex/sing-quic v0.0.0-20240409064816-c16ac6b1f4b4 // indirect
|
||||
github.com/metacubex/sing-shadowsocks v0.2.6 // indirect
|
||||
github.com/metacubex/sing-shadowsocks2 v0.2.0 // indirect
|
||||
github.com/metacubex/sing-tun v0.2.1-0.20240405021556-f37a4aa3d060 // indirect
|
||||
github.com/metacubex/sing-tun v0.2.6 // indirect
|
||||
github.com/metacubex/sing-vmess v0.1.9-0.20231207122118-72303677451f // indirect
|
||||
github.com/metacubex/sing-wireguard v0.0.0-20240321042214-224f96122a63 // indirect
|
||||
github.com/metacubex/tfo-go v0.0.0-20240228025757-be1269474a66 // indirect
|
||||
@@ -68,7 +68,7 @@ require (
|
||||
github.com/quic-go/qtls-go1-20 v0.4.1 // indirect
|
||||
github.com/sagernet/bbolt v0.0.0-20231014093535-ea5cb2fe9f0a // indirect
|
||||
github.com/sagernet/netlink v0.0.0-20220905062125-8043b4a9aa97 // indirect
|
||||
github.com/sagernet/sing v0.3.6 // indirect
|
||||
github.com/sagernet/sing v0.3.8 // indirect
|
||||
github.com/sagernet/sing-mux v0.2.1-0.20240124034317-9bfb33698bb6 // indirect
|
||||
github.com/sagernet/sing-shadowtls v0.1.4 // indirect
|
||||
github.com/sagernet/smux v0.0.0-20231208180855-7041f6ea79e7 // indirect
|
||||
@@ -91,12 +91,12 @@ require (
|
||||
gitlab.com/yawning/bsaes.git v0.0.0-20190805113838-0a714cd429ec // indirect
|
||||
go.uber.org/mock v0.4.0 // indirect
|
||||
go4.org/netipx v0.0.0-20231129151722-fdeea329fbba // indirect
|
||||
golang.org/x/crypto v0.21.0 // indirect
|
||||
golang.org/x/crypto v0.22.0 // indirect
|
||||
golang.org/x/exp v0.0.0-20240222234643-814bf88cf225 // indirect
|
||||
golang.org/x/mod v0.15.0 // indirect
|
||||
golang.org/x/net v0.22.0 // indirect
|
||||
golang.org/x/net v0.24.0 // indirect
|
||||
golang.org/x/sync v0.6.0 // indirect
|
||||
golang.org/x/sys v0.18.0 // indirect
|
||||
golang.org/x/sys v0.19.0 // indirect
|
||||
golang.org/x/text v0.14.0 // indirect
|
||||
golang.org/x/time v0.5.0 // indirect
|
||||
golang.org/x/tools v0.18.0 // indirect
|
||||
|
||||
@@ -102,14 +102,14 @@ github.com/metacubex/quic-go v0.42.1-0.20240319071510-a251e5c66a5c h1:AhaPKvVqF3
|
||||
github.com/metacubex/quic-go v0.42.1-0.20240319071510-a251e5c66a5c/go.mod h1:iGx3Y1zynls/FjFgykLSqDcM81U0IKePRTXEz5g3iiQ=
|
||||
github.com/metacubex/sing v0.0.0-20240111014253-f1818b6a82b2 h1:upEO8dt9WDBavhgcgkXB3hRcwVNbkTbnd+xyzy6ZQZo=
|
||||
github.com/metacubex/sing v0.0.0-20240111014253-f1818b6a82b2/go.mod h1:9pfuAH6mZfgnz/YjP6xu5sxx882rfyjpcrTdUpd6w3g=
|
||||
github.com/metacubex/sing-quic v0.0.0-20240310154810-47bca850fc01 h1:5INHs85Gp1JZsdF7fQp1pXUjfJOX2dhwZjuUQWJVSt8=
|
||||
github.com/metacubex/sing-quic v0.0.0-20240310154810-47bca850fc01/go.mod h1:WyY0zYxv+o+18R/Ece+QFontlgXoobKbNqbtYn2zjz8=
|
||||
github.com/metacubex/sing-quic v0.0.0-20240409064816-c16ac6b1f4b4 h1:JB+BgUgQVicS1oGiw63c0xQWEAkUeuTylDy5WIaco7o=
|
||||
github.com/metacubex/sing-quic v0.0.0-20240409064816-c16ac6b1f4b4/go.mod h1:WyY0zYxv+o+18R/Ece+QFontlgXoobKbNqbtYn2zjz8=
|
||||
github.com/metacubex/sing-shadowsocks v0.2.6 h1:6oEB3QcsFYnNiFeoevcXrCwJ3sAablwVSgtE9R3QeFQ=
|
||||
github.com/metacubex/sing-shadowsocks v0.2.6/go.mod h1:zIkMeSnb8Mbf4hdqhw0pjzkn1d99YJ3JQm/VBg5WMTg=
|
||||
github.com/metacubex/sing-shadowsocks2 v0.2.0 h1:hqwT/AfI5d5UdPefIzR6onGHJfDXs5zgOM5QSgaM/9A=
|
||||
github.com/metacubex/sing-shadowsocks2 v0.2.0/go.mod h1:LCKF6j1P94zN8ZS+LXRK1gmYTVGB3squivBSXAFnOg8=
|
||||
github.com/metacubex/sing-tun v0.2.1-0.20240405021556-f37a4aa3d060 h1:SEkMqQlInU4KoyaISvEPKEzhDw0CnTr2TvIuj/hmEQ0=
|
||||
github.com/metacubex/sing-tun v0.2.1-0.20240405021556-f37a4aa3d060/go.mod h1:GfLZG/QgGpW9+BPjltzONrL5vVms86TWqmZ23J68ISc=
|
||||
github.com/metacubex/sing-tun v0.2.6 h1:frc58BqnIClqcC9KcYBfVAn5bgO6WW1ANKvZW3/HYAQ=
|
||||
github.com/metacubex/sing-tun v0.2.6/go.mod h1:4VsMwZH1IlgPGFK1ZbBomZ/B2MYkTgs2+gnBAr5GOIo=
|
||||
github.com/metacubex/sing-vmess v0.1.9-0.20231207122118-72303677451f h1:QjXrHKbTMBip/C+R79bvbfr42xH1gZl3uFb0RELdZiQ=
|
||||
github.com/metacubex/sing-vmess v0.1.9-0.20231207122118-72303677451f/go.mod h1:olVkD4FChQ5gKMHG4ZzuD7+fMkJY1G8vwOKpRehjrmY=
|
||||
github.com/metacubex/sing-wireguard v0.0.0-20240321042214-224f96122a63 h1:AGyIB55UfQm/0ZH0HtQO9u3l//yjtHUpjeRjjPGfGRI=
|
||||
@@ -211,8 +211,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.21.0 h1:X31++rzVUdKhX5sWmSOFZxx8UW/ldWx55cbf08iNAMA=
|
||||
golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs=
|
||||
golang.org/x/crypto v0.22.0 h1:g1v0xeRhjcugydODzvb3mEM9SQ0HGp9s/nh3COQ/C30=
|
||||
golang.org/x/crypto v0.22.0/go.mod h1:vr6Su+7cTlO45qkww3VDJlzDn0ctJvRgYbC2NvXHt+M=
|
||||
golang.org/x/exp v0.0.0-20240222234643-814bf88cf225 h1:LfspQV/FYTatPTr/3HzIcmiUFH7PGP+OQ6mgDYo3yuQ=
|
||||
golang.org/x/exp v0.0.0-20240222234643-814bf88cf225/go.mod h1:CxmFvTBINI24O/j8iY7H1xHzx2i4OsyguNBmN/uPtqc=
|
||||
golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
|
||||
@@ -221,8 +221,8 @@ golang.org/x/mod v0.15.0 h1:SernR4v+D55NyBH2QiEQrlBAnj1ECL6AGrA5+dPaMY8=
|
||||
golang.org/x/mod v0.15.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.22.0 h1:9sGLhx7iRIHEiX0oAJ3MRZMUCElJgy7Br1nO+AMN3Tc=
|
||||
golang.org/x/net v0.22.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg=
|
||||
golang.org/x/net v0.24.0 h1:1PcaxkF854Fu3+lvBIx5SYn9wRlBzzcnHZSiaFFAb0w=
|
||||
golang.org/x/net v0.24.0/go.mod h1:2Q7sJY5mzlzWjKtYUEXSlBWCdyaioyXzRB2RtU8KVE8=
|
||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.6.0 h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ=
|
||||
golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
|
||||
@@ -243,9 +243,9 @@ 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.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4=
|
||||
golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/term v0.18.0 h1:FcHjZXDMxI8mM3nwhX9HlKop4C0YQvCVCdwYl2wOtE8=
|
||||
golang.org/x/sys v0.19.0 h1:q5f1RH2jigJ1MoAWp2KTp3gm5zAGFUTarQZ5U386+4o=
|
||||
golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/term v0.19.0 h1:+ThwsDv+tYfnJFhF4L8jITxu1tdTWRTZpdsWgEgjL6Q=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
|
||||
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
|
||||
|
||||
@@ -55,10 +55,10 @@ require (
|
||||
github.com/metacubex/gopacket v1.1.20-0.20230608035415-7e2f98a3e759 // indirect
|
||||
github.com/metacubex/gvisor v0.0.0-20240320004321-933faba989ec // indirect
|
||||
github.com/metacubex/quic-go v0.42.1-0.20240319071510-a251e5c66a5c // indirect
|
||||
github.com/metacubex/sing-quic v0.0.0-20240310154810-47bca850fc01 // indirect
|
||||
github.com/metacubex/sing-quic v0.0.0-20240409064816-c16ac6b1f4b4 // indirect
|
||||
github.com/metacubex/sing-shadowsocks v0.2.6 // indirect
|
||||
github.com/metacubex/sing-shadowsocks2 v0.2.0 // indirect
|
||||
github.com/metacubex/sing-tun v0.2.1-0.20240405021556-f37a4aa3d060 // indirect
|
||||
github.com/metacubex/sing-tun v0.2.6 // indirect
|
||||
github.com/metacubex/sing-vmess v0.1.9-0.20231207122118-72303677451f // indirect
|
||||
github.com/metacubex/sing-wireguard v0.0.0-20240321042214-224f96122a63 // indirect
|
||||
github.com/metacubex/tfo-go v0.0.0-20240228025757-be1269474a66 // indirect
|
||||
@@ -73,7 +73,7 @@ require (
|
||||
github.com/quic-go/qtls-go1-20 v0.4.1 // indirect
|
||||
github.com/sagernet/bbolt v0.0.0-20231014093535-ea5cb2fe9f0a // indirect
|
||||
github.com/sagernet/netlink v0.0.0-20220905062125-8043b4a9aa97 // indirect
|
||||
github.com/sagernet/sing v0.3.6 // indirect
|
||||
github.com/sagernet/sing v0.3.8 // indirect
|
||||
github.com/sagernet/sing-mux v0.2.1-0.20240124034317-9bfb33698bb6 // indirect
|
||||
github.com/sagernet/sing-shadowtls v0.1.4 // indirect
|
||||
github.com/sagernet/smux v0.0.0-20231208180855-7041f6ea79e7 // indirect
|
||||
@@ -96,11 +96,11 @@ require (
|
||||
gitlab.com/yawning/bsaes.git v0.0.0-20190805113838-0a714cd429ec // indirect
|
||||
go.uber.org/mock v0.4.0 // indirect
|
||||
go4.org/netipx v0.0.0-20231129151722-fdeea329fbba // indirect
|
||||
golang.org/x/crypto v0.21.0 // indirect
|
||||
golang.org/x/crypto v0.22.0 // indirect
|
||||
golang.org/x/exp v0.0.0-20240222234643-814bf88cf225 // indirect
|
||||
golang.org/x/mod v0.15.0 // indirect
|
||||
golang.org/x/net v0.22.0 // indirect
|
||||
golang.org/x/sys v0.18.0 // indirect
|
||||
golang.org/x/net v0.24.0 // indirect
|
||||
golang.org/x/sys v0.19.0 // indirect
|
||||
golang.org/x/text v0.14.0 // indirect
|
||||
golang.org/x/time v0.5.0 // indirect
|
||||
golang.org/x/tools v0.18.0 // indirect
|
||||
|
||||
@@ -102,14 +102,14 @@ github.com/metacubex/quic-go v0.42.1-0.20240319071510-a251e5c66a5c h1:AhaPKvVqF3
|
||||
github.com/metacubex/quic-go v0.42.1-0.20240319071510-a251e5c66a5c/go.mod h1:iGx3Y1zynls/FjFgykLSqDcM81U0IKePRTXEz5g3iiQ=
|
||||
github.com/metacubex/sing v0.0.0-20240111014253-f1818b6a82b2 h1:upEO8dt9WDBavhgcgkXB3hRcwVNbkTbnd+xyzy6ZQZo=
|
||||
github.com/metacubex/sing v0.0.0-20240111014253-f1818b6a82b2/go.mod h1:9pfuAH6mZfgnz/YjP6xu5sxx882rfyjpcrTdUpd6w3g=
|
||||
github.com/metacubex/sing-quic v0.0.0-20240310154810-47bca850fc01 h1:5INHs85Gp1JZsdF7fQp1pXUjfJOX2dhwZjuUQWJVSt8=
|
||||
github.com/metacubex/sing-quic v0.0.0-20240310154810-47bca850fc01/go.mod h1:WyY0zYxv+o+18R/Ece+QFontlgXoobKbNqbtYn2zjz8=
|
||||
github.com/metacubex/sing-quic v0.0.0-20240409064816-c16ac6b1f4b4 h1:JB+BgUgQVicS1oGiw63c0xQWEAkUeuTylDy5WIaco7o=
|
||||
github.com/metacubex/sing-quic v0.0.0-20240409064816-c16ac6b1f4b4/go.mod h1:WyY0zYxv+o+18R/Ece+QFontlgXoobKbNqbtYn2zjz8=
|
||||
github.com/metacubex/sing-shadowsocks v0.2.6 h1:6oEB3QcsFYnNiFeoevcXrCwJ3sAablwVSgtE9R3QeFQ=
|
||||
github.com/metacubex/sing-shadowsocks v0.2.6/go.mod h1:zIkMeSnb8Mbf4hdqhw0pjzkn1d99YJ3JQm/VBg5WMTg=
|
||||
github.com/metacubex/sing-shadowsocks2 v0.2.0 h1:hqwT/AfI5d5UdPefIzR6onGHJfDXs5zgOM5QSgaM/9A=
|
||||
github.com/metacubex/sing-shadowsocks2 v0.2.0/go.mod h1:LCKF6j1P94zN8ZS+LXRK1gmYTVGB3squivBSXAFnOg8=
|
||||
github.com/metacubex/sing-tun v0.2.1-0.20240405021556-f37a4aa3d060 h1:SEkMqQlInU4KoyaISvEPKEzhDw0CnTr2TvIuj/hmEQ0=
|
||||
github.com/metacubex/sing-tun v0.2.1-0.20240405021556-f37a4aa3d060/go.mod h1:GfLZG/QgGpW9+BPjltzONrL5vVms86TWqmZ23J68ISc=
|
||||
github.com/metacubex/sing-tun v0.2.6 h1:frc58BqnIClqcC9KcYBfVAn5bgO6WW1ANKvZW3/HYAQ=
|
||||
github.com/metacubex/sing-tun v0.2.6/go.mod h1:4VsMwZH1IlgPGFK1ZbBomZ/B2MYkTgs2+gnBAr5GOIo=
|
||||
github.com/metacubex/sing-vmess v0.1.9-0.20231207122118-72303677451f h1:QjXrHKbTMBip/C+R79bvbfr42xH1gZl3uFb0RELdZiQ=
|
||||
github.com/metacubex/sing-vmess v0.1.9-0.20231207122118-72303677451f/go.mod h1:olVkD4FChQ5gKMHG4ZzuD7+fMkJY1G8vwOKpRehjrmY=
|
||||
github.com/metacubex/sing-wireguard v0.0.0-20240321042214-224f96122a63 h1:AGyIB55UfQm/0ZH0HtQO9u3l//yjtHUpjeRjjPGfGRI=
|
||||
@@ -211,8 +211,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.21.0 h1:X31++rzVUdKhX5sWmSOFZxx8UW/ldWx55cbf08iNAMA=
|
||||
golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs=
|
||||
golang.org/x/crypto v0.22.0 h1:g1v0xeRhjcugydODzvb3mEM9SQ0HGp9s/nh3COQ/C30=
|
||||
golang.org/x/crypto v0.22.0/go.mod h1:vr6Su+7cTlO45qkww3VDJlzDn0ctJvRgYbC2NvXHt+M=
|
||||
golang.org/x/exp v0.0.0-20240222234643-814bf88cf225 h1:LfspQV/FYTatPTr/3HzIcmiUFH7PGP+OQ6mgDYo3yuQ=
|
||||
golang.org/x/exp v0.0.0-20240222234643-814bf88cf225/go.mod h1:CxmFvTBINI24O/j8iY7H1xHzx2i4OsyguNBmN/uPtqc=
|
||||
golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
|
||||
@@ -221,8 +221,8 @@ golang.org/x/mod v0.15.0 h1:SernR4v+D55NyBH2QiEQrlBAnj1ECL6AGrA5+dPaMY8=
|
||||
golang.org/x/mod v0.15.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.22.0 h1:9sGLhx7iRIHEiX0oAJ3MRZMUCElJgy7Br1nO+AMN3Tc=
|
||||
golang.org/x/net v0.22.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg=
|
||||
golang.org/x/net v0.24.0 h1:1PcaxkF854Fu3+lvBIx5SYn9wRlBzzcnHZSiaFFAb0w=
|
||||
golang.org/x/net v0.24.0/go.mod h1:2Q7sJY5mzlzWjKtYUEXSlBWCdyaioyXzRB2RtU8KVE8=
|
||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.6.0 h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ=
|
||||
golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
|
||||
@@ -243,9 +243,9 @@ 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.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4=
|
||||
golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/term v0.18.0 h1:FcHjZXDMxI8mM3nwhX9HlKop4C0YQvCVCdwYl2wOtE8=
|
||||
golang.org/x/sys v0.19.0 h1:q5f1RH2jigJ1MoAWp2KTp3gm5zAGFUTarQZ5U386+4o=
|
||||
golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/term v0.19.0 h1:+ThwsDv+tYfnJFhF4L8jITxu1tdTWRTZpdsWgEgjL6Q=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
|
||||
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
|
||||
|
||||
@@ -159,6 +159,8 @@ func Start(addr string, tlsAddr string, secret string,
|
||||
}
|
||||
|
||||
func StartUnix(addr string, isDebug bool) {
|
||||
addr = C.Path.Resolve(addr)
|
||||
|
||||
dir := filepath.Dir(addr)
|
||||
if _, err := os.Stat(dir); os.IsNotExist(err) {
|
||||
if err := os.MkdirAll(dir, 0o755); err != nil {
|
||||
|
||||
Generated
+2
-2
@@ -5516,9 +5516,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "sysinfo"
|
||||
version = "0.30.10"
|
||||
version = "0.30.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "26d7c217777061d5a2d652aea771fb9ba98b6dade657204b08c4b9604d11555b"
|
||||
checksum = "87341a165d73787554941cd5ef55ad728011566fe714e987d1b976c15dbc3a83"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"core-foundation-sys",
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
import useSWR from "swr";
|
||||
import { Clash, clash } from "../service/clash";
|
||||
import {
|
||||
getClashInfo as getClashInfoFromTauri,
|
||||
patchClashInfo,
|
||||
} from "@/service/tauri";
|
||||
import { ClashConfig } from "..";
|
||||
|
||||
/**
|
||||
* useClash with swr.
|
||||
@@ -8,6 +13,18 @@ import { Clash, clash } from "../service/clash";
|
||||
export const useClash = () => {
|
||||
const { deleteConnections, ...api } = clash();
|
||||
|
||||
const getClashInfo = useSWR("getClashInfo", getClashInfoFromTauri);
|
||||
|
||||
const setClashInfo = async (payload: Partial<ClashConfig>) => {
|
||||
try {
|
||||
await patchClashInfo(payload);
|
||||
|
||||
await getClashInfo.mutate();
|
||||
} finally {
|
||||
return getClashInfo.data;
|
||||
}
|
||||
};
|
||||
|
||||
const getConfigs = useSWR("getClashConfig", api.getConfigs);
|
||||
|
||||
const setConfigs = async (payload: Partial<Clash.Config>) => {
|
||||
@@ -39,6 +56,8 @@ export const useClash = () => {
|
||||
};
|
||||
|
||||
return {
|
||||
getClashInfo,
|
||||
setClashInfo,
|
||||
getConfigs,
|
||||
setConfigs,
|
||||
getVersion,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { invoke } from "@tauri-apps/api/tauri";
|
||||
import { ClashInfo, VergeConfig } from "./types";
|
||||
import { ClashConfig, ClashInfo, VergeConfig } from "./types";
|
||||
|
||||
export const getNyanpasuConfig = async () => {
|
||||
return await invoke<VergeConfig>("get_verge_config");
|
||||
@@ -12,3 +12,7 @@ export const patchNyanpasuConfig = async (payload: VergeConfig) => {
|
||||
export const getClashInfo = async () => {
|
||||
return await invoke<ClashInfo | null>("get_clash_info");
|
||||
};
|
||||
|
||||
export const patchClashInfo = async (payload: Partial<ClashConfig>) => {
|
||||
return await invoke<void>("patch_clash_config", { payload });
|
||||
};
|
||||
|
||||
@@ -50,3 +50,17 @@ export interface ClashInfo {
|
||||
server?: string;
|
||||
secret?: string;
|
||||
}
|
||||
export interface ClashConfig {
|
||||
port: number;
|
||||
mode: string;
|
||||
ipv6: boolean;
|
||||
"socket-port": number;
|
||||
"allow-lan": boolean;
|
||||
"log-level": string;
|
||||
"mixed-port": number;
|
||||
"redir-port": number;
|
||||
"socks-port": number;
|
||||
"tproxy-port": number;
|
||||
"external-controller": string;
|
||||
secret: string;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
import { List } from "@mui/material";
|
||||
import { BaseCard, MenuItem, SwitchItem } from "@nyanpasu/ui";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { createBooleanProps, createMenuProps } from "./modules";
|
||||
|
||||
export const SettingClashBase = () => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
return (
|
||||
<BaseCard label={t("Clash Setting")}>
|
||||
<List disablePadding>
|
||||
<SwitchItem
|
||||
label={t("Allow Lan")}
|
||||
{...createBooleanProps("allow-lan")}
|
||||
/>
|
||||
|
||||
<SwitchItem label={t("IPv6")} {...createBooleanProps("ipv6")} />
|
||||
|
||||
<MenuItem
|
||||
label={t("Log Level")}
|
||||
{...createMenuProps("log-level", {
|
||||
options: {
|
||||
debug: "Debug",
|
||||
info: "Info",
|
||||
warning: "Warn",
|
||||
error: "Error",
|
||||
silent: "Silent",
|
||||
},
|
||||
fallbackSelect: "debug",
|
||||
})}
|
||||
/>
|
||||
</List>
|
||||
</BaseCard>
|
||||
);
|
||||
};
|
||||
|
||||
export default SettingClashBase;
|
||||
@@ -0,0 +1,158 @@
|
||||
import { useMessage } from "@/hooks/use-notification";
|
||||
import Done from "@mui/icons-material/Done";
|
||||
import LoadingButton from "@mui/lab/LoadingButton";
|
||||
import {
|
||||
Box,
|
||||
List,
|
||||
ListItem,
|
||||
ListItemText,
|
||||
TextField,
|
||||
TextFieldProps,
|
||||
} from "@mui/material";
|
||||
import { useClash, useNyanpasu } from "@nyanpasu/interface";
|
||||
import { BaseCard, Expand, MenuItem } from "@nyanpasu/ui";
|
||||
import { ChangeEvent, useEffect, useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
type PortStrategy = "fixed" | "random" | "allow_fallback";
|
||||
|
||||
const portStrategyOptions = {
|
||||
allow_fallback: "Allow Fallback",
|
||||
fixed: "Fixed",
|
||||
random: "Random",
|
||||
};
|
||||
|
||||
const textFieldProps: TextFieldProps = {
|
||||
size: "small",
|
||||
variant: "outlined",
|
||||
sx: { width: 160 },
|
||||
inputProps: {
|
||||
"aria-autocomplete": "none",
|
||||
},
|
||||
};
|
||||
|
||||
export const SettingClashExternal = () => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const { nyanpasuConfig, setNyanpasuConfig } = useNyanpasu();
|
||||
|
||||
const { getClashInfo, setClashInfo } = useClash();
|
||||
|
||||
// What even are these fields?????
|
||||
// I had to write the shit code to make it run like a pile of crap.
|
||||
const [config, setConfig] = useState({
|
||||
portStrategy:
|
||||
nyanpasuConfig?.clash_strategy?.external_controller_port_strategy ||
|
||||
"allow_fallback",
|
||||
controller: getClashInfo.data?.server || "",
|
||||
secret: getClashInfo.data?.secret || "",
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
setConfig({
|
||||
portStrategy:
|
||||
nyanpasuConfig?.clash_strategy?.external_controller_port_strategy ||
|
||||
"allow_fallback",
|
||||
controller: getClashInfo.data?.server || "",
|
||||
secret: getClashInfo.data?.secret || "",
|
||||
});
|
||||
}, [nyanpasuConfig, getClashInfo.data]);
|
||||
|
||||
const [expand, setExpand] = useState(false);
|
||||
|
||||
const [loading, setLoading] = useState(false);
|
||||
|
||||
const apply = async () => {
|
||||
setLoading(true);
|
||||
|
||||
try {
|
||||
await Promise.all([
|
||||
setNyanpasuConfig({
|
||||
clash_strategy: {
|
||||
external_controller_port_strategy: config.portStrategy,
|
||||
},
|
||||
}),
|
||||
|
||||
setClashInfo({
|
||||
"external-controller": config.controller,
|
||||
secret: config.secret,
|
||||
}),
|
||||
]);
|
||||
} catch (e) {
|
||||
useMessage(JSON.stringify(e), {
|
||||
title: t("Error"),
|
||||
type: "error",
|
||||
});
|
||||
} finally {
|
||||
setExpand(false);
|
||||
|
||||
setTimeout(() => {
|
||||
setLoading(false);
|
||||
}, 300);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<BaseCard label={t("Clash External Controll")}>
|
||||
<List disablePadding>
|
||||
<ListItem sx={{ pl: 0, pr: 0 }}>
|
||||
<ListItemText primary="External Controller" />
|
||||
|
||||
<TextField
|
||||
value={config.controller}
|
||||
onChange={(e: ChangeEvent<HTMLInputElement>) => {
|
||||
setConfig((v) => ({ ...v, controller: e.target.value }));
|
||||
setExpand(true);
|
||||
}}
|
||||
{...textFieldProps}
|
||||
disabled={loading}
|
||||
/>
|
||||
</ListItem>
|
||||
|
||||
<MenuItem
|
||||
label="Port Strategy"
|
||||
options={portStrategyOptions}
|
||||
selected={config.portStrategy}
|
||||
onSelected={(value) => {
|
||||
setConfig((v) => ({
|
||||
...v,
|
||||
portStrategy: value as PortStrategy,
|
||||
}));
|
||||
setExpand(true);
|
||||
}}
|
||||
selectSx={{ width: 160 }}
|
||||
disabled={loading}
|
||||
/>
|
||||
|
||||
<ListItem sx={{ pl: 0, pr: 0 }}>
|
||||
<ListItemText primary="Core Secret" />
|
||||
|
||||
<TextField
|
||||
value={config.secret}
|
||||
disabled={loading}
|
||||
onChange={(e: ChangeEvent<HTMLInputElement>) => {
|
||||
setConfig((v) => ({ ...v, secret: e.target.value }));
|
||||
setExpand(true);
|
||||
}}
|
||||
{...textFieldProps}
|
||||
/>
|
||||
</ListItem>
|
||||
|
||||
<Expand open={expand}>
|
||||
<Box display="flex" justifyContent="end" alignItems="center" gap={8}>
|
||||
<LoadingButton
|
||||
loading={loading}
|
||||
variant="contained"
|
||||
startIcon={<Done />}
|
||||
onClick={apply}
|
||||
>
|
||||
Apply
|
||||
</LoadingButton>
|
||||
</Box>
|
||||
</Expand>
|
||||
</List>
|
||||
</BaseCard>
|
||||
);
|
||||
};
|
||||
|
||||
export default SettingClashExternal;
|
||||
@@ -0,0 +1,63 @@
|
||||
import { List } from "@mui/material";
|
||||
import { BaseCard, NumberItem, SwitchItem } from "@nyanpasu/ui";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { useClash, useNyanpasu } from "@nyanpasu/interface";
|
||||
import { useMemo } from "react";
|
||||
import { useMessage } from "@/hooks/use-notification";
|
||||
|
||||
export const SettingClashPort = () => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const { nyanpasuConfig, setNyanpasuConfig } = useNyanpasu();
|
||||
|
||||
const { getConfigs, setConfigs } = useClash();
|
||||
|
||||
const port = useMemo(() => {
|
||||
return (
|
||||
getConfigs.data?.["mixed-port"] ||
|
||||
nyanpasuConfig?.verge_mixed_port ||
|
||||
7890
|
||||
);
|
||||
}, [getConfigs.data?.["mixed-port"], nyanpasuConfig?.verge_mixed_port]);
|
||||
|
||||
return (
|
||||
<BaseCard label={t("Clash Port")}>
|
||||
<List disablePadding>
|
||||
<NumberItem
|
||||
label={t("Mixed Port")}
|
||||
vaule={port}
|
||||
checkEvent={(input) => input > 65535 || input < 1}
|
||||
checkLabel="Port must be between 1 and 65535."
|
||||
onApply={(value) => {
|
||||
setConfigs({ "mixed-port": value });
|
||||
setNyanpasuConfig({ verge_mixed_port: value });
|
||||
}}
|
||||
/>
|
||||
|
||||
<SwitchItem
|
||||
label={t("Random Port")}
|
||||
checked={nyanpasuConfig?.enable_random_port || false}
|
||||
onChange={async () => {
|
||||
try {
|
||||
await setNyanpasuConfig({
|
||||
enable_random_port: !nyanpasuConfig?.enable_random_port,
|
||||
});
|
||||
} catch (e) {
|
||||
useMessage(JSON.stringify(e), {
|
||||
title: t("Error"),
|
||||
type: "error",
|
||||
});
|
||||
} finally {
|
||||
useMessage(t("After restart to take effect"), {
|
||||
title: t("Success"),
|
||||
type: "info",
|
||||
});
|
||||
}
|
||||
}}
|
||||
/>
|
||||
</List>
|
||||
</BaseCard>
|
||||
);
|
||||
};
|
||||
|
||||
export default SettingClashPort;
|
||||
@@ -64,5 +64,12 @@ export const useMessage = async (
|
||||
value: string,
|
||||
options?: string | MessageDialogOptions | undefined,
|
||||
) => {
|
||||
await message(value, options);
|
||||
if (typeof options === "object") {
|
||||
await message(value, {
|
||||
...options,
|
||||
title: `Clash Nyanpasu - ${options.title}`,
|
||||
});
|
||||
} else {
|
||||
await message(value, options);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
import { motion } from "framer-motion";
|
||||
import { ReactNode } from "react";
|
||||
|
||||
/**
|
||||
* @example
|
||||
* <Expand open={true}></Expand>
|
||||
*
|
||||
* @returns {React.JSX.Element}
|
||||
* React.JSX.Element
|
||||
*
|
||||
* `With motion support.`
|
||||
*
|
||||
* @author keiko233 <i@elaina.moe>
|
||||
* @copyright LibNyanpasu org. 2024
|
||||
*/
|
||||
export const Expand = ({
|
||||
open,
|
||||
children,
|
||||
}: {
|
||||
open: boolean;
|
||||
children: ReactNode;
|
||||
}): React.JSX.Element => {
|
||||
return (
|
||||
<motion.div
|
||||
animate={open ? "open" : "closed"}
|
||||
variants={{
|
||||
open: { opacity: 1, height: "auto" },
|
||||
closed: { opacity: 0, height: 0 },
|
||||
}}
|
||||
>
|
||||
{children}
|
||||
</motion.div>
|
||||
);
|
||||
};
|
||||
@@ -1,3 +1,4 @@
|
||||
export * from "./basePage";
|
||||
export * from "./baseCard";
|
||||
export * from "./item";
|
||||
export * from "./expand";
|
||||
|
||||
@@ -1,2 +1,3 @@
|
||||
export * from "./switchItem";
|
||||
export * from "./menuItem";
|
||||
export * from "./numberItem";
|
||||
|
||||
@@ -3,6 +3,7 @@ import {
|
||||
ListItemText,
|
||||
MenuItem as MuiMenuItem,
|
||||
Select,
|
||||
SxProps,
|
||||
} from "@mui/material";
|
||||
|
||||
type OptionValue = string | number | boolean;
|
||||
@@ -12,13 +13,37 @@ export interface MenuItemProps {
|
||||
options: Record<string, OptionValue>;
|
||||
selected: OptionValue;
|
||||
onSelected: (value: OptionValue) => void;
|
||||
selectSx?: SxProps;
|
||||
disabled?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* @example
|
||||
* <MenuItem
|
||||
label={t("Log Level")}
|
||||
options={options}
|
||||
selected={selected}
|
||||
onSelected={(value) => {
|
||||
console.log(value);
|
||||
}}
|
||||
selectSx={{ width: 100 }}
|
||||
/>
|
||||
*
|
||||
* @returns {React.JSX.Element}
|
||||
* React.JSX.Element
|
||||
*
|
||||
* `MenuItem extends MuiMenuItem. Support options api.`
|
||||
*
|
||||
* @author keiko233 <i@elaina.moe>
|
||||
* @copyright LibNyanpasu org. 2024
|
||||
*/
|
||||
export const MenuItem = ({
|
||||
label,
|
||||
options,
|
||||
selected,
|
||||
onSelected,
|
||||
selectSx,
|
||||
disabled,
|
||||
}: MenuItemProps) => {
|
||||
return (
|
||||
<ListItem sx={{ pl: 0, pr: 0 }}>
|
||||
@@ -31,6 +56,8 @@ export const MenuItem = ({
|
||||
onChange={(e) => {
|
||||
onSelected(e.target.value);
|
||||
}}
|
||||
sx={{ width: 104, ...selectSx }}
|
||||
disabled={disabled}
|
||||
>
|
||||
{Object.entries(options).map(([key, value]) => (
|
||||
<MuiMenuItem
|
||||
|
||||
@@ -0,0 +1,107 @@
|
||||
import {
|
||||
ListItem,
|
||||
ListItemText,
|
||||
TextField,
|
||||
Box,
|
||||
Button,
|
||||
Typography,
|
||||
Divider,
|
||||
} from "@mui/material";
|
||||
import Done from "@mui/icons-material/Done";
|
||||
import { ChangeEvent, useMemo, useState } from "react";
|
||||
import { Expand } from "../expand";
|
||||
|
||||
export interface NumberItemprops {
|
||||
label: string;
|
||||
vaule: number;
|
||||
checkEvent: (input: number) => boolean;
|
||||
checkLabel: string;
|
||||
onApply: (input: number) => void;
|
||||
divider?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* @example
|
||||
* <NumberItem
|
||||
label={t("Mixed Port")}
|
||||
vaule={port}
|
||||
checkEvent={(input) => input > 65535 || input < 1}
|
||||
checkLabel="Port must be between 1 and 65535."
|
||||
onApply={(value) => {
|
||||
setConfigs({ "mixed-port": value });
|
||||
}}
|
||||
/>
|
||||
*
|
||||
* @returns {React.JSX.Element}
|
||||
* React.JSX.Element
|
||||
*
|
||||
* `NumberItem most use for port label.`
|
||||
*
|
||||
* @author keiko233 <i@elaina.moe>
|
||||
* @copyright LibNyanpasu org. 2024
|
||||
*/
|
||||
export const NumberItem = ({
|
||||
label,
|
||||
vaule,
|
||||
checkEvent,
|
||||
checkLabel,
|
||||
onApply,
|
||||
divider,
|
||||
}: NumberItemprops) => {
|
||||
const [changed, setChanged] = useState(false);
|
||||
|
||||
const [input, setInput] = useState<number | null>(null);
|
||||
|
||||
const applyCheck = useMemo(() => checkEvent(input as number), [input]);
|
||||
|
||||
return (
|
||||
<>
|
||||
<ListItem sx={{ pl: 0, pr: 0 }}>
|
||||
<ListItemText primary={label} />
|
||||
|
||||
<TextField
|
||||
value={input !== null ? input : vaule}
|
||||
size="small"
|
||||
variant="outlined"
|
||||
sx={{ width: 80 }}
|
||||
inputProps={{ "aria-autocomplete": "none" }}
|
||||
onChange={(e: ChangeEvent<HTMLInputElement>) => {
|
||||
setInput(Number(e.target.value));
|
||||
setChanged(true);
|
||||
}}
|
||||
/>
|
||||
</ListItem>
|
||||
|
||||
<Expand open={changed}>
|
||||
<Box
|
||||
sx={{ pb: 1 }}
|
||||
display="flex"
|
||||
justifyContent="space-between"
|
||||
alignItems="center"
|
||||
>
|
||||
<span>
|
||||
{applyCheck && (
|
||||
<Typography variant="body2" color="error">
|
||||
{checkLabel}
|
||||
</Typography>
|
||||
)}
|
||||
</span>
|
||||
|
||||
<Button
|
||||
variant="contained"
|
||||
startIcon={<Done />}
|
||||
disabled={applyCheck}
|
||||
onClick={() => {
|
||||
onApply(input as number);
|
||||
setChanged(false);
|
||||
}}
|
||||
>
|
||||
Apply
|
||||
</Button>
|
||||
</Box>
|
||||
|
||||
{divider && <Divider />}
|
||||
</Expand>
|
||||
</>
|
||||
);
|
||||
};
|
||||
@@ -5,8 +5,10 @@
|
||||
"module": "index.ts",
|
||||
"dependencies": {
|
||||
"@material/material-color-utilities": "0.2.7",
|
||||
"@mui/icons-material": "5.15.15",
|
||||
"@mui/material": "5.15.15",
|
||||
"@types/react": "18.2.79",
|
||||
"framer-motion": "11.1.0",
|
||||
"react": "18.2.0",
|
||||
"react-error-boundary": "4.0.13"
|
||||
},
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
"manifest_version": 1,
|
||||
"latest": {
|
||||
"mihomo": "v1.18.3",
|
||||
"mihomo_alpha": "alpha-ff2071c",
|
||||
"mihomo_alpha": "alpha-d4ececa",
|
||||
"clash_rs": "v0.1.16",
|
||||
"clash_premium": "2023-09-05-gdcc8d87"
|
||||
},
|
||||
@@ -36,5 +36,5 @@
|
||||
"darwin-x64": "clash-darwin-amd64-n{}.gz"
|
||||
}
|
||||
},
|
||||
"updated_at": "2024-04-17T22:19:33.317Z"
|
||||
"updated_at": "2024-04-18T22:19:13.198Z"
|
||||
}
|
||||
|
||||
Generated
+6
@@ -292,12 +292,18 @@ importers:
|
||||
'@material/material-color-utilities':
|
||||
specifier: 0.2.7
|
||||
version: 0.2.7
|
||||
'@mui/icons-material':
|
||||
specifier: 5.15.15
|
||||
version: 5.15.15(@mui/material@5.15.15)(@types/react@18.2.79)(react@18.2.0)
|
||||
'@mui/material':
|
||||
specifier: 5.15.15
|
||||
version: 5.15.15(@emotion/react@11.11.4)(@emotion/styled@11.11.5)(@types/react@18.2.79)(react-dom@18.2.0)(react@18.2.0)
|
||||
'@types/react':
|
||||
specifier: 18.2.79
|
||||
version: 18.2.79
|
||||
framer-motion:
|
||||
specifier: 11.1.0
|
||||
version: 11.1.0(react-dom@18.2.0)(react@18.2.0)
|
||||
react:
|
||||
specifier: 18.2.0
|
||||
version: 18.2.0
|
||||
|
||||
@@ -30,6 +30,7 @@ async function main() {
|
||||
const tauriAppOverrides = await fs.readJSON(TAURI_DEV_APP_OVERRIDES_PATH);
|
||||
const tauriConf = merge(tauriAppConf, tauriAppOverrides);
|
||||
const packageJson = await fs.readJSON(NYANPASU_PACKAGE_JSON_PATH);
|
||||
const rootPackageJson = await fs.readJSON(ROOT_PACKAGE_JSON_PATH);
|
||||
// const wxsFile = await fs.readFile(WXS_PATH, "utf-8");
|
||||
|
||||
if (isNSIS) {
|
||||
@@ -63,6 +64,8 @@ async function main() {
|
||||
consola.debug("Write tauri version to package.json");
|
||||
packageJson.version = version;
|
||||
await fs.writeJSON(NYANPASU_PACKAGE_JSON_PATH, packageJson, { spaces: 2 });
|
||||
rootPackageJson.version = version;
|
||||
await fs.writeJSON(ROOT_PACKAGE_JSON_PATH, rootPackageJson, { spaces: 2 });
|
||||
consola.debug("package.json updated");
|
||||
}
|
||||
|
||||
|
||||
@@ -27,11 +27,13 @@
|
||||
"@mui/material": "^5.15.5",
|
||||
"@mui/x-data-grid": "^6.18.7",
|
||||
"@tauri-apps/api": "^1.5.3",
|
||||
"@types/json-schema": "^7.0.15",
|
||||
"ahooks": "^3.7.8",
|
||||
"axios": "^1.6.5",
|
||||
"dayjs": "1.11.5",
|
||||
"i18next": "^23.7.16",
|
||||
"lodash-es": "^4.17.21",
|
||||
"meta-json-schema": "^1.18.3-beta",
|
||||
"monaco-editor": "^0.47.0",
|
||||
"monaco-yaml": "^5.1.1",
|
||||
"nanoid": "^5.0.4",
|
||||
|
||||
Generated
+718
-683
File diff suppressed because it is too large
Load Diff
@@ -18,6 +18,10 @@ import * as monaco from "monaco-editor";
|
||||
import { editor } from "monaco-editor/esm/vs/editor/editor.api";
|
||||
import { configureMonacoYaml } from "monaco-yaml";
|
||||
|
||||
import { type JSONSchema7 } from "json-schema";
|
||||
import metaSchema from "meta-json-schema/schemas/meta-json-schema.json";
|
||||
import mergeSchema from "meta-json-schema/schemas/clash-verge-merge-json-schema.json";
|
||||
|
||||
interface Props {
|
||||
uid: string;
|
||||
open: boolean;
|
||||
@@ -33,12 +37,14 @@ configureMonacoYaml(monaco, {
|
||||
enableSchemaRequest: true,
|
||||
schemas: [
|
||||
{
|
||||
uri: "https://fastly.jsdelivr.net/gh/dongchengjie/meta-json-schema@main/schemas/meta-json-schema.json",
|
||||
uri: "http://example.com/meta-json-schema.json",
|
||||
fileMatch: ["**/*.clash.yaml"],
|
||||
schema: metaSchema as JSONSchema7,
|
||||
},
|
||||
{
|
||||
uri: "https://fastly.jsdelivr.net/gh/dongchengjie/meta-json-schema@main/schemas/clash-verge-merge-json-schema.json",
|
||||
uri: "http://example.com/clash-verge-merge-json-schema.json",
|
||||
fileMatch: ["**/*.merge.yaml"],
|
||||
schema: mergeSchema as JSONSchema7,
|
||||
},
|
||||
],
|
||||
});
|
||||
@@ -65,8 +71,10 @@ export const EditorViewer = (props: Props) => {
|
||||
instanceRef.current = editor.create(editorRef.current, {
|
||||
model: model,
|
||||
language: language,
|
||||
tabSize: ["yaml", "javascript"].includes(language) ? 2 : 4, // 根据语言类型设置缩进
|
||||
theme: themeMode === "light" ? "vs" : "vs-dark",
|
||||
minimap: { enabled: dom.clientWidth >= 1000 }, // 超过一定宽度显示minimap滚动条
|
||||
mouseWheelZoom: true, // Ctrl+滚轮调节缩放
|
||||
quickSuggestions: {
|
||||
strings: true, // 字符串类型的建议
|
||||
comments: true, // 注释类型的建议
|
||||
@@ -102,7 +110,7 @@ export const EditorViewer = (props: Props) => {
|
||||
<DialogTitle>{t("Edit File")}</DialogTitle>
|
||||
|
||||
<DialogContent
|
||||
sx={{ width: "95%", height: "100vh", pb: 1, userSelect: "text" }}
|
||||
sx={{ width: "94%", height: "100vh", pb: 1, userSelect: "text" }}
|
||||
>
|
||||
<div style={{ width: "100%", height: "100%" }} ref={editorRef} />
|
||||
</DialogContent>
|
||||
|
||||
@@ -109,7 +109,7 @@ export const ProxyHead = (props: Props) => {
|
||||
<IconButton
|
||||
size="small"
|
||||
color="inherit"
|
||||
title={t("Proxy detail")}
|
||||
title={showType ? t("Proxy basic") : t("Proxy detail")}
|
||||
onClick={() => onHeadState({ showType: !showType })}
|
||||
>
|
||||
{showType ? <VisibilityRounded /> : <VisibilityOffRounded />}
|
||||
|
||||
@@ -67,8 +67,9 @@ export const ProxyItemMini = (props: Props) => {
|
||||
"&:hover .the-icon": { display: "none" },
|
||||
"& .the-pin, & .the-unpin": {
|
||||
position: "absolute",
|
||||
top: "-8px",
|
||||
right: "-8px",
|
||||
fontSize: "12px",
|
||||
top: "-5px",
|
||||
right: "-5px",
|
||||
},
|
||||
"& .the-unpin": { filter: "grayscale(1)" },
|
||||
"&.Mui-selected": {
|
||||
|
||||
@@ -7,10 +7,17 @@ import {
|
||||
} from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { useRecoilValue } from "recoil";
|
||||
import { Chip } from "@mui/material";
|
||||
import {
|
||||
Button,
|
||||
Dialog,
|
||||
DialogActions,
|
||||
DialogContent,
|
||||
DialogTitle,
|
||||
Chip,
|
||||
} from "@mui/material";
|
||||
import { atomThemeMode } from "@/services/states";
|
||||
import { getRuntimeYaml } from "@/services/cmds";
|
||||
import { BaseDialog, DialogRef } from "@/components/base";
|
||||
import { DialogRef } from "@/components/base";
|
||||
import { editor } from "monaco-editor/esm/vs/editor/editor.api";
|
||||
|
||||
import "monaco-editor/esm/vs/basic-languages/javascript/javascript.contribution.js";
|
||||
@@ -47,9 +54,12 @@ export const ConfigViewer = forwardRef<DialogRef>((props, ref) => {
|
||||
instanceRef.current = editor.create(editorRef.current, {
|
||||
value: data ?? "# Error\n",
|
||||
language: "yaml",
|
||||
tabSize: 2,
|
||||
theme: themeMode === "light" ? "vs" : "vs-dark",
|
||||
minimap: { enabled: false },
|
||||
readOnly: true,
|
||||
minimap: { enabled: dom.clientWidth >= 1000 }, // 超过一定宽度显示minimap滚动条
|
||||
mouseWheelZoom: true, // Ctrl+滚轮调节缩放
|
||||
readOnly: true, // 只读
|
||||
readOnlyMessage: { value: t("ReadOnlyMessage") },
|
||||
});
|
||||
});
|
||||
},
|
||||
@@ -57,20 +67,22 @@ export const ConfigViewer = forwardRef<DialogRef>((props, ref) => {
|
||||
}));
|
||||
|
||||
return (
|
||||
<BaseDialog
|
||||
open={open}
|
||||
title={
|
||||
<>
|
||||
{t("Runtime Config")} <Chip label={t("ReadOnly")} size="small" />
|
||||
</>
|
||||
}
|
||||
contentSx={{ width: 520, pb: 1, userSelect: "text" }}
|
||||
cancelBtn={t("Back")}
|
||||
disableOk
|
||||
onClose={() => setOpen(false)}
|
||||
onCancel={() => setOpen(false)}
|
||||
>
|
||||
<div style={{ width: "100%", height: "420px" }} ref={editorRef} />
|
||||
</BaseDialog>
|
||||
<Dialog open={open} onClose={() => setOpen(false)} maxWidth="xl" fullWidth>
|
||||
<DialogTitle>
|
||||
{t("Runtime Config")} <Chip label={t("ReadOnly")} size="small" />
|
||||
</DialogTitle>
|
||||
|
||||
<DialogContent
|
||||
sx={{ width: "94%", height: "100vh", pb: 1, userSelect: "text" }}
|
||||
>
|
||||
<div style={{ width: "100%", height: "100%" }} ref={editorRef} />
|
||||
</DialogContent>
|
||||
|
||||
<DialogActions>
|
||||
<Button onClick={() => setOpen(false)} variant="outlined">
|
||||
{t("Back")}
|
||||
</Button>
|
||||
</DialogActions>
|
||||
</Dialog>
|
||||
);
|
||||
});
|
||||
|
||||
@@ -54,6 +54,7 @@
|
||||
"Sort by delay": "Sort by delay",
|
||||
"Sort by name": "Sort by name",
|
||||
"Delay check URL": "Delay check URL",
|
||||
"Proxy basic": "Proxy basic",
|
||||
"Proxy detail": "Proxy detail",
|
||||
"Filter": "Filter",
|
||||
"Filter conditions": "Filter conditions",
|
||||
@@ -129,6 +130,7 @@
|
||||
"Clash Field": "Clash Field",
|
||||
"Runtime Config": "Runtime Config",
|
||||
"ReadOnly": "ReadOnly",
|
||||
"ReadOnlyMessage": "Cannot edit in read-only editor",
|
||||
"Restart": "Restart",
|
||||
"Upgrade": "Upgrade",
|
||||
|
||||
|
||||
@@ -54,6 +54,7 @@
|
||||
"Sort by delay": "Сортировать по задержке",
|
||||
"Sort by name": "Сортировать по названию",
|
||||
"Delay check URL": "URL проверки задержки",
|
||||
"Proxy basic": "Резюме о прокси",
|
||||
"Proxy detail": "Подробности о прокси",
|
||||
"Filter": "Фильтр",
|
||||
"Filter conditions": "Условия фильтрации",
|
||||
@@ -115,6 +116,7 @@
|
||||
"Clash Field": "Используемые настройки Clash",
|
||||
"Runtime Config": "Используемый конфиг",
|
||||
"ReadOnly": "Только для чтения",
|
||||
"ReadOnlyMessage": "Невозможно редактировать в режиме только для чтения",
|
||||
"Restart": "Перезапуск",
|
||||
"Upgrade": "Обновлять",
|
||||
|
||||
|
||||
@@ -56,6 +56,7 @@
|
||||
"Sort by delay": "按延迟排序",
|
||||
"Sort by name": "按名称排序",
|
||||
"Delay check URL": "延迟测试链接",
|
||||
"Proxy basic": "隐藏节点细节",
|
||||
"Proxy detail": "展示节点细节",
|
||||
"Filter": "过滤节点",
|
||||
"Filter conditions": "过滤条件",
|
||||
@@ -135,6 +136,7 @@
|
||||
"Clash Field": "Clash 字段",
|
||||
"Runtime Config": "当前配置",
|
||||
"ReadOnly": "只读",
|
||||
"ReadOnlyMessage": "无法在只读模式下编辑",
|
||||
"Restart": "重启内核",
|
||||
"Upgrade": "升级内核",
|
||||
|
||||
|
||||
+2
-2
@@ -156,8 +156,8 @@ jobs:
|
||||
- name: Smoke test
|
||||
if: matrix.goarch == 'amd64' && matrix.goamd64 == 'v1'
|
||||
run: |
|
||||
./build/juicity-server version
|
||||
./build/juicity-client version
|
||||
./build/juicity-server -v
|
||||
./build/juicity-client -v
|
||||
|
||||
- name: Create binary ZIP archive and Signature
|
||||
run: |
|
||||
|
||||
+2
-2
@@ -146,8 +146,8 @@ jobs:
|
||||
- name: Smoke test
|
||||
if: matrix.goarch == 'amd64' && matrix.goamd64 == 'v1'
|
||||
run: |
|
||||
./build/juicity-server version
|
||||
./build/juicity-client version
|
||||
./build/juicity-server -v
|
||||
./build/juicity-client -v
|
||||
|
||||
- name: Create binary ZIP archive and Signature
|
||||
run: |
|
||||
|
||||
+17
-2
@@ -12,7 +12,8 @@ curl --silent "https://api.github.com/repos/juicity/juicity/releases" | jq -r '.
|
||||
|
||||
<!-- BEGIN NEW TOC ENTRY -->
|
||||
|
||||
- [v0.4.1 (Latest)](#v041-latest)
|
||||
- [v0.4.2 (Latest)](#v042-latest)
|
||||
- [v0.4.1](#v041)
|
||||
- [v0.4.0](#v040)
|
||||
- [v0.3.0](#v030)
|
||||
- [v0.2.1](#v021)
|
||||
@@ -23,7 +24,21 @@ curl --silent "https://api.github.com/repos/juicity/juicity/releases" | jq -r '.
|
||||
- [v0.1.0](#v010)
|
||||
<!-- BEGIN NEW CHANGELOGS -->
|
||||
|
||||
### v0.4.1 (Latest)
|
||||
### v0.4.2 (Latest)
|
||||
|
||||
> Release date: 2024/04/19
|
||||
|
||||
#### Bug Fixes
|
||||
|
||||
- fix(cmd): use generic version flag to display ver info in [#159](https://github.com/juicity/juicity/pull/159) by (@sumire88)
|
||||
|
||||
#### Others
|
||||
|
||||
- ci(seed-build): update smoke test step in [#160](https://github.com/juicity/juicity/pull/160) by (@sumire88)
|
||||
|
||||
**Full Changelog**: https://github.com/juicity/juicity/compare/v0.4.1...v0.4.2
|
||||
|
||||
### v0.4.1
|
||||
|
||||
> Release date: 2024/04/16
|
||||
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
LINUX_VERSION-5.15 = .155
|
||||
LINUX_KERNEL_HASH-5.15.155 = c85859b86d2e6d1fc91ca1be8b44f24a9b5bb9f86869b04a8665a3a6559126e4
|
||||
LINUX_VERSION-5.15 = .156
|
||||
LINUX_KERNEL_HASH-5.15.156 = 9f0465d14c93691056f5f94de647601f94f083ad8ce2e5d306564394b13e7778
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
LINUX_VERSION-6.1 = .86
|
||||
LINUX_KERNEL_HASH-6.1.86 = d3d3c8c44f0f0a870a95bd2823f9d91979d1aa6f266da5d8cccd0c4b15e3115b
|
||||
LINUX_VERSION-6.1 = .87
|
||||
LINUX_KERNEL_HASH-6.1.87 = fc7af16a72e8aee4790b796f1bf5003cb0de6095ea1ffd7d7c7c9a5678d95124
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
LINUX_VERSION-6.6 = .27
|
||||
LINUX_KERNEL_HASH-6.6.27 = 639e50060e3c8f23ed017cb10cfeacc6ba88ff5583812bb76859b4cc6a128291
|
||||
LINUX_VERSION-6.6 = .28
|
||||
LINUX_KERNEL_HASH-6.6.28 = 818716ed13e7dba6aaeae24e3073993e260812ed128d10272e94b922ee6d3394
|
||||
|
||||
+2
-2
@@ -21,7 +21,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
|
||||
--- a/drivers/net/dsa/mt7530.c
|
||||
+++ b/drivers/net/dsa/mt7530.c
|
||||
@@ -1243,27 +1243,31 @@ static int
|
||||
@@ -1404,27 +1404,31 @@ static int
|
||||
mt7530_port_bridge_join(struct dsa_switch *ds, int port,
|
||||
struct net_device *bridge)
|
||||
{
|
||||
@@ -65,7 +65,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
}
|
||||
|
||||
/* Add the all other ports to this port matrix. */
|
||||
@@ -1368,24 +1372,28 @@ static void
|
||||
@@ -1529,24 +1533,28 @@ static void
|
||||
mt7530_port_bridge_leave(struct dsa_switch *ds, int port,
|
||||
struct net_device *bridge)
|
||||
{
|
||||
|
||||
+9
-9
@@ -23,7 +23,7 @@ Signed-off-by: Paolo Abeni <pabeni@redhat.com>
|
||||
|
||||
--- a/drivers/net/dsa/mt7530.c
|
||||
+++ b/drivers/net/dsa/mt7530.c
|
||||
@@ -2499,6 +2499,32 @@ mt7531_setup(struct dsa_switch *ds)
|
||||
@@ -2660,6 +2660,32 @@ mt7531_setup(struct dsa_switch *ds)
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ Signed-off-by: Paolo Abeni <pabeni@redhat.com>
|
||||
static bool
|
||||
mt7530_phy_mode_supported(struct dsa_switch *ds, int port,
|
||||
const struct phylink_link_state *state)
|
||||
@@ -2535,6 +2561,37 @@ static bool mt7531_is_rgmii_port(struct
|
||||
@@ -2696,6 +2722,37 @@ static bool mt7531_is_rgmii_port(struct
|
||||
return (port == 5) && (priv->p5_intf_sel != P5_INTF_SEL_GMAC5_SGMII);
|
||||
}
|
||||
|
||||
@@ -94,7 +94,7 @@ Signed-off-by: Paolo Abeni <pabeni@redhat.com>
|
||||
static bool
|
||||
mt7531_phy_mode_supported(struct dsa_switch *ds, int port,
|
||||
const struct phylink_link_state *state)
|
||||
@@ -3011,6 +3068,18 @@ mt7531_cpu_port_config(struct dsa_switch
|
||||
@@ -3172,6 +3229,18 @@ mt7531_cpu_port_config(struct dsa_switch
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -113,7 +113,7 @@ Signed-off-by: Paolo Abeni <pabeni@redhat.com>
|
||||
static void
|
||||
mt7530_mac_port_validate(struct dsa_switch *ds, int port,
|
||||
unsigned long *supported)
|
||||
@@ -3246,6 +3315,7 @@ static const struct dsa_switch_ops mt753
|
||||
@@ -3407,6 +3476,7 @@ static const struct dsa_switch_ops mt753
|
||||
.port_vlan_del = mt7530_port_vlan_del,
|
||||
.port_mirror_add = mt753x_port_mirror_add,
|
||||
.port_mirror_del = mt753x_port_mirror_del,
|
||||
@@ -121,7 +121,7 @@ Signed-off-by: Paolo Abeni <pabeni@redhat.com>
|
||||
.phylink_validate = mt753x_phylink_validate,
|
||||
.phylink_mac_link_state = mt753x_phylink_mac_link_state,
|
||||
.phylink_mac_config = mt753x_phylink_mac_config,
|
||||
@@ -3263,6 +3333,7 @@ static const struct mt753x_info mt753x_t
|
||||
@@ -3424,6 +3494,7 @@ static const struct mt753x_info mt753x_t
|
||||
.phy_read = mt7530_phy_read,
|
||||
.phy_write = mt7530_phy_write,
|
||||
.pad_setup = mt7530_pad_clk_setup,
|
||||
@@ -129,7 +129,7 @@ Signed-off-by: Paolo Abeni <pabeni@redhat.com>
|
||||
.phy_mode_supported = mt7530_phy_mode_supported,
|
||||
.mac_port_validate = mt7530_mac_port_validate,
|
||||
.mac_port_get_state = mt7530_phylink_mac_link_state,
|
||||
@@ -3274,6 +3345,7 @@ static const struct mt753x_info mt753x_t
|
||||
@@ -3435,6 +3506,7 @@ static const struct mt753x_info mt753x_t
|
||||
.phy_read = mt7530_phy_read,
|
||||
.phy_write = mt7530_phy_write,
|
||||
.pad_setup = mt7530_pad_clk_setup,
|
||||
@@ -137,7 +137,7 @@ Signed-off-by: Paolo Abeni <pabeni@redhat.com>
|
||||
.phy_mode_supported = mt7530_phy_mode_supported,
|
||||
.mac_port_validate = mt7530_mac_port_validate,
|
||||
.mac_port_get_state = mt7530_phylink_mac_link_state,
|
||||
@@ -3286,6 +3358,7 @@ static const struct mt753x_info mt753x_t
|
||||
@@ -3447,6 +3519,7 @@ static const struct mt753x_info mt753x_t
|
||||
.phy_write = mt7531_ind_phy_write,
|
||||
.pad_setup = mt7531_pad_setup,
|
||||
.cpu_port_config = mt7531_cpu_port_config,
|
||||
@@ -145,7 +145,7 @@ Signed-off-by: Paolo Abeni <pabeni@redhat.com>
|
||||
.phy_mode_supported = mt7531_phy_mode_supported,
|
||||
.mac_port_validate = mt7531_mac_port_validate,
|
||||
.mac_port_get_state = mt7531_phylink_mac_link_state,
|
||||
@@ -3348,6 +3421,7 @@ mt7530_probe(struct mdio_device *mdiodev
|
||||
@@ -3509,6 +3582,7 @@ mt7530_probe(struct mdio_device *mdiodev
|
||||
*/
|
||||
if (!priv->info->sw_setup || !priv->info->pad_setup ||
|
||||
!priv->info->phy_read || !priv->info->phy_write ||
|
||||
@@ -155,7 +155,7 @@ Signed-off-by: Paolo Abeni <pabeni@redhat.com>
|
||||
!priv->info->mac_port_get_state || !priv->info->mac_port_config)
|
||||
--- a/drivers/net/dsa/mt7530.h
|
||||
+++ b/drivers/net/dsa/mt7530.h
|
||||
@@ -796,6 +796,8 @@ struct mt753x_info {
|
||||
@@ -801,6 +801,8 @@ struct mt753x_info {
|
||||
int (*phy_write)(struct mt7530_priv *priv, int port, int regnum, u16 val);
|
||||
int (*pad_setup)(struct dsa_switch *ds, phy_interface_t interface);
|
||||
int (*cpu_port_config)(struct dsa_switch *ds, int port);
|
||||
|
||||
+9
-9
@@ -21,7 +21,7 @@ Signed-off-by: Paolo Abeni <pabeni@redhat.com>
|
||||
|
||||
--- a/drivers/net/dsa/mt7530.c
|
||||
+++ b/drivers/net/dsa/mt7530.c
|
||||
@@ -2525,37 +2525,6 @@ static void mt7530_mac_port_get_caps(str
|
||||
@@ -2686,37 +2686,6 @@ static void mt7530_mac_port_get_caps(str
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ Signed-off-by: Paolo Abeni <pabeni@redhat.com>
|
||||
static bool mt7531_is_rgmii_port(struct mt7530_priv *priv, u32 port)
|
||||
{
|
||||
return (port == 5) && (priv->p5_intf_sel != P5_INTF_SEL_GMAC5_SGMII);
|
||||
@@ -2592,44 +2561,6 @@ static void mt7531_mac_port_get_caps(str
|
||||
@@ -2753,44 +2722,6 @@ static void mt7531_mac_port_get_caps(str
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,7 +104,7 @@ Signed-off-by: Paolo Abeni <pabeni@redhat.com>
|
||||
static int
|
||||
mt753x_pad_setup(struct dsa_switch *ds, const struct phylink_link_state *state)
|
||||
{
|
||||
@@ -2884,9 +2815,6 @@ mt753x_phylink_mac_config(struct dsa_swi
|
||||
@@ -3045,9 +2976,6 @@ mt753x_phylink_mac_config(struct dsa_swi
|
||||
struct mt7530_priv *priv = ds->priv;
|
||||
u32 mcr_cur, mcr_new;
|
||||
|
||||
@@ -114,7 +114,7 @@ Signed-off-by: Paolo Abeni <pabeni@redhat.com>
|
||||
switch (port) {
|
||||
case 0 ... 4: /* Internal phy */
|
||||
if (state->interface != PHY_INTERFACE_MODE_GMII)
|
||||
@@ -3102,12 +3030,6 @@ mt753x_phylink_validate(struct dsa_switc
|
||||
@@ -3263,12 +3191,6 @@ mt753x_phylink_validate(struct dsa_switc
|
||||
__ETHTOOL_DECLARE_LINK_MODE_MASK(mask) = { 0, };
|
||||
struct mt7530_priv *priv = ds->priv;
|
||||
|
||||
@@ -127,7 +127,7 @@ Signed-off-by: Paolo Abeni <pabeni@redhat.com>
|
||||
phylink_set_port_modes(mask);
|
||||
|
||||
if (state->interface != PHY_INTERFACE_MODE_TRGMII &&
|
||||
@@ -3334,7 +3256,6 @@ static const struct mt753x_info mt753x_t
|
||||
@@ -3495,7 +3417,6 @@ static const struct mt753x_info mt753x_t
|
||||
.phy_write = mt7530_phy_write,
|
||||
.pad_setup = mt7530_pad_clk_setup,
|
||||
.mac_port_get_caps = mt7530_mac_port_get_caps,
|
||||
@@ -135,7 +135,7 @@ Signed-off-by: Paolo Abeni <pabeni@redhat.com>
|
||||
.mac_port_validate = mt7530_mac_port_validate,
|
||||
.mac_port_get_state = mt7530_phylink_mac_link_state,
|
||||
.mac_port_config = mt7530_mac_config,
|
||||
@@ -3346,7 +3267,6 @@ static const struct mt753x_info mt753x_t
|
||||
@@ -3507,7 +3428,6 @@ static const struct mt753x_info mt753x_t
|
||||
.phy_write = mt7530_phy_write,
|
||||
.pad_setup = mt7530_pad_clk_setup,
|
||||
.mac_port_get_caps = mt7530_mac_port_get_caps,
|
||||
@@ -143,7 +143,7 @@ Signed-off-by: Paolo Abeni <pabeni@redhat.com>
|
||||
.mac_port_validate = mt7530_mac_port_validate,
|
||||
.mac_port_get_state = mt7530_phylink_mac_link_state,
|
||||
.mac_port_config = mt7530_mac_config,
|
||||
@@ -3359,7 +3279,6 @@ static const struct mt753x_info mt753x_t
|
||||
@@ -3520,7 +3440,6 @@ static const struct mt753x_info mt753x_t
|
||||
.pad_setup = mt7531_pad_setup,
|
||||
.cpu_port_config = mt7531_cpu_port_config,
|
||||
.mac_port_get_caps = mt7531_mac_port_get_caps,
|
||||
@@ -151,7 +151,7 @@ Signed-off-by: Paolo Abeni <pabeni@redhat.com>
|
||||
.mac_port_validate = mt7531_mac_port_validate,
|
||||
.mac_port_get_state = mt7531_phylink_mac_link_state,
|
||||
.mac_port_config = mt7531_mac_config,
|
||||
@@ -3422,7 +3341,6 @@ mt7530_probe(struct mdio_device *mdiodev
|
||||
@@ -3583,7 +3502,6 @@ mt7530_probe(struct mdio_device *mdiodev
|
||||
if (!priv->info->sw_setup || !priv->info->pad_setup ||
|
||||
!priv->info->phy_read || !priv->info->phy_write ||
|
||||
!priv->info->mac_port_get_caps ||
|
||||
@@ -161,7 +161,7 @@ Signed-off-by: Paolo Abeni <pabeni@redhat.com>
|
||||
return -EINVAL;
|
||||
--- a/drivers/net/dsa/mt7530.h
|
||||
+++ b/drivers/net/dsa/mt7530.h
|
||||
@@ -798,8 +798,6 @@ struct mt753x_info {
|
||||
@@ -803,8 +803,6 @@ struct mt753x_info {
|
||||
int (*cpu_port_config)(struct dsa_switch *ds, int port);
|
||||
void (*mac_port_get_caps)(struct dsa_switch *ds, int port,
|
||||
struct phylink_config *config);
|
||||
|
||||
+1
-1
@@ -20,7 +20,7 @@ Signed-off-by: Paolo Abeni <pabeni@redhat.com>
|
||||
|
||||
--- a/drivers/net/dsa/mt7530.c
|
||||
+++ b/drivers/net/dsa/mt7530.c
|
||||
@@ -3054,11 +3054,6 @@ mt753x_phylink_validate(struct dsa_switc
|
||||
@@ -3215,11 +3215,6 @@ mt753x_phylink_validate(struct dsa_switc
|
||||
|
||||
linkmode_and(supported, supported, mask);
|
||||
linkmode_and(state->advertising, state->advertising, mask);
|
||||
|
||||
+4
-4
@@ -23,7 +23,7 @@ Signed-off-by: Paolo Abeni <pabeni@redhat.com>
|
||||
|
||||
--- a/drivers/net/dsa/mt7530.c
|
||||
+++ b/drivers/net/dsa/mt7530.c
|
||||
@@ -2632,12 +2632,13 @@ static int mt7531_rgmii_setup(struct mt7
|
||||
@@ -2793,12 +2793,13 @@ static int mt7531_rgmii_setup(struct mt7
|
||||
}
|
||||
|
||||
static void mt7531_sgmii_validate(struct mt7530_priv *priv, int port,
|
||||
@@ -38,7 +38,7 @@ Signed-off-by: Paolo Abeni <pabeni@redhat.com>
|
||||
phylink_set(supported, 2500baseX_Full);
|
||||
phylink_set(supported, 2500baseT_Full);
|
||||
}
|
||||
@@ -3010,16 +3011,18 @@ static void mt753x_phylink_get_caps(stru
|
||||
@@ -3171,16 +3172,18 @@ static void mt753x_phylink_get_caps(stru
|
||||
|
||||
static void
|
||||
mt7530_mac_port_validate(struct dsa_switch *ds, int port,
|
||||
@@ -58,7 +58,7 @@ Signed-off-by: Paolo Abeni <pabeni@redhat.com>
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -3042,12 +3045,13 @@ mt753x_phylink_validate(struct dsa_switc
|
||||
@@ -3203,12 +3206,13 @@ mt753x_phylink_validate(struct dsa_switc
|
||||
}
|
||||
|
||||
/* This switch only supports 1G full-duplex. */
|
||||
@@ -76,7 +76,7 @@ Signed-off-by: Paolo Abeni <pabeni@redhat.com>
|
||||
phylink_set(mask, Asym_Pause);
|
||||
--- a/drivers/net/dsa/mt7530.h
|
||||
+++ b/drivers/net/dsa/mt7530.h
|
||||
@@ -799,6 +799,7 @@ struct mt753x_info {
|
||||
@@ -804,6 +804,7 @@ struct mt753x_info {
|
||||
void (*mac_port_get_caps)(struct dsa_switch *ds, int port,
|
||||
struct phylink_config *config);
|
||||
void (*mac_port_validate)(struct dsa_switch *ds, int port,
|
||||
|
||||
+6
-6
@@ -20,7 +20,7 @@ Signed-off-by: Paolo Abeni <pabeni@redhat.com>
|
||||
|
||||
--- a/drivers/net/dsa/mt7530.c
|
||||
+++ b/drivers/net/dsa/mt7530.c
|
||||
@@ -2631,19 +2631,6 @@ static int mt7531_rgmii_setup(struct mt7
|
||||
@@ -2792,19 +2792,6 @@ static int mt7531_rgmii_setup(struct mt7
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ Signed-off-by: Paolo Abeni <pabeni@redhat.com>
|
||||
static void
|
||||
mt7531_sgmii_link_up_force(struct dsa_switch *ds, int port,
|
||||
unsigned int mode, phy_interface_t interface,
|
||||
@@ -3010,51 +2997,21 @@ static void mt753x_phylink_get_caps(stru
|
||||
@@ -3171,51 +3158,21 @@ static void mt753x_phylink_get_caps(stru
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -97,7 +97,7 @@ Signed-off-by: Paolo Abeni <pabeni@redhat.com>
|
||||
|
||||
linkmode_and(supported, supported, mask);
|
||||
linkmode_and(state->advertising, state->advertising, mask);
|
||||
@@ -3255,7 +3212,6 @@ static const struct mt753x_info mt753x_t
|
||||
@@ -3416,7 +3373,6 @@ static const struct mt753x_info mt753x_t
|
||||
.phy_write = mt7530_phy_write,
|
||||
.pad_setup = mt7530_pad_clk_setup,
|
||||
.mac_port_get_caps = mt7530_mac_port_get_caps,
|
||||
@@ -105,7 +105,7 @@ Signed-off-by: Paolo Abeni <pabeni@redhat.com>
|
||||
.mac_port_get_state = mt7530_phylink_mac_link_state,
|
||||
.mac_port_config = mt7530_mac_config,
|
||||
},
|
||||
@@ -3266,7 +3222,6 @@ static const struct mt753x_info mt753x_t
|
||||
@@ -3427,7 +3383,6 @@ static const struct mt753x_info mt753x_t
|
||||
.phy_write = mt7530_phy_write,
|
||||
.pad_setup = mt7530_pad_clk_setup,
|
||||
.mac_port_get_caps = mt7530_mac_port_get_caps,
|
||||
@@ -113,7 +113,7 @@ Signed-off-by: Paolo Abeni <pabeni@redhat.com>
|
||||
.mac_port_get_state = mt7530_phylink_mac_link_state,
|
||||
.mac_port_config = mt7530_mac_config,
|
||||
},
|
||||
@@ -3278,7 +3233,6 @@ static const struct mt753x_info mt753x_t
|
||||
@@ -3439,7 +3394,6 @@ static const struct mt753x_info mt753x_t
|
||||
.pad_setup = mt7531_pad_setup,
|
||||
.cpu_port_config = mt7531_cpu_port_config,
|
||||
.mac_port_get_caps = mt7531_mac_port_get_caps,
|
||||
@@ -121,7 +121,7 @@ Signed-off-by: Paolo Abeni <pabeni@redhat.com>
|
||||
.mac_port_get_state = mt7531_phylink_mac_link_state,
|
||||
.mac_port_config = mt7531_mac_config,
|
||||
.mac_pcs_an_restart = mt7531_sgmii_restart_an,
|
||||
@@ -3340,7 +3294,6 @@ mt7530_probe(struct mdio_device *mdiodev
|
||||
@@ -3501,7 +3455,6 @@ mt7530_probe(struct mdio_device *mdiodev
|
||||
if (!priv->info->sw_setup || !priv->info->pad_setup ||
|
||||
!priv->info->phy_read || !priv->info->phy_write ||
|
||||
!priv->info->mac_port_get_caps ||
|
||||
|
||||
+19
-19
@@ -33,7 +33,7 @@ Signed-off-by: Paolo Abeni <pabeni@redhat.com>
|
||||
/* String, offset, and register size in bytes if different from 4 bytes */
|
||||
static const struct mt7530_mib_desc mt7530_mib[] = {
|
||||
MIB_DESC(1, 0x00, "TxDrop"),
|
||||
@@ -2631,12 +2636,11 @@ static int mt7531_rgmii_setup(struct mt7
|
||||
@@ -2792,12 +2797,11 @@ static int mt7531_rgmii_setup(struct mt7
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ Signed-off-by: Paolo Abeni <pabeni@redhat.com>
|
||||
unsigned int val;
|
||||
|
||||
/* For adjusting speed and duplex of SGMII force mode. */
|
||||
@@ -2662,6 +2666,9 @@ mt7531_sgmii_link_up_force(struct dsa_sw
|
||||
@@ -2823,6 +2827,9 @@ mt7531_sgmii_link_up_force(struct dsa_sw
|
||||
|
||||
/* MT7531 SGMII 1G force mode can only work in full duplex mode,
|
||||
* no matter MT7531_SGMII_FORCE_HALF_DUPLEX is set or not.
|
||||
@@ -60,7 +60,7 @@ Signed-off-by: Paolo Abeni <pabeni@redhat.com>
|
||||
*/
|
||||
if ((speed == SPEED_10 || speed == SPEED_100) &&
|
||||
duplex != DUPLEX_FULL)
|
||||
@@ -2737,9 +2744,10 @@ static int mt7531_sgmii_setup_mode_an(st
|
||||
@@ -2898,9 +2905,10 @@ static int mt7531_sgmii_setup_mode_an(st
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ Signed-off-by: Paolo Abeni <pabeni@redhat.com>
|
||||
u32 val;
|
||||
|
||||
/* Only restart AN when AN is enabled */
|
||||
@@ -2796,6 +2804,24 @@ mt753x_mac_config(struct dsa_switch *ds,
|
||||
@@ -2957,6 +2965,24 @@ mt753x_mac_config(struct dsa_switch *ds,
|
||||
return priv->info->mac_port_config(ds, port, mode, state->interface);
|
||||
}
|
||||
|
||||
@@ -98,7 +98,7 @@ Signed-off-by: Paolo Abeni <pabeni@redhat.com>
|
||||
static void
|
||||
mt753x_phylink_mac_config(struct dsa_switch *ds, int port, unsigned int mode,
|
||||
const struct phylink_link_state *state)
|
||||
@@ -2857,17 +2883,6 @@ unsupported:
|
||||
@@ -3018,17 +3044,6 @@ unsupported:
|
||||
mt7530_write(priv, MT7530_PMCR_P(port), mcr_new);
|
||||
}
|
||||
|
||||
@@ -116,7 +116,7 @@ Signed-off-by: Paolo Abeni <pabeni@redhat.com>
|
||||
static void mt753x_phylink_mac_link_down(struct dsa_switch *ds, int port,
|
||||
unsigned int mode,
|
||||
phy_interface_t interface)
|
||||
@@ -2877,16 +2892,13 @@ static void mt753x_phylink_mac_link_down
|
||||
@@ -3038,16 +3053,13 @@ static void mt753x_phylink_mac_link_down
|
||||
mt7530_clear(priv, MT7530_PMCR_P(port), PMCR_LINK_SETTINGS_MASK);
|
||||
}
|
||||
|
||||
@@ -139,7 +139,7 @@ Signed-off-by: Paolo Abeni <pabeni@redhat.com>
|
||||
}
|
||||
|
||||
static void mt753x_phylink_mac_link_up(struct dsa_switch *ds, int port,
|
||||
@@ -2899,8 +2911,6 @@ static void mt753x_phylink_mac_link_up(s
|
||||
@@ -3060,8 +3072,6 @@ static void mt753x_phylink_mac_link_up(s
|
||||
struct mt7530_priv *priv = ds->priv;
|
||||
u32 mcr;
|
||||
|
||||
@@ -148,7 +148,7 @@ Signed-off-by: Paolo Abeni <pabeni@redhat.com>
|
||||
mcr = PMCR_RX_EN | PMCR_TX_EN | PMCR_FORCE_LNK;
|
||||
|
||||
/* MT753x MAC works in 1G full duplex mode for all up-clocked
|
||||
@@ -2978,6 +2988,8 @@ mt7531_cpu_port_config(struct dsa_switch
|
||||
@@ -3139,6 +3149,8 @@ mt7531_cpu_port_config(struct dsa_switch
|
||||
return ret;
|
||||
mt7530_write(priv, MT7530_PMCR_P(port),
|
||||
PMCR_CPU_PORT_SETTING(priv->id));
|
||||
@@ -157,7 +157,7 @@ Signed-off-by: Paolo Abeni <pabeni@redhat.com>
|
||||
mt753x_phylink_mac_link_up(ds, port, MLO_AN_FIXED, interface, NULL,
|
||||
speed, DUPLEX_FULL, true, true);
|
||||
|
||||
@@ -3017,16 +3029,13 @@ mt753x_phylink_validate(struct dsa_switc
|
||||
@@ -3178,16 +3190,13 @@ mt753x_phylink_validate(struct dsa_switc
|
||||
linkmode_and(state->advertising, state->advertising, mask);
|
||||
}
|
||||
|
||||
@@ -178,7 +178,7 @@ Signed-off-by: Paolo Abeni <pabeni@redhat.com>
|
||||
pmsr = mt7530_read(priv, MT7530_PMSR_P(port));
|
||||
|
||||
state->link = (pmsr & PMSR_LINK);
|
||||
@@ -3053,8 +3062,6 @@ mt7530_phylink_mac_link_state(struct dsa
|
||||
@@ -3214,8 +3223,6 @@ mt7530_phylink_mac_link_state(struct dsa
|
||||
state->pause |= MLO_PAUSE_RX;
|
||||
if (pmsr & PMSR_TX_FC)
|
||||
state->pause |= MLO_PAUSE_TX;
|
||||
@@ -187,7 +187,7 @@ Signed-off-by: Paolo Abeni <pabeni@redhat.com>
|
||||
}
|
||||
|
||||
static int
|
||||
@@ -3096,32 +3103,49 @@ mt7531_sgmii_pcs_get_state_an(struct mt7
|
||||
@@ -3257,32 +3264,49 @@ mt7531_sgmii_pcs_get_state_an(struct mt7
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -249,7 +249,7 @@ Signed-off-by: Paolo Abeni <pabeni@redhat.com>
|
||||
|
||||
if (ret)
|
||||
return ret;
|
||||
@@ -3134,6 +3158,13 @@ mt753x_setup(struct dsa_switch *ds)
|
||||
@@ -3295,6 +3319,13 @@ mt753x_setup(struct dsa_switch *ds)
|
||||
if (ret && priv->irq)
|
||||
mt7530_free_irq_common(priv);
|
||||
|
||||
@@ -263,7 +263,7 @@ Signed-off-by: Paolo Abeni <pabeni@redhat.com>
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -3195,9 +3226,8 @@ static const struct dsa_switch_ops mt753
|
||||
@@ -3356,9 +3387,8 @@ static const struct dsa_switch_ops mt753
|
||||
.port_mirror_del = mt753x_port_mirror_del,
|
||||
.phylink_get_caps = mt753x_phylink_get_caps,
|
||||
.phylink_validate = mt753x_phylink_validate,
|
||||
@@ -274,7 +274,7 @@ Signed-off-by: Paolo Abeni <pabeni@redhat.com>
|
||||
.phylink_mac_link_down = mt753x_phylink_mac_link_down,
|
||||
.phylink_mac_link_up = mt753x_phylink_mac_link_up,
|
||||
.get_mac_eee = mt753x_get_mac_eee,
|
||||
@@ -3207,36 +3237,34 @@ static const struct dsa_switch_ops mt753
|
||||
@@ -3368,36 +3398,34 @@ static const struct dsa_switch_ops mt753
|
||||
static const struct mt753x_info mt753x_table[] = {
|
||||
[ID_MT7621] = {
|
||||
.id = ID_MT7621,
|
||||
@@ -314,7 +314,7 @@ Signed-off-by: Paolo Abeni <pabeni@redhat.com>
|
||||
},
|
||||
};
|
||||
|
||||
@@ -3294,7 +3322,7 @@ mt7530_probe(struct mdio_device *mdiodev
|
||||
@@ -3455,7 +3483,7 @@ mt7530_probe(struct mdio_device *mdiodev
|
||||
if (!priv->info->sw_setup || !priv->info->pad_setup ||
|
||||
!priv->info->phy_read || !priv->info->phy_write ||
|
||||
!priv->info->mac_port_get_caps ||
|
||||
@@ -325,7 +325,7 @@ Signed-off-by: Paolo Abeni <pabeni@redhat.com>
|
||||
priv->id = priv->info->id;
|
||||
--- a/drivers/net/dsa/mt7530.h
|
||||
+++ b/drivers/net/dsa/mt7530.h
|
||||
@@ -768,6 +768,12 @@ static const char *p5_intf_modes(unsigne
|
||||
@@ -773,6 +773,12 @@ static const char *p5_intf_modes(unsigne
|
||||
|
||||
struct mt7530_priv;
|
||||
|
||||
@@ -338,7 +338,7 @@ Signed-off-by: Paolo Abeni <pabeni@redhat.com>
|
||||
/* struct mt753x_info - This is the main data structure for holding the specific
|
||||
* part for each supported device
|
||||
* @sw_setup: Holding the handler to a device initialization
|
||||
@@ -779,18 +785,14 @@ struct mt7530_priv;
|
||||
@@ -784,18 +790,14 @@ struct mt7530_priv;
|
||||
* port
|
||||
* @mac_port_validate: Holding the way to set addition validate type for a
|
||||
* certan MAC port
|
||||
@@ -359,7 +359,7 @@ Signed-off-by: Paolo Abeni <pabeni@redhat.com>
|
||||
int (*sw_setup)(struct dsa_switch *ds);
|
||||
int (*phy_read)(struct mt7530_priv *priv, int port, int regnum);
|
||||
int (*phy_write)(struct mt7530_priv *priv, int port, int regnum, u16 val);
|
||||
@@ -801,15 +803,9 @@ struct mt753x_info {
|
||||
@@ -806,15 +808,9 @@ struct mt753x_info {
|
||||
void (*mac_port_validate)(struct dsa_switch *ds, int port,
|
||||
phy_interface_t interface,
|
||||
unsigned long *supported);
|
||||
@@ -375,7 +375,7 @@ Signed-off-by: Paolo Abeni <pabeni@redhat.com>
|
||||
};
|
||||
|
||||
/* struct mt7530_priv - This is the main data structure for holding the state
|
||||
@@ -851,6 +847,7 @@ struct mt7530_priv {
|
||||
@@ -856,6 +852,7 @@ struct mt7530_priv {
|
||||
u8 mirror_tx;
|
||||
|
||||
struct mt7530_port ports[MT7530_NUM_PORTS];
|
||||
|
||||
+3
-3
@@ -20,7 +20,7 @@ Signed-off-by: Paolo Abeni <pabeni@redhat.com>
|
||||
|
||||
--- a/drivers/net/dsa/mt7530.c
|
||||
+++ b/drivers/net/dsa/mt7530.c
|
||||
@@ -3008,25 +3008,16 @@ static void mt753x_phylink_get_caps(stru
|
||||
@@ -3169,25 +3169,16 @@ static void mt753x_phylink_get_caps(stru
|
||||
priv->info->mac_port_get_caps(ds, port, config);
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ Signed-off-by: Paolo Abeni <pabeni@redhat.com>
|
||||
}
|
||||
|
||||
static void mt7530_pcs_get_state(struct phylink_pcs *pcs,
|
||||
@@ -3128,12 +3119,14 @@ static void mt7530_pcs_an_restart(struct
|
||||
@@ -3289,12 +3280,14 @@ static void mt7530_pcs_an_restart(struct
|
||||
}
|
||||
|
||||
static const struct phylink_pcs_ops mt7530_pcs_ops = {
|
||||
@@ -70,7 +70,7 @@ Signed-off-by: Paolo Abeni <pabeni@redhat.com>
|
||||
.pcs_get_state = mt7531_pcs_get_state,
|
||||
.pcs_config = mt753x_pcs_config,
|
||||
.pcs_an_restart = mt7531_pcs_an_restart,
|
||||
@@ -3225,7 +3218,6 @@ static const struct dsa_switch_ops mt753
|
||||
@@ -3386,7 +3379,6 @@ static const struct dsa_switch_ops mt753
|
||||
.port_mirror_add = mt753x_port_mirror_add,
|
||||
.port_mirror_del = mt753x_port_mirror_del,
|
||||
.phylink_get_caps = mt753x_phylink_get_caps,
|
||||
|
||||
+1
-1
@@ -19,7 +19,7 @@ Signed-off-by: Paolo Abeni <pabeni@redhat.com>
|
||||
|
||||
--- a/drivers/net/dsa/mt7530.c
|
||||
+++ b/drivers/net/dsa/mt7530.c
|
||||
@@ -3005,6 +3005,12 @@ static void mt753x_phylink_get_caps(stru
|
||||
@@ -3166,6 +3166,12 @@ static void mt753x_phylink_get_caps(stru
|
||||
config->mac_capabilities = MAC_ASYM_PAUSE | MAC_SYM_PAUSE |
|
||||
MAC_10 | MAC_100 | MAC_1000FD;
|
||||
|
||||
|
||||
+2
-2
@@ -81,7 +81,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
|
||||
--- a/drivers/net/dsa/mt7530.c
|
||||
+++ b/drivers/net/dsa/mt7530.c
|
||||
@@ -3143,9 +3143,16 @@ static int
|
||||
@@ -3304,9 +3304,16 @@ static int
|
||||
mt753x_setup(struct dsa_switch *ds)
|
||||
{
|
||||
struct mt7530_priv *priv = ds->priv;
|
||||
@@ -100,7 +100,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
@@ -3157,13 +3164,6 @@ mt753x_setup(struct dsa_switch *ds)
|
||||
@@ -3318,13 +3325,6 @@ mt753x_setup(struct dsa_switch *ds)
|
||||
if (ret && priv->irq)
|
||||
mt7530_free_irq_common(priv);
|
||||
|
||||
|
||||
+3
-3
@@ -26,7 +26,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
|
||||
--- a/drivers/net/dsa/mt7530.c
|
||||
+++ b/drivers/net/dsa/mt7530.c
|
||||
@@ -1589,11 +1589,11 @@ static void
|
||||
@@ -1750,11 +1750,11 @@ static void
|
||||
mt7530_hw_vlan_add(struct mt7530_priv *priv,
|
||||
struct mt7530_hw_vlan_entry *entry)
|
||||
{
|
||||
@@ -40,7 +40,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
|
||||
/* Validate the entry with independent learning, create egress tag per
|
||||
* VLAN and joining the port as one of the port members.
|
||||
@@ -1604,22 +1604,20 @@ mt7530_hw_vlan_add(struct mt7530_priv *p
|
||||
@@ -1765,22 +1765,20 @@ mt7530_hw_vlan_add(struct mt7530_priv *p
|
||||
|
||||
/* Decide whether adding tag or not for those outgoing packets from the
|
||||
* port inside the VLAN.
|
||||
@@ -72,7 +72,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -1638,11 +1636,7 @@ mt7530_hw_vlan_del(struct mt7530_priv *p
|
||||
@@ -1799,11 +1797,7 @@ mt7530_hw_vlan_del(struct mt7530_priv *p
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
+8
-8
@@ -21,7 +21,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
|
||||
--- a/drivers/net/dsa/mt7530.c
|
||||
+++ b/drivers/net/dsa/mt7530.c
|
||||
@@ -1093,6 +1093,7 @@ static int
|
||||
@@ -1254,6 +1254,7 @@ static int
|
||||
mt7530_port_enable(struct dsa_switch *ds, int port,
|
||||
struct phy_device *phy)
|
||||
{
|
||||
@@ -29,7 +29,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
struct mt7530_priv *priv = ds->priv;
|
||||
|
||||
mutex_lock(&priv->reg_mutex);
|
||||
@@ -1101,7 +1102,11 @@ mt7530_port_enable(struct dsa_switch *ds
|
||||
@@ -1262,7 +1263,11 @@ mt7530_port_enable(struct dsa_switch *ds
|
||||
* restore the port matrix if the port is the member of a certain
|
||||
* bridge.
|
||||
*/
|
||||
@@ -42,7 +42,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
priv->ports[port].enable = true;
|
||||
mt7530_rmw(priv, MT7530_PCR_P(port), PCR_MATRIX_MASK,
|
||||
priv->ports[port].pm);
|
||||
@@ -1249,7 +1254,8 @@ mt7530_port_bridge_join(struct dsa_switc
|
||||
@@ -1410,7 +1415,8 @@ mt7530_port_bridge_join(struct dsa_switc
|
||||
struct net_device *bridge)
|
||||
{
|
||||
struct dsa_port *dp = dsa_to_port(ds, port), *other_dp;
|
||||
@@ -52,7 +52,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
struct mt7530_priv *priv = ds->priv;
|
||||
|
||||
mutex_lock(&priv->reg_mutex);
|
||||
@@ -1326,9 +1332,12 @@ mt7530_port_set_vlan_unaware(struct dsa_
|
||||
@@ -1487,9 +1493,12 @@ mt7530_port_set_vlan_unaware(struct dsa_
|
||||
* the CPU port get out of VLAN filtering mode.
|
||||
*/
|
||||
if (all_user_ports_removed) {
|
||||
@@ -67,7 +67,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
| PVC_EG_TAG(MT7530_VLAN_EG_CONSISTENT));
|
||||
}
|
||||
}
|
||||
@@ -1378,6 +1387,7 @@ mt7530_port_bridge_leave(struct dsa_swit
|
||||
@@ -1539,6 +1548,7 @@ mt7530_port_bridge_leave(struct dsa_swit
|
||||
struct net_device *bridge)
|
||||
{
|
||||
struct dsa_port *dp = dsa_to_port(ds, port), *other_dp;
|
||||
@@ -75,7 +75,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
struct mt7530_priv *priv = ds->priv;
|
||||
|
||||
mutex_lock(&priv->reg_mutex);
|
||||
@@ -1406,8 +1416,8 @@ mt7530_port_bridge_leave(struct dsa_swit
|
||||
@@ -1567,8 +1577,8 @@ mt7530_port_bridge_leave(struct dsa_swit
|
||||
*/
|
||||
if (priv->ports[port].enable)
|
||||
mt7530_rmw(priv, MT7530_PCR_P(port), PCR_MATRIX_MASK,
|
||||
@@ -86,7 +86,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
|
||||
/* When a port is removed from the bridge, the port would be set up
|
||||
* back to the default as is at initial boot which is a VLAN-unaware
|
||||
@@ -1570,6 +1580,9 @@ static int
|
||||
@@ -1731,6 +1741,9 @@ static int
|
||||
mt7530_port_vlan_filtering(struct dsa_switch *ds, int port, bool vlan_filtering,
|
||||
struct netlink_ext_ack *extack)
|
||||
{
|
||||
@@ -96,7 +96,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
if (vlan_filtering) {
|
||||
/* The port is being kept as VLAN-unaware port when bridge is
|
||||
* set up with vlan_filtering not being set, Otherwise, the
|
||||
@@ -1577,7 +1590,7 @@ mt7530_port_vlan_filtering(struct dsa_sw
|
||||
@@ -1738,7 +1751,7 @@ mt7530_port_vlan_filtering(struct dsa_sw
|
||||
* for becoming a VLAN-aware port.
|
||||
*/
|
||||
mt7530_port_set_vlan_aware(ds, port);
|
||||
|
||||
+7
-7
@@ -19,7 +19,7 @@ Signed-off-by: David S. Miller <davem@davemloft.net>
|
||||
|
||||
--- a/drivers/net/dsa/mt7530.c
|
||||
+++ b/drivers/net/dsa/mt7530.c
|
||||
@@ -2791,9 +2791,6 @@ mt7531_mac_config(struct dsa_switch *ds,
|
||||
@@ -2952,9 +2952,6 @@ mt7531_mac_config(struct dsa_switch *ds,
|
||||
case PHY_INTERFACE_MODE_NA:
|
||||
case PHY_INTERFACE_MODE_1000BASEX:
|
||||
case PHY_INTERFACE_MODE_2500BASEX:
|
||||
@@ -29,7 +29,7 @@ Signed-off-by: David S. Miller <davem@davemloft.net>
|
||||
return mt7531_sgmii_setup_mode_force(priv, port, interface);
|
||||
default:
|
||||
return -EINVAL;
|
||||
@@ -2869,13 +2866,6 @@ unsupported:
|
||||
@@ -3030,13 +3027,6 @@ unsupported:
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ Signed-off-by: David S. Miller <davem@davemloft.net>
|
||||
mcr_cur = mt7530_read(priv, MT7530_PMCR_P(port));
|
||||
mcr_new = mcr_cur;
|
||||
mcr_new &= ~PMCR_LINK_SETTINGS_MASK;
|
||||
@@ -3012,6 +3002,9 @@ static void mt753x_phylink_get_caps(stru
|
||||
@@ -3173,6 +3163,9 @@ static void mt753x_phylink_get_caps(stru
|
||||
config->mac_capabilities = MAC_ASYM_PAUSE | MAC_SYM_PAUSE |
|
||||
MAC_10 | MAC_100 | MAC_1000FD;
|
||||
|
||||
@@ -53,7 +53,7 @@ Signed-off-by: David S. Miller <davem@davemloft.net>
|
||||
/* This driver does not make use of the speed, duplex, pause or the
|
||||
* advertisement in its mac_config, so it is safe to mark this driver
|
||||
* as non-legacy.
|
||||
@@ -3077,6 +3070,7 @@ mt7531_sgmii_pcs_get_state_an(struct mt7
|
||||
@@ -3238,6 +3231,7 @@ mt7531_sgmii_pcs_get_state_an(struct mt7
|
||||
|
||||
status = mt7530_read(priv, MT7531_PCS_CONTROL_1(port));
|
||||
state->link = !!(status & MT7531_SGMII_LINK_STATUS);
|
||||
@@ -61,7 +61,7 @@ Signed-off-by: David S. Miller <davem@davemloft.net>
|
||||
if (state->interface == PHY_INTERFACE_MODE_SGMII &&
|
||||
(status & MT7531_SGMII_AN_ENABLE)) {
|
||||
val = mt7530_read(priv, MT7531_PCS_SPEED_ABILITY(port));
|
||||
@@ -3107,16 +3101,44 @@ mt7531_sgmii_pcs_get_state_an(struct mt7
|
||||
@@ -3268,16 +3262,44 @@ mt7531_sgmii_pcs_get_state_an(struct mt7
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -109,7 +109,7 @@ Signed-off-by: David S. Miller <davem@davemloft.net>
|
||||
}
|
||||
|
||||
static int mt753x_pcs_config(struct phylink_pcs *pcs, unsigned int mode,
|
||||
@@ -3157,6 +3179,8 @@ mt753x_setup(struct dsa_switch *ds)
|
||||
@@ -3318,6 +3340,8 @@ mt753x_setup(struct dsa_switch *ds)
|
||||
priv->pcs[i].pcs.ops = priv->info->pcs_ops;
|
||||
priv->pcs[i].priv = priv;
|
||||
priv->pcs[i].port = i;
|
||||
@@ -120,7 +120,7 @@ Signed-off-by: David S. Miller <davem@davemloft.net>
|
||||
ret = priv->info->sw_setup(ds);
|
||||
--- a/drivers/net/dsa/mt7530.h
|
||||
+++ b/drivers/net/dsa/mt7530.h
|
||||
@@ -400,6 +400,7 @@ enum mt7530_vlan_port_acc_frm {
|
||||
@@ -405,6 +405,7 @@ enum mt7530_vlan_port_acc_frm {
|
||||
#define MT7531_SGMII_LINK_STATUS BIT(18)
|
||||
#define MT7531_SGMII_AN_ENABLE BIT(12)
|
||||
#define MT7531_SGMII_AN_RESTART BIT(9)
|
||||
|
||||
+12
-12
@@ -81,7 +81,7 @@ Tested-by: Frank Wunderlich <frank-w@public-files.de>
|
||||
#include <linux/phylink.h>
|
||||
#include <linux/regmap.h>
|
||||
#include <linux/regulator/consumer.h>
|
||||
@@ -2643,128 +2644,11 @@ static int mt7531_rgmii_setup(struct mt7
|
||||
@@ -2804,128 +2805,11 @@ static int mt7531_rgmii_setup(struct mt7
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -210,7 +210,7 @@ Tested-by: Frank Wunderlich <frank-w@public-files.de>
|
||||
static int
|
||||
mt7531_mac_config(struct dsa_switch *ds, int port, unsigned int mode,
|
||||
phy_interface_t interface)
|
||||
@@ -2787,11 +2671,11 @@ mt7531_mac_config(struct dsa_switch *ds,
|
||||
@@ -2948,11 +2832,11 @@ mt7531_mac_config(struct dsa_switch *ds,
|
||||
phydev = dp->slave->phydev;
|
||||
return mt7531_rgmii_setup(priv, port, interface, phydev);
|
||||
case PHY_INTERFACE_MODE_SGMII:
|
||||
@@ -224,7 +224,7 @@ Tested-by: Frank Wunderlich <frank-w@public-files.de>
|
||||
default:
|
||||
return -EINVAL;
|
||||
}
|
||||
@@ -2816,11 +2700,11 @@ mt753x_phylink_mac_select_pcs(struct dsa
|
||||
@@ -2977,11 +2861,11 @@ mt753x_phylink_mac_select_pcs(struct dsa
|
||||
|
||||
switch (interface) {
|
||||
case PHY_INTERFACE_MODE_TRGMII:
|
||||
@@ -238,7 +238,7 @@ Tested-by: Frank Wunderlich <frank-w@public-files.de>
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
@@ -3061,86 +2945,6 @@ static void mt7530_pcs_get_state(struct
|
||||
@@ -3222,86 +3106,6 @@ static void mt7530_pcs_get_state(struct
|
||||
state->pause |= MLO_PAUSE_TX;
|
||||
}
|
||||
|
||||
@@ -325,7 +325,7 @@ Tested-by: Frank Wunderlich <frank-w@public-files.de>
|
||||
static int mt753x_pcs_config(struct phylink_pcs *pcs, unsigned int mode,
|
||||
phy_interface_t interface,
|
||||
const unsigned long *advertising,
|
||||
@@ -3160,18 +2964,57 @@ static const struct phylink_pcs_ops mt75
|
||||
@@ -3321,18 +3125,57 @@ static const struct phylink_pcs_ops mt75
|
||||
.pcs_an_restart = mt7530_pcs_an_restart,
|
||||
};
|
||||
|
||||
@@ -389,7 +389,7 @@ Tested-by: Frank Wunderlich <frank-w@public-files.de>
|
||||
int i, ret;
|
||||
|
||||
/* Initialise the PCS devices */
|
||||
@@ -3179,8 +3022,6 @@ mt753x_setup(struct dsa_switch *ds)
|
||||
@@ -3340,8 +3183,6 @@ mt753x_setup(struct dsa_switch *ds)
|
||||
priv->pcs[i].pcs.ops = priv->info->pcs_ops;
|
||||
priv->pcs[i].priv = priv;
|
||||
priv->pcs[i].port = i;
|
||||
@@ -398,7 +398,7 @@ Tested-by: Frank Wunderlich <frank-w@public-files.de>
|
||||
}
|
||||
|
||||
ret = priv->info->sw_setup(ds);
|
||||
@@ -3195,6 +3036,16 @@ mt753x_setup(struct dsa_switch *ds)
|
||||
@@ -3356,6 +3197,16 @@ mt753x_setup(struct dsa_switch *ds)
|
||||
if (ret && priv->irq)
|
||||
mt7530_free_irq_common(priv);
|
||||
|
||||
@@ -415,7 +415,7 @@ Tested-by: Frank Wunderlich <frank-w@public-files.de>
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -3286,7 +3137,7 @@ static const struct mt753x_info mt753x_t
|
||||
@@ -3447,7 +3298,7 @@ static const struct mt753x_info mt753x_t
|
||||
},
|
||||
[ID_MT7531] = {
|
||||
.id = ID_MT7531,
|
||||
@@ -424,7 +424,7 @@ Tested-by: Frank Wunderlich <frank-w@public-files.de>
|
||||
.sw_setup = mt7531_setup,
|
||||
.phy_read = mt7531_ind_phy_read,
|
||||
.phy_write = mt7531_ind_phy_write,
|
||||
@@ -3394,7 +3245,7 @@ static void
|
||||
@@ -3555,7 +3406,7 @@ static void
|
||||
mt7530_remove(struct mdio_device *mdiodev)
|
||||
{
|
||||
struct mt7530_priv *priv = dev_get_drvdata(&mdiodev->dev);
|
||||
@@ -433,7 +433,7 @@ Tested-by: Frank Wunderlich <frank-w@public-files.de>
|
||||
|
||||
if (!priv)
|
||||
return;
|
||||
@@ -3413,6 +3264,10 @@ mt7530_remove(struct mdio_device *mdiode
|
||||
@@ -3574,6 +3425,10 @@ mt7530_remove(struct mdio_device *mdiode
|
||||
mt7530_free_irq(priv);
|
||||
|
||||
dsa_unregister_switch(priv->ds);
|
||||
@@ -446,7 +446,7 @@ Tested-by: Frank Wunderlich <frank-w@public-files.de>
|
||||
dev_set_drvdata(&mdiodev->dev, NULL);
|
||||
--- a/drivers/net/dsa/mt7530.h
|
||||
+++ b/drivers/net/dsa/mt7530.h
|
||||
@@ -391,47 +391,8 @@ enum mt7530_vlan_port_acc_frm {
|
||||
@@ -396,47 +396,8 @@ enum mt7530_vlan_port_acc_frm {
|
||||
CCR_TX_OCT_CNT_BAD)
|
||||
|
||||
/* MT7531 SGMII register group */
|
||||
@@ -496,7 +496,7 @@ Tested-by: Frank Wunderlich <frank-w@public-files.de>
|
||||
|
||||
/* Register for system reset */
|
||||
#define MT7530_SYS_CTRL 0x7000
|
||||
@@ -730,13 +691,13 @@ struct mt7530_fdb {
|
||||
@@ -735,13 +696,13 @@ struct mt7530_fdb {
|
||||
* @pm: The matrix used to show all connections with the port.
|
||||
* @pvid: The VLAN specified is to be considered a PVID at ingress. Any
|
||||
* untagged frames will be assigned to the related VLAN.
|
||||
|
||||
+2
-2
@@ -18,7 +18,7 @@ Signed-off-by: David S. Miller <davem@davemloft.net>
|
||||
|
||||
--- a/drivers/net/dsa/mt7530.c
|
||||
+++ b/drivers/net/dsa/mt7530.c
|
||||
@@ -2996,26 +2996,56 @@ static const struct regmap_bus mt7531_re
|
||||
@@ -3157,26 +3157,56 @@ static const struct regmap_bus mt7531_re
|
||||
.reg_update_bits = mt7530_regmap_update_bits,
|
||||
};
|
||||
|
||||
@@ -88,7 +88,7 @@ Signed-off-by: David S. Miller <davem@davemloft.net>
|
||||
int i, ret;
|
||||
|
||||
/* Initialise the PCS devices */
|
||||
@@ -3037,15 +3067,11 @@ mt753x_setup(struct dsa_switch *ds)
|
||||
@@ -3198,15 +3228,11 @@ mt753x_setup(struct dsa_switch *ds)
|
||||
if (ret && priv->irq)
|
||||
mt7530_free_irq_common(priv);
|
||||
|
||||
|
||||
+3
-3
@@ -19,7 +19,7 @@ Signed-off-by: David S. Miller <davem@davemloft.net>
|
||||
|
||||
--- a/drivers/net/dsa/mt7530.c
|
||||
+++ b/drivers/net/dsa/mt7530.c
|
||||
@@ -2969,7 +2969,7 @@ static int mt7530_regmap_read(void *cont
|
||||
@@ -3130,7 +3130,7 @@ static int mt7530_regmap_read(void *cont
|
||||
{
|
||||
struct mt7530_priv *priv = context;
|
||||
|
||||
@@ -28,7 +28,7 @@ Signed-off-by: David S. Miller <davem@davemloft.net>
|
||||
return 0;
|
||||
};
|
||||
|
||||
@@ -2977,23 +2977,25 @@ static int mt7530_regmap_write(void *con
|
||||
@@ -3138,23 +3138,25 @@ static int mt7530_regmap_write(void *con
|
||||
{
|
||||
struct mt7530_priv *priv = context;
|
||||
|
||||
@@ -62,7 +62,7 @@ Signed-off-by: David S. Miller <davem@davemloft.net>
|
||||
};
|
||||
|
||||
static int
|
||||
@@ -3019,6 +3021,9 @@ mt7531_create_sgmii(struct mt7530_priv *
|
||||
@@ -3180,6 +3182,9 @@ mt7531_create_sgmii(struct mt7530_priv *
|
||||
mt7531_pcs_config[i]->reg_stride = 4;
|
||||
mt7531_pcs_config[i]->reg_base = MT7531_SGMII_REG_BASE(5 + i);
|
||||
mt7531_pcs_config[i]->max_register = 0x17c;
|
||||
|
||||
+7
-7
@@ -133,7 +133,7 @@ Signed-off-by: David S. Miller <davem@davemloft.net>
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -2965,22 +2986,6 @@ static const struct phylink_pcs_ops mt75
|
||||
@@ -3126,22 +3147,6 @@ static const struct phylink_pcs_ops mt75
|
||||
.pcs_an_restart = mt7530_pcs_an_restart,
|
||||
};
|
||||
|
||||
@@ -156,7 +156,7 @@ Signed-off-by: David S. Miller <davem@davemloft.net>
|
||||
static void
|
||||
mt7530_mdio_regmap_lock(void *mdio_lock)
|
||||
{
|
||||
@@ -2993,7 +2998,7 @@ mt7530_mdio_regmap_unlock(void *mdio_loc
|
||||
@@ -3154,7 +3159,7 @@ mt7530_mdio_regmap_unlock(void *mdio_loc
|
||||
mutex_unlock(mdio_lock);
|
||||
}
|
||||
|
||||
@@ -165,7 +165,7 @@ Signed-off-by: David S. Miller <davem@davemloft.net>
|
||||
.reg_write = mt7530_regmap_write,
|
||||
.reg_read = mt7530_regmap_read,
|
||||
};
|
||||
@@ -3026,7 +3031,7 @@ mt7531_create_sgmii(struct mt7530_priv *
|
||||
@@ -3187,7 +3192,7 @@ mt7531_create_sgmii(struct mt7530_priv *
|
||||
mt7531_pcs_config[i]->lock_arg = &priv->bus->mdio_lock;
|
||||
|
||||
regmap = devm_regmap_init(priv->dev,
|
||||
@@ -174,7 +174,7 @@ Signed-off-by: David S. Miller <davem@davemloft.net>
|
||||
mt7531_pcs_config[i]);
|
||||
if (IS_ERR(regmap)) {
|
||||
ret = PTR_ERR(regmap);
|
||||
@@ -3191,6 +3196,7 @@ MODULE_DEVICE_TABLE(of, mt7530_of_match)
|
||||
@@ -3352,6 +3357,7 @@ MODULE_DEVICE_TABLE(of, mt7530_of_match)
|
||||
static int
|
||||
mt7530_probe(struct mdio_device *mdiodev)
|
||||
{
|
||||
@@ -182,7 +182,7 @@ Signed-off-by: David S. Miller <davem@davemloft.net>
|
||||
struct mt7530_priv *priv;
|
||||
struct device_node *dn;
|
||||
|
||||
@@ -3270,6 +3276,21 @@ mt7530_probe(struct mdio_device *mdiodev
|
||||
@@ -3431,6 +3437,21 @@ mt7530_probe(struct mdio_device *mdiodev
|
||||
mutex_init(&priv->reg_mutex);
|
||||
dev_set_drvdata(&mdiodev->dev, priv);
|
||||
|
||||
@@ -206,7 +206,7 @@ Signed-off-by: David S. Miller <davem@davemloft.net>
|
||||
|
||||
--- a/drivers/net/dsa/mt7530.h
|
||||
+++ b/drivers/net/dsa/mt7530.h
|
||||
@@ -774,6 +774,7 @@ struct mt753x_info {
|
||||
@@ -779,6 +779,7 @@ struct mt753x_info {
|
||||
* @dev: The device pointer
|
||||
* @ds: The pointer to the dsa core structure
|
||||
* @bus: The bus used for the device and built-in PHY
|
||||
@@ -214,7 +214,7 @@ Signed-off-by: David S. Miller <davem@davemloft.net>
|
||||
* @rstc: The pointer to reset control used by MCM
|
||||
* @core_pwr: The power supplied into the core
|
||||
* @io_pwr: The power supplied into the I/O
|
||||
@@ -794,6 +795,7 @@ struct mt7530_priv {
|
||||
@@ -799,6 +800,7 @@ struct mt7530_priv {
|
||||
struct device *dev;
|
||||
struct dsa_switch *ds;
|
||||
struct mii_bus *bus;
|
||||
|
||||
+3
-3
@@ -18,7 +18,7 @@ Signed-off-by: David S. Miller <davem@davemloft.net>
|
||||
|
||||
--- a/drivers/net/dsa/mt7530.c
|
||||
+++ b/drivers/net/dsa/mt7530.c
|
||||
@@ -3077,12 +3077,6 @@ mt753x_setup(struct dsa_switch *ds)
|
||||
@@ -3238,12 +3238,6 @@ mt753x_setup(struct dsa_switch *ds)
|
||||
if (ret && priv->irq)
|
||||
mt7530_free_irq_common(priv);
|
||||
|
||||
@@ -31,7 +31,7 @@ Signed-off-by: David S. Miller <davem@davemloft.net>
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -3199,6 +3193,7 @@ mt7530_probe(struct mdio_device *mdiodev
|
||||
@@ -3360,6 +3354,7 @@ mt7530_probe(struct mdio_device *mdiodev
|
||||
static struct regmap_config *regmap_config;
|
||||
struct mt7530_priv *priv;
|
||||
struct device_node *dn;
|
||||
@@ -39,7 +39,7 @@ Signed-off-by: David S. Miller <davem@davemloft.net>
|
||||
|
||||
dn = mdiodev->dev.of_node;
|
||||
|
||||
@@ -3291,6 +3286,12 @@ mt7530_probe(struct mdio_device *mdiodev
|
||||
@@ -3452,6 +3447,12 @@ mt7530_probe(struct mdio_device *mdiodev
|
||||
if (IS_ERR(priv->regmap))
|
||||
return PTR_ERR(priv->regmap);
|
||||
|
||||
|
||||
+6
-6
@@ -214,7 +214,7 @@ Signed-off-by: David S. Miller <davem@davemloft.net>
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -1162,7 +1162,6 @@ static int
|
||||
@@ -1323,7 +1323,6 @@ static int
|
||||
mt7530_port_change_mtu(struct dsa_switch *ds, int port, int new_mtu)
|
||||
{
|
||||
struct mt7530_priv *priv = ds->priv;
|
||||
@@ -222,7 +222,7 @@ Signed-off-by: David S. Miller <davem@davemloft.net>
|
||||
int length;
|
||||
u32 val;
|
||||
|
||||
@@ -1173,7 +1172,7 @@ mt7530_port_change_mtu(struct dsa_switch
|
||||
@@ -1334,7 +1333,7 @@ mt7530_port_change_mtu(struct dsa_switch
|
||||
if (!dsa_is_cpu_port(ds, port))
|
||||
return 0;
|
||||
|
||||
@@ -231,7 +231,7 @@ Signed-off-by: David S. Miller <davem@davemloft.net>
|
||||
|
||||
val = mt7530_mii_read(priv, MT7530_GMACCR);
|
||||
val &= ~MAX_RX_PKT_LEN_MASK;
|
||||
@@ -1194,7 +1193,7 @@ mt7530_port_change_mtu(struct dsa_switch
|
||||
@@ -1355,7 +1354,7 @@ mt7530_port_change_mtu(struct dsa_switch
|
||||
|
||||
mt7530_mii_write(priv, MT7530_GMACCR, val);
|
||||
|
||||
@@ -240,7 +240,7 @@ Signed-off-by: David S. Miller <davem@davemloft.net>
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -1990,10 +1989,10 @@ mt7530_irq_thread_fn(int irq, void *dev_
|
||||
@@ -2151,10 +2150,10 @@ mt7530_irq_thread_fn(int irq, void *dev_
|
||||
u32 val;
|
||||
int p;
|
||||
|
||||
@@ -253,7 +253,7 @@ Signed-off-by: David S. Miller <davem@davemloft.net>
|
||||
|
||||
for (p = 0; p < MT7530_NUM_PHYS; p++) {
|
||||
if (BIT(p) & val) {
|
||||
@@ -2029,7 +2028,7 @@ mt7530_irq_bus_lock(struct irq_data *d)
|
||||
@@ -2190,7 +2189,7 @@ mt7530_irq_bus_lock(struct irq_data *d)
|
||||
{
|
||||
struct mt7530_priv *priv = irq_data_get_irq_chip_data(d);
|
||||
|
||||
@@ -262,7 +262,7 @@ Signed-off-by: David S. Miller <davem@davemloft.net>
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -2038,7 +2037,7 @@ mt7530_irq_bus_sync_unlock(struct irq_da
|
||||
@@ -2199,7 +2198,7 @@ mt7530_irq_bus_sync_unlock(struct irq_da
|
||||
struct mt7530_priv *priv = irq_data_get_irq_chip_data(d);
|
||||
|
||||
mt7530_mii_write(priv, MT7530_SYS_INT_EN, priv->irq_enable);
|
||||
|
||||
+1
-1
@@ -48,7 +48,7 @@ Signed-off-by: David S. Miller <davem@davemloft.net>
|
||||
struct mt7530_priv *priv = ds->priv;
|
||||
--- a/drivers/net/dsa/mt7530.h
|
||||
+++ b/drivers/net/dsa/mt7530.h
|
||||
@@ -709,24 +709,6 @@ enum p5_interface_select {
|
||||
@@ -714,24 +714,6 @@ enum p5_interface_select {
|
||||
P5_INTF_SEL_GMAC5_SGMII,
|
||||
};
|
||||
|
||||
|
||||
+3
-3
@@ -17,7 +17,7 @@ Signed-off-by: David S. Miller <davem@davemloft.net>
|
||||
|
||||
--- a/drivers/net/dsa/mt7530.c
|
||||
+++ b/drivers/net/dsa/mt7530.c
|
||||
@@ -3205,44 +3205,21 @@ static const struct of_device_id mt7530_
|
||||
@@ -3366,44 +3366,21 @@ static const struct of_device_id mt7530_
|
||||
MODULE_DEVICE_TABLE(of, mt7530_of_match);
|
||||
|
||||
static int
|
||||
@@ -67,7 +67,7 @@ Signed-off-by: David S. Miller <davem@davemloft.net>
|
||||
if (!priv->info)
|
||||
return -EINVAL;
|
||||
|
||||
@@ -3256,23 +3233,53 @@ mt7530_probe(struct mdio_device *mdiodev
|
||||
@@ -3417,23 +3394,53 @@ mt7530_probe(struct mdio_device *mdiodev
|
||||
return -EINVAL;
|
||||
|
||||
priv->id = priv->info->id;
|
||||
@@ -131,7 +131,7 @@ Signed-off-by: David S. Miller <davem@davemloft.net>
|
||||
priv->reset = devm_gpiod_get_optional(&mdiodev->dev, "reset",
|
||||
GPIOD_OUT_LOW);
|
||||
if (IS_ERR(priv->reset)) {
|
||||
@@ -3281,12 +3288,15 @@ mt7530_probe(struct mdio_device *mdiodev
|
||||
@@ -3442,12 +3449,15 @@ mt7530_probe(struct mdio_device *mdiodev
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -17,7 +17,7 @@ Signed-off-by: David S. Miller <davem@davemloft.net>
|
||||
|
||||
--- a/drivers/net/dsa/mt7530.c
|
||||
+++ b/drivers/net/dsa/mt7530.c
|
||||
@@ -3323,6 +3323,17 @@ mt7530_probe(struct mdio_device *mdiodev
|
||||
@@ -3484,6 +3484,17 @@ mt7530_probe(struct mdio_device *mdiodev
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -35,7 +35,7 @@ Signed-off-by: David S. Miller <davem@davemloft.net>
|
||||
mt7530_remove(struct mdio_device *mdiodev)
|
||||
{
|
||||
struct mt7530_priv *priv = dev_get_drvdata(&mdiodev->dev);
|
||||
@@ -3341,16 +3352,11 @@ mt7530_remove(struct mdio_device *mdiode
|
||||
@@ -3502,16 +3513,11 @@ mt7530_remove(struct mdio_device *mdiode
|
||||
dev_err(priv->dev, "Failed to disable io pwr: %d\n",
|
||||
ret);
|
||||
|
||||
|
||||
+7
-7
@@ -416,7 +416,7 @@ Signed-off-by: David S. Miller <davem@davemloft.net>
|
||||
static u32
|
||||
mt7530_mii_read(struct mt7530_priv *priv, u32 reg)
|
||||
{
|
||||
@@ -3003,72 +2954,6 @@ static const struct phylink_pcs_ops mt75
|
||||
@@ -3164,72 +3115,6 @@ static const struct phylink_pcs_ops mt75
|
||||
.pcs_an_restart = mt7530_pcs_an_restart,
|
||||
};
|
||||
|
||||
@@ -489,7 +489,7 @@ Signed-off-by: David S. Miller <davem@davemloft.net>
|
||||
static int
|
||||
mt753x_setup(struct dsa_switch *ds)
|
||||
{
|
||||
@@ -3127,7 +3012,7 @@ static int mt753x_set_mac_eee(struct dsa
|
||||
@@ -3288,7 +3173,7 @@ static int mt753x_set_mac_eee(struct dsa
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -498,7 +498,7 @@ Signed-off-by: David S. Miller <davem@davemloft.net>
|
||||
.get_tag_protocol = mtk_get_tag_protocol,
|
||||
.setup = mt753x_setup,
|
||||
.get_strings = mt7530_get_strings,
|
||||
@@ -3161,8 +3046,9 @@ static const struct dsa_switch_ops mt753
|
||||
@@ -3322,8 +3207,9 @@ static const struct dsa_switch_ops mt753
|
||||
.get_mac_eee = mt753x_get_mac_eee,
|
||||
.set_mac_eee = mt753x_set_mac_eee,
|
||||
};
|
||||
@@ -509,7 +509,7 @@ Signed-off-by: David S. Miller <davem@davemloft.net>
|
||||
[ID_MT7621] = {
|
||||
.id = ID_MT7621,
|
||||
.pcs_ops = &mt7530_pcs_ops,
|
||||
@@ -3195,16 +3081,9 @@ static const struct mt753x_info mt753x_t
|
||||
@@ -3356,16 +3242,9 @@ static const struct mt753x_info mt753x_t
|
||||
.mac_port_config = mt7531_mac_config,
|
||||
},
|
||||
};
|
||||
@@ -528,7 +528,7 @@ Signed-off-by: David S. Miller <davem@davemloft.net>
|
||||
mt7530_probe_common(struct mt7530_priv *priv)
|
||||
{
|
||||
struct device *dev = priv->dev;
|
||||
@@ -3241,88 +3120,9 @@ mt7530_probe_common(struct mt7530_priv *
|
||||
@@ -3402,88 +3281,9 @@ mt7530_probe_common(struct mt7530_priv *
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -619,7 +619,7 @@ Signed-off-by: David S. Miller <davem@davemloft.net>
|
||||
mt7530_remove_common(struct mt7530_priv *priv)
|
||||
{
|
||||
if (priv->irq)
|
||||
@@ -3333,57 +3133,6 @@ mt7530_remove_common(struct mt7530_priv
|
||||
@@ -3494,57 +3294,6 @@ mt7530_remove_common(struct mt7530_priv
|
||||
mutex_destroy(&priv->reg_mutex);
|
||||
}
|
||||
|
||||
@@ -679,7 +679,7 @@ Signed-off-by: David S. Miller <davem@davemloft.net>
|
||||
MODULE_LICENSE("GPL");
|
||||
--- a/drivers/net/dsa/mt7530.h
|
||||
+++ b/drivers/net/dsa/mt7530.h
|
||||
@@ -834,4 +834,10 @@ static inline void INIT_MT7530_DUMMY_POL
|
||||
@@ -839,4 +839,10 @@ static inline void INIT_MT7530_DUMMY_POL
|
||||
p->reg = reg;
|
||||
}
|
||||
|
||||
|
||||
+10
-10
@@ -184,7 +184,7 @@ Signed-off-by: David S. Miller <davem@davemloft.net>
|
||||
+MODULE_LICENSE("GPL");
|
||||
--- a/drivers/net/dsa/mt7530.c
|
||||
+++ b/drivers/net/dsa/mt7530.c
|
||||
@@ -2037,6 +2037,47 @@ static const struct irq_domain_ops mt753
|
||||
@@ -2198,6 +2198,47 @@ static const struct irq_domain_ops mt753
|
||||
};
|
||||
|
||||
static void
|
||||
@@ -232,7 +232,7 @@ Signed-off-by: David S. Miller <davem@davemloft.net>
|
||||
mt7530_setup_mdio_irq(struct mt7530_priv *priv)
|
||||
{
|
||||
struct dsa_switch *ds = priv->ds;
|
||||
@@ -2070,8 +2111,15 @@ mt7530_setup_irq(struct mt7530_priv *pri
|
||||
@@ -2231,8 +2272,15 @@ mt7530_setup_irq(struct mt7530_priv *pri
|
||||
return priv->irq ? : -EINVAL;
|
||||
}
|
||||
|
||||
@@ -250,7 +250,7 @@ Signed-off-by: David S. Miller <davem@davemloft.net>
|
||||
if (!priv->irq_domain) {
|
||||
dev_err(dev, "failed to create IRQ domain\n");
|
||||
return -ENOMEM;
|
||||
@@ -2566,6 +2614,25 @@ static void mt7531_mac_port_get_caps(str
|
||||
@@ -2727,6 +2775,25 @@ static void mt7531_mac_port_get_caps(str
|
||||
}
|
||||
}
|
||||
|
||||
@@ -276,7 +276,7 @@ Signed-off-by: David S. Miller <davem@davemloft.net>
|
||||
static int
|
||||
mt753x_pad_setup(struct dsa_switch *ds, const struct phylink_link_state *state)
|
||||
{
|
||||
@@ -2642,6 +2709,17 @@ static bool mt753x_is_mac_port(u32 port)
|
||||
@@ -2803,6 +2870,17 @@ static bool mt753x_is_mac_port(u32 port)
|
||||
}
|
||||
|
||||
static int
|
||||
@@ -294,7 +294,7 @@ Signed-off-by: David S. Miller <davem@davemloft.net>
|
||||
mt7531_mac_config(struct dsa_switch *ds, int port, unsigned int mode,
|
||||
phy_interface_t interface)
|
||||
{
|
||||
@@ -2711,7 +2789,8 @@ mt753x_phylink_mac_config(struct dsa_swi
|
||||
@@ -2872,7 +2950,8 @@ mt753x_phylink_mac_config(struct dsa_swi
|
||||
|
||||
switch (port) {
|
||||
case 0 ... 4: /* Internal phy */
|
||||
@@ -304,7 +304,7 @@ Signed-off-by: David S. Miller <davem@davemloft.net>
|
||||
goto unsupported;
|
||||
break;
|
||||
case 5: /* 2nd cpu port with phy of port 0 or 4 / external phy */
|
||||
@@ -2789,7 +2868,8 @@ static void mt753x_phylink_mac_link_up(s
|
||||
@@ -2950,7 +3029,8 @@ static void mt753x_phylink_mac_link_up(s
|
||||
/* MT753x MAC works in 1G full duplex mode for all up-clocked
|
||||
* variants.
|
||||
*/
|
||||
@@ -314,7 +314,7 @@ Signed-off-by: David S. Miller <davem@davemloft.net>
|
||||
(phy_interface_mode_is_8023z(interface))) {
|
||||
speed = SPEED_1000;
|
||||
duplex = DUPLEX_FULL;
|
||||
@@ -2869,6 +2949,21 @@ mt7531_cpu_port_config(struct dsa_switch
|
||||
@@ -3030,6 +3110,21 @@ mt7531_cpu_port_config(struct dsa_switch
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -336,7 +336,7 @@ Signed-off-by: David S. Miller <davem@davemloft.net>
|
||||
static void mt753x_phylink_get_caps(struct dsa_switch *ds, int port,
|
||||
struct phylink_config *config)
|
||||
{
|
||||
@@ -3014,6 +3109,27 @@ static int mt753x_set_mac_eee(struct dsa
|
||||
@@ -3175,6 +3270,27 @@ static int mt753x_set_mac_eee(struct dsa
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -364,7 +364,7 @@ Signed-off-by: David S. Miller <davem@davemloft.net>
|
||||
const struct dsa_switch_ops mt7530_switch_ops = {
|
||||
.get_tag_protocol = mtk_get_tag_protocol,
|
||||
.setup = mt753x_setup,
|
||||
@@ -3082,6 +3198,17 @@ const struct mt753x_info mt753x_table[]
|
||||
@@ -3243,6 +3359,17 @@ const struct mt753x_info mt753x_table[]
|
||||
.mac_port_get_caps = mt7531_mac_port_get_caps,
|
||||
.mac_port_config = mt7531_mac_config,
|
||||
},
|
||||
@@ -407,7 +407,7 @@ Signed-off-by: David S. Miller <davem@davemloft.net>
|
||||
MT7531_MIRROR_MASK : MIRROR_MASK)
|
||||
|
||||
/* Registers for BPDU and PAE frame control*/
|
||||
@@ -322,9 +323,8 @@ enum mt7530_vlan_port_acc_frm {
|
||||
@@ -327,9 +328,8 @@ enum mt7530_vlan_port_acc_frm {
|
||||
MT7531_FORCE_DPX | \
|
||||
MT7531_FORCE_RX_FC | \
|
||||
MT7531_FORCE_TX_FC)
|
||||
|
||||
+4
-4
@@ -73,7 +73,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
}
|
||||
--- a/drivers/net/dsa/mt7530.c
|
||||
+++ b/drivers/net/dsa/mt7530.c
|
||||
@@ -3076,6 +3076,12 @@ mt753x_setup(struct dsa_switch *ds)
|
||||
@@ -3237,6 +3237,12 @@ mt753x_setup(struct dsa_switch *ds)
|
||||
if (ret && priv->irq)
|
||||
mt7530_free_irq_common(priv);
|
||||
|
||||
@@ -88,7 +88,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
|
||||
--- a/drivers/net/dsa/mt7530.h
|
||||
+++ b/drivers/net/dsa/mt7530.h
|
||||
@@ -768,10 +768,10 @@ struct mt753x_info {
|
||||
@@ -773,10 +773,10 @@ struct mt753x_info {
|
||||
* registers
|
||||
* @p6_interface Holding the current port 6 interface
|
||||
* @p5_intf_sel: Holding the current port 5 interface select
|
||||
@@ -100,7 +100,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
*/
|
||||
struct mt7530_priv {
|
||||
struct device *dev;
|
||||
@@ -790,7 +790,6 @@ struct mt7530_priv {
|
||||
@@ -795,7 +795,6 @@ struct mt7530_priv {
|
||||
unsigned int p5_intf_sel;
|
||||
u8 mirror_rx;
|
||||
u8 mirror_tx;
|
||||
@@ -108,7 +108,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
struct mt7530_port ports[MT7530_NUM_PORTS];
|
||||
struct mt753x_pcs pcs[MT7530_NUM_PORTS];
|
||||
/* protect among processes for registers access*/
|
||||
@@ -798,6 +797,7 @@ struct mt7530_priv {
|
||||
@@ -803,6 +802,7 @@ struct mt7530_priv {
|
||||
int irq;
|
||||
struct irq_domain *irq_domain;
|
||||
u32 irq_enable;
|
||||
|
||||
+12
-12
@@ -81,7 +81,7 @@ Tested-by: Frank Wunderlich <frank-w@public-files.de>
|
||||
#include <linux/phylink.h>
|
||||
#include <linux/regmap.h>
|
||||
#include <linux/regulator/consumer.h>
|
||||
@@ -2651,128 +2652,11 @@ static int mt7531_rgmii_setup(struct mt7
|
||||
@@ -2812,128 +2813,11 @@ static int mt7531_rgmii_setup(struct mt7
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -210,7 +210,7 @@ Tested-by: Frank Wunderlich <frank-w@public-files.de>
|
||||
static int
|
||||
mt7531_mac_config(struct dsa_switch *ds, int port, unsigned int mode,
|
||||
phy_interface_t interface)
|
||||
@@ -2795,11 +2679,11 @@ mt7531_mac_config(struct dsa_switch *ds,
|
||||
@@ -2956,11 +2840,11 @@ mt7531_mac_config(struct dsa_switch *ds,
|
||||
phydev = dp->slave->phydev;
|
||||
return mt7531_rgmii_setup(priv, port, interface, phydev);
|
||||
case PHY_INTERFACE_MODE_SGMII:
|
||||
@@ -224,7 +224,7 @@ Tested-by: Frank Wunderlich <frank-w@public-files.de>
|
||||
default:
|
||||
return -EINVAL;
|
||||
}
|
||||
@@ -2824,11 +2708,11 @@ mt753x_phylink_mac_select_pcs(struct dsa
|
||||
@@ -2985,11 +2869,11 @@ mt753x_phylink_mac_select_pcs(struct dsa
|
||||
|
||||
switch (interface) {
|
||||
case PHY_INTERFACE_MODE_TRGMII:
|
||||
@@ -238,7 +238,7 @@ Tested-by: Frank Wunderlich <frank-w@public-files.de>
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
@@ -3069,86 +2953,6 @@ static void mt7530_pcs_get_state(struct
|
||||
@@ -3230,86 +3114,6 @@ static void mt7530_pcs_get_state(struct
|
||||
state->pause |= MLO_PAUSE_TX;
|
||||
}
|
||||
|
||||
@@ -325,7 +325,7 @@ Tested-by: Frank Wunderlich <frank-w@public-files.de>
|
||||
static int mt753x_pcs_config(struct phylink_pcs *pcs, unsigned int mode,
|
||||
phy_interface_t interface,
|
||||
const unsigned long *advertising,
|
||||
@@ -3168,18 +2972,57 @@ static const struct phylink_pcs_ops mt75
|
||||
@@ -3329,18 +3133,57 @@ static const struct phylink_pcs_ops mt75
|
||||
.pcs_an_restart = mt7530_pcs_an_restart,
|
||||
};
|
||||
|
||||
@@ -389,7 +389,7 @@ Tested-by: Frank Wunderlich <frank-w@public-files.de>
|
||||
int i, ret;
|
||||
|
||||
/* Initialise the PCS devices */
|
||||
@@ -3187,8 +3030,6 @@ mt753x_setup(struct dsa_switch *ds)
|
||||
@@ -3348,8 +3191,6 @@ mt753x_setup(struct dsa_switch *ds)
|
||||
priv->pcs[i].pcs.ops = priv->info->pcs_ops;
|
||||
priv->pcs[i].priv = priv;
|
||||
priv->pcs[i].port = i;
|
||||
@@ -398,7 +398,7 @@ Tested-by: Frank Wunderlich <frank-w@public-files.de>
|
||||
}
|
||||
|
||||
ret = priv->info->sw_setup(ds);
|
||||
@@ -3203,6 +3044,16 @@ mt753x_setup(struct dsa_switch *ds)
|
||||
@@ -3364,6 +3205,16 @@ mt753x_setup(struct dsa_switch *ds)
|
||||
if (ret && priv->irq)
|
||||
mt7530_free_irq_common(priv);
|
||||
|
||||
@@ -415,7 +415,7 @@ Tested-by: Frank Wunderlich <frank-w@public-files.de>
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -3294,7 +3145,7 @@ static const struct mt753x_info mt753x_t
|
||||
@@ -3455,7 +3306,7 @@ static const struct mt753x_info mt753x_t
|
||||
},
|
||||
[ID_MT7531] = {
|
||||
.id = ID_MT7531,
|
||||
@@ -424,7 +424,7 @@ Tested-by: Frank Wunderlich <frank-w@public-files.de>
|
||||
.sw_setup = mt7531_setup,
|
||||
.phy_read = mt7531_ind_phy_read,
|
||||
.phy_write = mt7531_ind_phy_write,
|
||||
@@ -3402,7 +3253,7 @@ static void
|
||||
@@ -3563,7 +3414,7 @@ static void
|
||||
mt7530_remove(struct mdio_device *mdiodev)
|
||||
{
|
||||
struct mt7530_priv *priv = dev_get_drvdata(&mdiodev->dev);
|
||||
@@ -433,7 +433,7 @@ Tested-by: Frank Wunderlich <frank-w@public-files.de>
|
||||
|
||||
if (!priv)
|
||||
return;
|
||||
@@ -3421,6 +3272,10 @@ mt7530_remove(struct mdio_device *mdiode
|
||||
@@ -3582,6 +3433,10 @@ mt7530_remove(struct mdio_device *mdiode
|
||||
mt7530_free_irq(priv);
|
||||
|
||||
dsa_unregister_switch(priv->ds);
|
||||
@@ -446,7 +446,7 @@ Tested-by: Frank Wunderlich <frank-w@public-files.de>
|
||||
|
||||
--- a/drivers/net/dsa/mt7530.h
|
||||
+++ b/drivers/net/dsa/mt7530.h
|
||||
@@ -391,47 +391,8 @@ enum mt7530_vlan_port_acc_frm {
|
||||
@@ -396,47 +396,8 @@ enum mt7530_vlan_port_acc_frm {
|
||||
CCR_TX_OCT_CNT_BAD)
|
||||
|
||||
/* MT7531 SGMII register group */
|
||||
@@ -496,7 +496,7 @@ Tested-by: Frank Wunderlich <frank-w@public-files.de>
|
||||
|
||||
/* Register for system reset */
|
||||
#define MT7530_SYS_CTRL 0x7000
|
||||
@@ -730,13 +691,13 @@ struct mt7530_fdb {
|
||||
@@ -735,13 +696,13 @@ struct mt7530_fdb {
|
||||
* @pm: The matrix used to show all connections with the port.
|
||||
* @pvid: The VLAN specified is to be considered a PVID at ingress. Any
|
||||
* untagged frames will be assigned to the related VLAN.
|
||||
|
||||
+2
-2
@@ -18,7 +18,7 @@ Signed-off-by: David S. Miller <davem@davemloft.net>
|
||||
|
||||
--- a/drivers/net/dsa/mt7530.c
|
||||
+++ b/drivers/net/dsa/mt7530.c
|
||||
@@ -3004,26 +3004,56 @@ static const struct regmap_bus mt7531_re
|
||||
@@ -3165,26 +3165,56 @@ static const struct regmap_bus mt7531_re
|
||||
.reg_update_bits = mt7530_regmap_update_bits,
|
||||
};
|
||||
|
||||
@@ -88,7 +88,7 @@ Signed-off-by: David S. Miller <davem@davemloft.net>
|
||||
int i, ret;
|
||||
|
||||
/* Initialise the PCS devices */
|
||||
@@ -3045,15 +3075,11 @@ mt753x_setup(struct dsa_switch *ds)
|
||||
@@ -3206,15 +3236,11 @@ mt753x_setup(struct dsa_switch *ds)
|
||||
if (ret && priv->irq)
|
||||
mt7530_free_irq_common(priv);
|
||||
|
||||
|
||||
+3
-3
@@ -19,7 +19,7 @@ Signed-off-by: David S. Miller <davem@davemloft.net>
|
||||
|
||||
--- a/drivers/net/dsa/mt7530.c
|
||||
+++ b/drivers/net/dsa/mt7530.c
|
||||
@@ -2977,7 +2977,7 @@ static int mt7530_regmap_read(void *cont
|
||||
@@ -3138,7 +3138,7 @@ static int mt7530_regmap_read(void *cont
|
||||
{
|
||||
struct mt7530_priv *priv = context;
|
||||
|
||||
@@ -28,7 +28,7 @@ Signed-off-by: David S. Miller <davem@davemloft.net>
|
||||
return 0;
|
||||
};
|
||||
|
||||
@@ -2985,23 +2985,25 @@ static int mt7530_regmap_write(void *con
|
||||
@@ -3146,23 +3146,25 @@ static int mt7530_regmap_write(void *con
|
||||
{
|
||||
struct mt7530_priv *priv = context;
|
||||
|
||||
@@ -62,7 +62,7 @@ Signed-off-by: David S. Miller <davem@davemloft.net>
|
||||
};
|
||||
|
||||
static int
|
||||
@@ -3027,6 +3029,9 @@ mt7531_create_sgmii(struct mt7530_priv *
|
||||
@@ -3188,6 +3190,9 @@ mt7531_create_sgmii(struct mt7530_priv *
|
||||
mt7531_pcs_config[i]->reg_stride = 4;
|
||||
mt7531_pcs_config[i]->reg_base = MT7531_SGMII_REG_BASE(5 + i);
|
||||
mt7531_pcs_config[i]->max_register = 0x17c;
|
||||
|
||||
+7
-7
@@ -133,7 +133,7 @@ Signed-off-by: David S. Miller <davem@davemloft.net>
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -2973,22 +2994,6 @@ static const struct phylink_pcs_ops mt75
|
||||
@@ -3134,22 +3155,6 @@ static const struct phylink_pcs_ops mt75
|
||||
.pcs_an_restart = mt7530_pcs_an_restart,
|
||||
};
|
||||
|
||||
@@ -156,7 +156,7 @@ Signed-off-by: David S. Miller <davem@davemloft.net>
|
||||
static void
|
||||
mt7530_mdio_regmap_lock(void *mdio_lock)
|
||||
{
|
||||
@@ -3001,7 +3006,7 @@ mt7530_mdio_regmap_unlock(void *mdio_loc
|
||||
@@ -3162,7 +3167,7 @@ mt7530_mdio_regmap_unlock(void *mdio_loc
|
||||
mutex_unlock(mdio_lock);
|
||||
}
|
||||
|
||||
@@ -165,7 +165,7 @@ Signed-off-by: David S. Miller <davem@davemloft.net>
|
||||
.reg_write = mt7530_regmap_write,
|
||||
.reg_read = mt7530_regmap_read,
|
||||
};
|
||||
@@ -3034,7 +3039,7 @@ mt7531_create_sgmii(struct mt7530_priv *
|
||||
@@ -3195,7 +3200,7 @@ mt7531_create_sgmii(struct mt7530_priv *
|
||||
mt7531_pcs_config[i]->lock_arg = &priv->bus->mdio_lock;
|
||||
|
||||
regmap = devm_regmap_init(priv->dev,
|
||||
@@ -174,7 +174,7 @@ Signed-off-by: David S. Miller <davem@davemloft.net>
|
||||
mt7531_pcs_config[i]);
|
||||
if (IS_ERR(regmap)) {
|
||||
ret = PTR_ERR(regmap);
|
||||
@@ -3199,6 +3204,7 @@ MODULE_DEVICE_TABLE(of, mt7530_of_match)
|
||||
@@ -3360,6 +3365,7 @@ MODULE_DEVICE_TABLE(of, mt7530_of_match)
|
||||
static int
|
||||
mt7530_probe(struct mdio_device *mdiodev)
|
||||
{
|
||||
@@ -182,7 +182,7 @@ Signed-off-by: David S. Miller <davem@davemloft.net>
|
||||
struct mt7530_priv *priv;
|
||||
struct device_node *dn;
|
||||
|
||||
@@ -3278,6 +3284,21 @@ mt7530_probe(struct mdio_device *mdiodev
|
||||
@@ -3439,6 +3445,21 @@ mt7530_probe(struct mdio_device *mdiodev
|
||||
mutex_init(&priv->reg_mutex);
|
||||
dev_set_drvdata(&mdiodev->dev, priv);
|
||||
|
||||
@@ -206,7 +206,7 @@ Signed-off-by: David S. Miller <davem@davemloft.net>
|
||||
|
||||
--- a/drivers/net/dsa/mt7530.h
|
||||
+++ b/drivers/net/dsa/mt7530.h
|
||||
@@ -774,6 +774,7 @@ struct mt753x_info {
|
||||
@@ -779,6 +779,7 @@ struct mt753x_info {
|
||||
* @dev: The device pointer
|
||||
* @ds: The pointer to the dsa core structure
|
||||
* @bus: The bus used for the device and built-in PHY
|
||||
@@ -214,7 +214,7 @@ Signed-off-by: David S. Miller <davem@davemloft.net>
|
||||
* @rstc: The pointer to reset control used by MCM
|
||||
* @core_pwr: The power supplied into the core
|
||||
* @io_pwr: The power supplied into the I/O
|
||||
@@ -794,6 +795,7 @@ struct mt7530_priv {
|
||||
@@ -799,6 +800,7 @@ struct mt7530_priv {
|
||||
struct device *dev;
|
||||
struct dsa_switch *ds;
|
||||
struct mii_bus *bus;
|
||||
|
||||
+3
-3
@@ -18,7 +18,7 @@ Signed-off-by: David S. Miller <davem@davemloft.net>
|
||||
|
||||
--- a/drivers/net/dsa/mt7530.c
|
||||
+++ b/drivers/net/dsa/mt7530.c
|
||||
@@ -3085,12 +3085,6 @@ mt753x_setup(struct dsa_switch *ds)
|
||||
@@ -3246,12 +3246,6 @@ mt753x_setup(struct dsa_switch *ds)
|
||||
if (ret && priv->irq)
|
||||
mt7530_free_irq_common(priv);
|
||||
|
||||
@@ -31,7 +31,7 @@ Signed-off-by: David S. Miller <davem@davemloft.net>
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -3207,6 +3201,7 @@ mt7530_probe(struct mdio_device *mdiodev
|
||||
@@ -3368,6 +3362,7 @@ mt7530_probe(struct mdio_device *mdiodev
|
||||
static struct regmap_config *regmap_config;
|
||||
struct mt7530_priv *priv;
|
||||
struct device_node *dn;
|
||||
@@ -39,7 +39,7 @@ Signed-off-by: David S. Miller <davem@davemloft.net>
|
||||
|
||||
dn = mdiodev->dev.of_node;
|
||||
|
||||
@@ -3299,6 +3294,12 @@ mt7530_probe(struct mdio_device *mdiodev
|
||||
@@ -3460,6 +3455,12 @@ mt7530_probe(struct mdio_device *mdiodev
|
||||
if (IS_ERR(priv->regmap))
|
||||
return PTR_ERR(priv->regmap);
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user