Files
FlClash/core/constant.go
T
chen08209 22afef0a3c Adjust android process
Optimize more details
2026-07-23 14:49:22 +08:00

151 lines
5.4 KiB
Go

package main
import (
"encoding/json"
"github.com/metacubex/mihomo/adapter/provider"
P "github.com/metacubex/mihomo/component/process"
"github.com/metacubex/mihomo/constant"
"github.com/metacubex/mihomo/log"
"github.com/metacubex/mihomo/tunnel"
"net/netip"
"time"
)
type InitParams struct {
HomeDir string `json:"home-dir"`
Version int `json:"version"`
}
type SetupParams struct {
SelectedMap map[string]string `json:"selected-map"`
TestURL string `json:"test-url"`
}
type UpdateParams struct {
Tun *tunSchema `json:"tun"`
AllowLan *bool `json:"allow-lan"`
MixedPort *int `json:"mixed-port"`
FindProcessMode *P.FindProcessMode `json:"find-process-mode"`
Mode *tunnel.TunnelMode `json:"mode"`
LogLevel *log.LogLevel `json:"log-level"`
IPv6 *bool `json:"ipv6"`
Sniffing *bool `json:"sniffing"`
TCPConcurrent *bool `json:"tcp-concurrent"`
ExternalController *string `json:"external-controller"`
Interface *string `json:"interface-name"`
UnifiedDelay *bool `json:"unified-delay"`
GeoAutoUpdate *bool `json:"geo-auto-update"`
GeoUpdateInterval *int `json:"geo-update-interval"`
}
type tunSchema struct {
Enable bool `yaml:"enable" json:"enable"`
Device *string `yaml:"device" json:"device"`
Stack *constant.TUNStack `yaml:"stack" json:"stack"`
DNSHijack *[]string `yaml:"dns-hijack" json:"dns-hijack"`
AutoRoute *bool `yaml:"auto-route" json:"auto-route"`
RouteAddress *[]netip.Prefix `yaml:"route-address" json:"route-address,omitempty"`
}
type ChangeProxyParams struct {
GroupName string `json:"group-name"`
ProxyName string `json:"proxy-name"`
}
type TestDelayParams struct {
ProxyName string `json:"proxy-name"`
TestUrl string `json:"test-url"`
Timeout int64 `json:"timeout"`
}
type Traffic struct {
Up int64 `json:"up"`
Down int64 `json:"down"`
}
type ExternalProvider struct {
Name string `json:"name"`
Type string `json:"type"`
VehicleType string `json:"vehicle-type"`
Count int `json:"count"`
Path string `json:"path"`
UpdateAt time.Time `json:"update-at"`
SubscriptionInfo *provider.SubscriptionInfo `json:"subscription-info"`
}
type ProxiesData struct {
Proxies map[string]constant.Proxy `json:"proxies"`
All []string `json:"all"`
}
const (
messageMethod CoreMethod = "message"
initClashMethod CoreMethod = "initClash"
getIsInitMethod CoreMethod = "getIsInit"
forceGcMethod CoreMethod = "forceGc"
shutdownMethod CoreMethod = "shutdown"
validateConfigMethod CoreMethod = "validateConfig"
updateConfigMethod CoreMethod = "updateConfig"
getProxiesMethod CoreMethod = "getProxies"
changeProxyMethod CoreMethod = "changeProxy"
getTrafficMethod CoreMethod = "getTraffic"
getTotalTrafficMethod CoreMethod = "getTotalTraffic"
resetTrafficMethod CoreMethod = "resetTraffic"
asyncTestDelayMethod CoreMethod = "asyncTestDelay"
getConnectionsMethod CoreMethod = "getConnections"
closeConnectionsMethod CoreMethod = "closeConnections"
resetConnectionsMethod CoreMethod = "resetConnections"
closeConnectionMethod CoreMethod = "closeConnection"
getExternalProvidersMethod CoreMethod = "getExternalProviders"
getExternalProviderMethod CoreMethod = "getExternalProvider"
getCountryCodeMethod CoreMethod = "getCountryCode"
getMemoryMethod CoreMethod = "getMemory"
updateGeoDataMethod CoreMethod = "updateGeoData"
updateExternalProviderMethod CoreMethod = "updateExternalProvider"
sideLoadExternalProviderMethod CoreMethod = "sideLoadExternalProvider"
startLogMethod CoreMethod = "startLog"
stopLogMethod CoreMethod = "stopLog"
startListenerMethod CoreMethod = "startListener"
stopListenerMethod CoreMethod = "stopListener"
updateDnsMethod CoreMethod = "updateDns"
crashMethod CoreMethod = "crash"
setupConfigMethod CoreMethod = "setupConfig"
getConfigMethod CoreMethod = "getConfig"
deleteFileMethod CoreMethod = "deleteFile"
)
type CoreMethod string
type MessageType string
type Delay struct {
Url string `json:"url"`
Name string `json:"name"`
Value int32 `json:"value"`
}
type Message struct {
Type MessageType `json:"type"`
Data interface{} `json:"data"`
}
const (
LogMessage MessageType = "log"
DelayMessage MessageType = "delay"
RequestMessage MessageType = "request"
LoadedMessage MessageType = "loaded"
GeoUpdateMessage MessageType = "geoUpdate"
)
type GeoUpdateStatus struct {
Type string `json:"type"`
Updating bool `json:"updating"`
Skipped bool `json:"skipped,omitempty"`
Error string `json:"error,omitempty"`
}
func (message *Message) Json() (string, error) {
data, err := json.Marshal(message)
return string(data), err
}