mirror of
https://github.com/shtorm-7/sing-box-extended.git
synced 2026-06-02 17:27:32 +03:00
Update sing-box core, refactor MASQUE, update XHTTP
This commit is contained in:
@@ -116,7 +116,7 @@ func (c *CacheFile) Start(stage adapter.StartStage) error {
|
||||
db *bbolt.DB
|
||||
err error
|
||||
)
|
||||
for i := 0; i < 10; i++ {
|
||||
for range 10 {
|
||||
db, err = bbolt.Open(c.path, fileMode, &options)
|
||||
if err == nil {
|
||||
break
|
||||
|
||||
@@ -166,7 +166,7 @@ func (s *Server) Start(stage adapter.StartStage) error {
|
||||
listener net.Listener
|
||||
err error
|
||||
)
|
||||
for i := 0; i < 3; i++ {
|
||||
for range 3 {
|
||||
listener, err = net.Listen("tcp", s.httpServer.Addr)
|
||||
if runtime.GOOS == "android" && errors.Is(err, syscall.EADDRINUSE) {
|
||||
time.Sleep(100 * time.Millisecond)
|
||||
|
||||
@@ -147,7 +147,7 @@ func (c *CommandClient) dialWithRetry(target string, contextDialer func(context.
|
||||
var client daemon.StartedServiceClient
|
||||
var lastError error
|
||||
|
||||
for attempt := 0; attempt < commandClientDialAttempts; attempt++ {
|
||||
for attempt := range commandClientDialAttempts {
|
||||
if connection == nil {
|
||||
options := []grpc.DialOption{
|
||||
grpc.WithTransportCredentials(insecure.NewCredentials()),
|
||||
|
||||
@@ -114,7 +114,7 @@ func (s *CommandServer) Start() error {
|
||||
if sCommandServerListenPort == 0 {
|
||||
sockPath := filepath.Join(sBasePath, "command.sock")
|
||||
os.Remove(sockPath)
|
||||
for i := 0; i < 30; i++ {
|
||||
for range 30 {
|
||||
listener, err = net.ListenUnix("unix", &net.UnixAddr{
|
||||
Name: sockPath,
|
||||
Net: "unix",
|
||||
|
||||
@@ -418,13 +418,3 @@ func systemProxyStatusFromGRPC(status *daemon.SystemProxyStatus) *SystemProxySta
|
||||
Enabled: status.Enabled,
|
||||
}
|
||||
}
|
||||
|
||||
func systemProxyStatusToGRPC(status *SystemProxyStatus) *daemon.SystemProxyStatus {
|
||||
if status == nil {
|
||||
return nil
|
||||
}
|
||||
return &daemon.SystemProxyStatus{
|
||||
Available: status.Available,
|
||||
Enabled: status.Enabled,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,8 +8,6 @@ import (
|
||||
"runtime/debug"
|
||||
)
|
||||
|
||||
var crashOutputFile *os.File
|
||||
|
||||
func RedirectStderr(path string) error {
|
||||
if stats, err := os.Stat(path); err == nil && stats.Size() > 0 {
|
||||
_ = os.Rename(path, path+".old")
|
||||
@@ -32,6 +30,5 @@ func RedirectStderr(path string) error {
|
||||
os.Remove(outputFile.Name())
|
||||
return err
|
||||
}
|
||||
crashOutputFile = outputFile
|
||||
return nil
|
||||
return outputFile.Close()
|
||||
}
|
||||
|
||||
@@ -16,7 +16,6 @@ var (
|
||||
type platformDefaultInterfaceMonitor struct {
|
||||
*platformInterfaceWrapper
|
||||
logger logger.Logger
|
||||
element *list.Element[tun.NetworkUpdateCallback]
|
||||
callbacks list.List[tun.DefaultInterfaceUpdateCallback]
|
||||
myInterface string
|
||||
}
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
package libbox
|
||||
|
||||
import (
|
||||
C "github.com/sagernet/sing-box/constant"
|
||||
"github.com/sagernet/sing-box/option"
|
||||
)
|
||||
import C "github.com/sagernet/sing-box/constant"
|
||||
|
||||
type PlatformInterface interface {
|
||||
LocalDNSTransport() LocalDNSTransport
|
||||
@@ -98,37 +95,3 @@ type OnDemandRuleIterator interface {
|
||||
Next() OnDemandRule
|
||||
HasNext() bool
|
||||
}
|
||||
|
||||
type onDemandRule struct {
|
||||
option.OnDemandRule
|
||||
}
|
||||
|
||||
func (r *onDemandRule) Target() int32 {
|
||||
if r.OnDemandRule.Action == nil {
|
||||
return -1
|
||||
}
|
||||
return int32(*r.OnDemandRule.Action)
|
||||
}
|
||||
|
||||
func (r *onDemandRule) DNSSearchDomainMatch() StringIterator {
|
||||
return newIterator(r.OnDemandRule.DNSSearchDomainMatch)
|
||||
}
|
||||
|
||||
func (r *onDemandRule) DNSServerAddressMatch() StringIterator {
|
||||
return newIterator(r.OnDemandRule.DNSServerAddressMatch)
|
||||
}
|
||||
|
||||
func (r *onDemandRule) InterfaceTypeMatch() int32 {
|
||||
if r.OnDemandRule.InterfaceTypeMatch == nil {
|
||||
return -1
|
||||
}
|
||||
return int32(*r.OnDemandRule.InterfaceTypeMatch)
|
||||
}
|
||||
|
||||
func (r *onDemandRule) SSIDMatch() StringIterator {
|
||||
return newIterator(r.OnDemandRule.SSIDMatch)
|
||||
}
|
||||
|
||||
func (r *onDemandRule) ProbeURL() string {
|
||||
return r.OnDemandRule.ProbeURL
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ const utunControlName = "com.apple.net.utun_control"
|
||||
func GetTunnelFileDescriptor() int32 {
|
||||
ctlInfo := &unix.CtlInfo{}
|
||||
copy(ctlInfo.Name[:], utunControlName)
|
||||
for fd := 0; fd < 1024; fd++ {
|
||||
for fd := range 1024 {
|
||||
addr, err := unix.Getpeername(fd)
|
||||
if err != nil {
|
||||
continue
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
package v2rayapi
|
||||
|
||||
import (
|
||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||
reflect "reflect"
|
||||
sync "sync"
|
||||
unsafe "unsafe"
|
||||
|
||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -483,16 +484,18 @@ func file_experimental_v2rayapi_stats_proto_rawDescGZIP() []byte {
|
||||
return file_experimental_v2rayapi_stats_proto_rawDescData
|
||||
}
|
||||
|
||||
var file_experimental_v2rayapi_stats_proto_msgTypes = make([]protoimpl.MessageInfo, 7)
|
||||
var file_experimental_v2rayapi_stats_proto_goTypes = []any{
|
||||
(*GetStatsRequest)(nil), // 0: experimental.v2rayapi.GetStatsRequest
|
||||
(*Stat)(nil), // 1: experimental.v2rayapi.Stat
|
||||
(*GetStatsResponse)(nil), // 2: experimental.v2rayapi.GetStatsResponse
|
||||
(*QueryStatsRequest)(nil), // 3: experimental.v2rayapi.QueryStatsRequest
|
||||
(*QueryStatsResponse)(nil), // 4: experimental.v2rayapi.QueryStatsResponse
|
||||
(*SysStatsRequest)(nil), // 5: experimental.v2rayapi.SysStatsRequest
|
||||
(*SysStatsResponse)(nil), // 6: experimental.v2rayapi.SysStatsResponse
|
||||
}
|
||||
var (
|
||||
file_experimental_v2rayapi_stats_proto_msgTypes = make([]protoimpl.MessageInfo, 7)
|
||||
file_experimental_v2rayapi_stats_proto_goTypes = []any{
|
||||
(*GetStatsRequest)(nil), // 0: experimental.v2rayapi.GetStatsRequest
|
||||
(*Stat)(nil), // 1: experimental.v2rayapi.Stat
|
||||
(*GetStatsResponse)(nil), // 2: experimental.v2rayapi.GetStatsResponse
|
||||
(*QueryStatsRequest)(nil), // 3: experimental.v2rayapi.QueryStatsRequest
|
||||
(*QueryStatsResponse)(nil), // 4: experimental.v2rayapi.QueryStatsResponse
|
||||
(*SysStatsRequest)(nil), // 5: experimental.v2rayapi.SysStatsRequest
|
||||
(*SysStatsResponse)(nil), // 6: experimental.v2rayapi.SysStatsResponse
|
||||
}
|
||||
)
|
||||
var file_experimental_v2rayapi_stats_proto_depIdxs = []int32{
|
||||
1, // 0: experimental.v2rayapi.GetStatsResponse.stat:type_name -> experimental.v2rayapi.Stat
|
||||
1, // 1: experimental.v2rayapi.QueryStatsResponse.stat:type_name -> experimental.v2rayapi.Stat
|
||||
|
||||
@@ -2,6 +2,7 @@ package v2rayapi
|
||||
|
||||
import (
|
||||
context "context"
|
||||
|
||||
grpc "google.golang.org/grpc"
|
||||
codes "google.golang.org/grpc/codes"
|
||||
status "google.golang.org/grpc/status"
|
||||
@@ -85,9 +86,11 @@ type UnimplementedStatsServiceServer struct{}
|
||||
func (UnimplementedStatsServiceServer) GetStats(context.Context, *GetStatsRequest) (*GetStatsResponse, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "method GetStats not implemented")
|
||||
}
|
||||
|
||||
func (UnimplementedStatsServiceServer) QueryStats(context.Context, *QueryStatsRequest) (*QueryStatsResponse, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "method QueryStats not implemented")
|
||||
}
|
||||
|
||||
func (UnimplementedStatsServiceServer) GetSysStats(context.Context, *SysStatsRequest) (*SysStatsResponse, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "method GetSysStats not implemented")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user