fix: close box service in case of exception, use source is private and disallow make in windows

This commit is contained in:
Hiddify
2024-02-08 11:31:39 +01:00
parent cc035c98fa
commit 0a91223909
3 changed files with 20 additions and 8 deletions

View File

@@ -6,7 +6,9 @@ SRVNAME=HiddifyService
BRANCH=$(shell git branch --show-current)
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
IOS_TAGS=with_dhcp,with_low_memory,with_conntrack
@@ -40,7 +42,6 @@ windows-amd64:
go get github.com/akavel/rsrc
go install github.com/akavel/rsrc
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
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

View File

@@ -256,8 +256,8 @@ func BuildConfig(opt ConfigOptions, input option.Options) (*option.Options, erro
option.Rule{
Type: C.RuleTypeDefault,
DefaultOptions: option.DefaultRule{
GeoIP: []string{"private"},
Outbound: OutboundBypassTag,
SourceIPIsPrivate: true,
Outbound: OutboundBypassTag,
},
},
)
@@ -367,6 +367,16 @@ func BuildConfig(opt ConfigOptions, input option.Options) (*option.Options, erro
Rules: routeRules,
AutoDetectInterface: 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{
Path: opt.GeoIPPath,
},

View File

@@ -6,6 +6,7 @@ import (
"fmt"
"github.com/hiddify/libcore/bridge"
"github.com/hiddify/libcore/config"
)
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)
msg, _ := json.Marshal(StatusMessage{Status: status, Alert: &alert, Message: &message})
bridge.SendStringToPort(statusPropagationPort, string(msg))
propagateStatus(Stopped)
config.DeactivateTunnelService()
commandServer.SetService(nil)
err = box.Close()
return nil
}