fix: close box service in case of exception, use source is private and disallow make in windows
This commit is contained in:
5
Makefile
5
Makefile
@@ -6,7 +6,9 @@ SRVNAME=HiddifyService
|
|||||||
|
|
||||||
BRANCH=$(shell git branch --show-current)
|
BRANCH=$(shell git branch --show-current)
|
||||||
VERSION=$(shell git describe --tags || echo "unknown version")
|
VERSION=$(shell git describe --tags || echo "unknown version")
|
||||||
|
ifeq ($(OS),Windows_NT)
|
||||||
|
Not available for Windows! use bash in WSL
|
||||||
|
endif
|
||||||
|
|
||||||
TAGS=with_gvisor,with_quic,with_wireguard,with_ech,with_utls,with_clash_api,with_grpc
|
TAGS=with_gvisor,with_quic,with_wireguard,with_ech,with_utls,with_clash_api,with_grpc
|
||||||
IOS_TAGS=with_dhcp,with_low_memory,with_conntrack
|
IOS_TAGS=with_dhcp,with_low_memory,with_conntrack
|
||||||
@@ -40,7 +42,6 @@ windows-amd64:
|
|||||||
go get github.com/akavel/rsrc
|
go get github.com/akavel/rsrc
|
||||||
go install github.com/akavel/rsrc
|
go install github.com/akavel/rsrc
|
||||||
cp $(BINDIR)/$(LIBNAME).dll ./$(LIBNAME).dll
|
cp $(BINDIR)/$(LIBNAME).dll ./$(LIBNAME).dll
|
||||||
ls ./
|
|
||||||
$$(go env GOPATH)/bin/rsrc -manifest admin_service/cmd/admin_service.manifest -ico ./assets/hiddify-service.ico -o admin_service/cmd/admin_service.syso
|
$$(go env GOPATH)/bin/rsrc -manifest admin_service/cmd/admin_service.manifest -ico ./assets/hiddify-service.ico -o admin_service/cmd/admin_service.syso
|
||||||
env GOOS=windows GOARCH=amd64 CC=x86_64-w64-mingw32-gcc CGO_LDFLAGS="$(LIBNAME).dll" $(GOBUILDSRV) -o $(BINDIR)/$(SRVNAME).exe ./admin_service/cmd
|
env GOOS=windows GOARCH=amd64 CC=x86_64-w64-mingw32-gcc CGO_LDFLAGS="$(LIBNAME).dll" $(GOBUILDSRV) -o $(BINDIR)/$(SRVNAME).exe ./admin_service/cmd
|
||||||
rm ./$(LIBNAME).dll
|
rm ./$(LIBNAME).dll
|
||||||
|
|||||||
@@ -256,8 +256,8 @@ func BuildConfig(opt ConfigOptions, input option.Options) (*option.Options, erro
|
|||||||
option.Rule{
|
option.Rule{
|
||||||
Type: C.RuleTypeDefault,
|
Type: C.RuleTypeDefault,
|
||||||
DefaultOptions: option.DefaultRule{
|
DefaultOptions: option.DefaultRule{
|
||||||
GeoIP: []string{"private"},
|
SourceIPIsPrivate: true,
|
||||||
Outbound: OutboundBypassTag,
|
Outbound: OutboundBypassTag,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
@@ -367,6 +367,16 @@ func BuildConfig(opt ConfigOptions, input option.Options) (*option.Options, erro
|
|||||||
Rules: routeRules,
|
Rules: routeRules,
|
||||||
AutoDetectInterface: true,
|
AutoDetectInterface: true,
|
||||||
OverrideAndroidVPN: true,
|
OverrideAndroidVPN: true,
|
||||||
|
// RuleSet: []option.RuleSet{
|
||||||
|
// {
|
||||||
|
// Type: C.RuleSetTypeRemote,
|
||||||
|
// Tag: "geoip-" + opt,
|
||||||
|
// RemoteOptions: option.RemoteRuleSet{
|
||||||
|
// URL: "https://raw.githubusercontent.com/Chocolate4U/Iran-sing-box-rules/rule-set/geoip-ir.srs",
|
||||||
|
// UpdateInterval: option.Duration(5 * time.day),
|
||||||
|
// },
|
||||||
|
// },
|
||||||
|
// },
|
||||||
GeoIP: &option.GeoIPOptions{
|
GeoIP: &option.GeoIPOptions{
|
||||||
Path: opt.GeoIPPath,
|
Path: opt.GeoIPPath,
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/hiddify/libcore/bridge"
|
"github.com/hiddify/libcore/bridge"
|
||||||
|
"github.com/hiddify/libcore/config"
|
||||||
)
|
)
|
||||||
|
|
||||||
var statusPropagationPort int64
|
var statusPropagationPort int64
|
||||||
@@ -31,10 +32,10 @@ func stopAndAlert(alert string, err error) (resultErr error) {
|
|||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
status = Stopped
|
|
||||||
message := err.Error()
|
|
||||||
fmt.Printf("Error: %s: %v\n", alert, err)
|
fmt.Printf("Error: %s: %v\n", alert, err)
|
||||||
msg, _ := json.Marshal(StatusMessage{Status: status, Alert: &alert, Message: &message})
|
propagateStatus(Stopped)
|
||||||
bridge.SendStringToPort(statusPropagationPort, string(msg))
|
config.DeactivateTunnelService()
|
||||||
|
commandServer.SetService(nil)
|
||||||
|
err = box.Close()
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user