Skip to content

Commit

Permalink
release: version 3.1.2
Browse files Browse the repository at this point in the history
  • Loading branch information
hiddify-com committed Sep 29, 2024
1 parent 2ede480 commit c5ba3e0
Show file tree
Hide file tree
Showing 17 changed files with 145 additions and 42 deletions.
20 changes: 20 additions & 0 deletions .github/change_version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#! /bin/bash
echo "previous version was $(git describe --tags $(git rev-list --tags --max-count=1))"
echo "WARNING: This operation will creates version tag and push to github"
read -p "Version? (provide the next x.y.z semver) : " TAG
echo $TAG &&\
[[ "$TAG" =~ ^[0-9]{1,2}\.[0-9]{1,2}\.[0-9]{1,2}(\.dev)?$ ]] || { echo "Incorrect tag. e.g., 1.2.3 or 1.2.3.dev"; exit 1; }
IFS="." read -r -a VERSION_ARRAY <<< "$TAG"
VERSION_STR="${VERSION_ARRAY[0]}.${VERSION_ARRAY[1]}.${VERSION_ARRAY[2]}"
BUILD_NUMBER=$(( ${VERSION_ARRAY[0]} * 10000 + ${VERSION_ARRAY[1]} * 100 + ${VERSION_ARRAY[2]} ))
echo "version: ${VERSION_STR}+${BUILD_NUMBER}"
sed -i -e "s|<key>CFBundleVersion</key>\s*<string>[^<]*</string>|<key>CFBundleVersion</key><string>${VERSION_STR}</string>|" Info.plist &&\
sed -i -e "s|<key>CFBundleShortVersionString</key>\s*<string>[^<]*</string>|<key>CFBundleShortVersionString</key><string>${VERSION_STR}</string>|" Info.plist &&\
sed -i "s|ENV VERSION=.*|ENV VERSION=v${TAG}|g" docker/Dockerfile
git add Info.plist docker/Dockerfile
git commit -m "release: version ${TAG}"
echo "creating git tag : v${TAG}"
git push
git tag v${TAG}
git push -u origin HEAD --tags
echo "Github Actions will detect the new tag and release the new version."'
4 changes: 2 additions & 2 deletions Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@
<string>1.0</string>
<key>CFBundleIdentifier</key>
<string>ios.libcore.hiddify</string>
<key>CFBundleShortVersionString</key><string>3.1.1</string>
<key>CFBundleVersion</key><string>3.1.1</string>
<key>CFBundleShortVersionString</key><string>3.1.2</string>
<key>CFBundleVersion</key><string>3.1.2</string>
<key>MinimumOSVersion</key>
<string>15.0</string>
</dict>
Expand Down
24 changes: 3 additions & 21 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -100,26 +100,8 @@ clean:



release: # Create a new tag for release.
@echo "previous version was $$(git describe --tags $$(git rev-list --tags --max-count=1))"
@echo "WARNING: This operation will creates version tag and push to github"
@bash -c '\
read -p "Version? (provide the next x.y.z semver) : " TAG && \
echo $$TAG &&\
[[ "$$TAG" =~ ^[0-9]{1,2}\.[0-9]{1,2}\.[0-9]{1,2}(\.dev)?$$ ]] || { echo "Incorrect tag. e.g., 1.2.3 or 1.2.3.dev"; exit 1; } && \
IFS="." read -r -a VERSION_ARRAY <<< "$$TAG" && \
VERSION_STR="$${VERSION_ARRAY[0]}.$${VERSION_ARRAY[1]}.$${VERSION_ARRAY[2]}" && \
BUILD_NUMBER=$$(( $${VERSION_ARRAY[0]} * 10000 + $${VERSION_ARRAY[1]} * 100 + $${VERSION_ARRAY[2]} )) && \
echo "version: $${VERSION_STR}+$${BUILD_NUMBER}" && \
sed -i -e "s|<key>CFBundleVersion</key>\s*<string>[^<]*</string>|<key>CFBundleVersion</key><string>$${VERSION_STR}</string>|" Info.plist &&\
sed -i -e "s|<key>CFBundleShortVersionString</key>\s*<string>[^<]*</string>|<key>CFBundleShortVersionString</key><string>$${VERSION_STR}</string>|" Info.plist &&\
sed -i "s|ENV VERSION=.*|ENV VERSION=v$${TAG}|g" docker/Dockerfile && \
git add Info.plist docker/Dockerfile && \
git commit -m "release: version $${TAG}" && \
echo "creating git tag : v$${TAG}" && \
git push && \
git tag v$${TAG} && \
git push -u origin HEAD --tags && \
echo "Github Actions will detect the new tag and release the new version."'
release: # Create a new tag for release.
@bash -c '.github/change_version.sh'



1 change: 1 addition & 0 deletions cmd/cmd_extension.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ var commandExtension = &cobra.Command{
}

func StartExtension() {
v2.Setup("./tmp", "./", "./tmp", 0, false)
grpc_server, _ := v2.StartCoreGrpcServer("127.0.0.1:12345")
fmt.Printf("Waiting for CTRL+C to stop\n")
runWebserver(grpc_server)
Expand Down
2 changes: 1 addition & 1 deletion config/warp.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"strings"

"github.com/bepass-org/warp-plus/warp"
"github.com/hiddify/hiddify-core/common"
"github.com/hiddify/hiddify-core/v2/common"
C "github.com/sagernet/sing-box/constant"

// "github.com/bepass-org/wireguard-go/warp"
Expand Down
1 change: 0 additions & 1 deletion custom/custom.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ func setupOnce(api unsafe.Pointer) {
//export setup
func setup(baseDir *C.char, workingDir *C.char, tempDir *C.char, statusPort C.longlong, debug bool) (CErr *C.char) {
err := v2.Setup(C.GoString(baseDir), C.GoString(workingDir), C.GoString(tempDir), int64(statusPort), debug)

return emptyOrErrorC(err)
}

Expand Down
2 changes: 1 addition & 1 deletion extension/extension.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package extension

import (
"github.com/hiddify/hiddify-core/common"
"github.com/hiddify/hiddify-core/config"
"github.com/hiddify/hiddify-core/extension/ui"
pb "github.com/hiddify/hiddify-core/hiddifyrpc"
"github.com/hiddify/hiddify-core/v2/common"
"github.com/jellydator/validation"
"github.com/sagernet/sing-box/log"
"github.com/sagernet/sing-box/option"
Expand Down
2 changes: 1 addition & 1 deletion extension/extension_host.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"fmt"
"log"

"github.com/hiddify/hiddify-core/common"
pb "github.com/hiddify/hiddify-core/hiddifyrpc"
"github.com/hiddify/hiddify-core/v2/common"
"google.golang.org/grpc"
)

Expand Down
35 changes: 30 additions & 5 deletions extension/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import (
"fmt"
"log"

"github.com/hiddify/hiddify-core/common"
"github.com/hiddify/hiddify-core/v2/common"
"github.com/hiddify/hiddify-core/v2/service_manager"
)

var (
Expand All @@ -26,11 +27,7 @@ func RegisterExtension(factory ExtensionFactory) error {
return err
}
allExtensionsMap[factory.Id] = factory
common.Storage.GetExtensionData("default", &generalExtensionData)

if val, ok := generalExtensionData.ExtensionStatusMap[factory.Id]; ok && val {
loadExtension(factory)
}
return nil
}

Expand All @@ -43,3 +40,31 @@ func loadExtension(factory ExtensionFactory) error {

return nil
}

type extensionService struct {
// Storage *CacheFile
}

func (s *extensionService) Start() error {
common.Storage.GetExtensionData("default", &generalExtensionData)

for id, factory := range allExtensionsMap {
if val, ok := generalExtensionData.ExtensionStatusMap[id]; ok && val {
loadExtension(factory)
}
}
return nil
}

func (s *extensionService) Close() error {
for _, extension := range enabledExtensionsMap {
if err := (*extension).Stop(); err != nil {
return err
}
}
return nil
}

func init() {
service_manager.Register(&extensionService{})
}
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ toolchain go1.22.3
require (
github.com/bepass-org/warp-plus v1.2.4
github.com/fatih/color v1.16.0 // indirect
github.com/hiddify/hiddify-ip-scanner-extension v0.0.0-20240928194626-7f6dde034dfe
github.com/hiddify/hiddify-ip-scanner-extension v0.0.0-20240929171529-e72be5930514
github.com/improbable-eng/grpc-web v0.15.0
github.com/jellydator/validation v1.1.0
github.com/kardianos/service v1.2.2
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -239,8 +239,8 @@ github.com/hashicorp/yamux v0.1.1 h1:yrQxtgseBDrq9Y652vSRDvsKCJKOUD+GzTS4Y0Y8pvE
github.com/hashicorp/yamux v0.1.1/go.mod h1:CtWFDAQgb7dxtzFs4tWbplKIe2jSi3+5vKbgIO0SLnQ=
github.com/hiddify/hiddify-app-demo-extension v0.0.0-20240929132536-e158b83e958c h1:DHMeFSoah61yZQKWhQGK6V8ve6KzoiPn1tdK/kpY5Wc=
github.com/hiddify/hiddify-app-demo-extension v0.0.0-20240929132536-e158b83e958c/go.mod h1:a/gJxWYZWt5ii9sDObSERSmxVEUVtsR8ZMnbgN8tLCM=
github.com/hiddify/hiddify-ip-scanner-extension v0.0.0-20240928194626-7f6dde034dfe h1:lqlc/H76XSDdOlwboI77pdDZGTwzNh6/J0MaYGOYUAc=
github.com/hiddify/hiddify-ip-scanner-extension v0.0.0-20240928194626-7f6dde034dfe/go.mod h1:9Fjoaxn2gbFQioxwdb06Kaz4kfFV7nxS0TJ/+IlDWvg=
github.com/hiddify/hiddify-ip-scanner-extension v0.0.0-20240929171529-e72be5930514 h1:22nmdhhrCUW5ygzSIIs6KlCndJGmNUb7+43i71M5nHg=
github.com/hiddify/hiddify-ip-scanner-extension v0.0.0-20240929171529-e72be5930514/go.mod h1:9Fjoaxn2gbFQioxwdb06Kaz4kfFV7nxS0TJ/+IlDWvg=
github.com/hiddify/hiddify-sing-box v1.8.9-0.20240928213625-7b79bf0c814d h1:+jTGlmOl+Kt3JEU1pt5yIItpi6nKKqUIUf76jkONHgQ=
github.com/hiddify/hiddify-sing-box v1.8.9-0.20240928213625-7b79bf0c814d/go.mod h1:2Cozqb5uVY/y0c/HWZ57CfE6fZwjmik/J3tWynsjjDA=
github.com/hiddify/ray2sing v0.0.0-20240928221833-190b549d5222 h1:+MFxFxoWCA44WhqIixqL/Zkt4DwnqhQvafS0Dm4+dKM=
Expand Down
6 changes: 4 additions & 2 deletions mobile/mobile.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@ import (

"github.com/hiddify/hiddify-core/config"

"github.com/hiddify/hiddify-core/v2"

_ "github.com/sagernet/gomobile"
"github.com/sagernet/sing-box/option"
)

func Setup() error {
func Setup(baseDir string, workingDir string, tempDir string, debug bool) error {
return v2.Setup(baseDir, workingDir, tempDir, 0, debug)
// return v2.Start(17078)
return nil
}

func Parse(path string, tempPath string, debug bool) error {
Expand Down
23 changes: 21 additions & 2 deletions common/cache.go → v2/common/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"os"
"time"

"github.com/hiddify/hiddify-core/v2/service_manager"
"github.com/sagernet/sing-box/option"

"github.com/sagernet/bbolt"
Expand All @@ -19,7 +20,7 @@ import (
)

var (
Storage = New(context.Background(), option.CacheFileOptions{})
Storage CacheFile
bucketExtension = []byte("extension")
bucketHiddify = []byte("hiddify")

Expand All @@ -29,6 +30,24 @@ var (
}
)

type StorageService struct {
// Storage *CacheFile
}

func (s *StorageService) Start() error {
Storage = *NewStorage(context.Background(), option.CacheFileOptions{})
return nil
}

func (s *StorageService) Close() error {
Storage.DB.Close()
return nil
}

func init() {
service_manager.RegisterPreservice(&StorageService{})
}

type CacheFile struct {
ctx context.Context
path string
Expand All @@ -37,7 +56,7 @@ type CacheFile struct {
DB *bbolt.DB
}

func New(ctx context.Context, options option.CacheFileOptions) *CacheFile {
func NewStorage(ctx context.Context, options option.CacheFileOptions) *CacheFile {
var path string
if options.Path != "" {
path = options.Path
Expand Down
File renamed without changes.
1 change: 0 additions & 1 deletion v2/grpc_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ func StartGrpcServer(listenAddressG string, service string) (*grpc.Server, error
if service == "core" {

// Setup("./tmp/", "./tmp", "./tmp", 11111, false)
Setup("./tmp", "./", "./tmp", 0, false)

useFlutterBridge = false
pb.RegisterCoreServer(s, &CoreService{})
Expand Down
14 changes: 12 additions & 2 deletions v2/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import (
runtimeDebug "runtime/debug"
"time"

"github.com/hiddify/hiddify-core/v2/service_manager"

B "github.com/sagernet/sing-box"
"github.com/sagernet/sing-box/common/urltest"
"github.com/sagernet/sing-box/experimental/libbox"
Expand All @@ -27,9 +29,13 @@ var (
statusPropagationPort int64
)

func InitHiddifyService() error {
return service_manager.StartServices()
}

func Setup(basePath string, workingPath string, tempPath string, statusPort int64, debug bool) error {
statusPropagationPort = int64(statusPort)
tcpConn := runtime.GOOS == "windows" //TODO add TVOS
tcpConn := runtime.GOOS == "windows" // TODO add TVOS
libbox.Setup(basePath, workingPath, tempPath, tcpConn)
sWorkingPath = workingPath
os.Chdir(sWorkingPath)
Expand All @@ -53,7 +59,11 @@ func Setup(basePath string, workingPath string, tempPath string, statusPort int6
// },
})
coreLogFactory = factory
return err

if err != nil {
return E.Cause(err, "create logger")
}
return InitHiddifyService()
}

func NewService(options option.Options) (*libbox.BoxService, error) {
Expand Down
46 changes: 46 additions & 0 deletions v2/service_manager/hiddify.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package service_manager

import (
"github.com/sagernet/sing-box/adapter"
)

var (
services = []adapter.Service{}
preservices = []adapter.Service{}
)

func RegisterPreservice(service adapter.Service) {
preservices = append(services, service)
}

func Register(service adapter.Service) {
services = append(services, service)
}

func StartServices() error {
for _, service := range preservices {
if err := service.Start(); err != nil {
return err
}
}
for _, service := range services {
if err := service.Start(); err != nil {
return err
}
}
return nil
}

func CloseServices() error {
for _, service := range services {
if err := service.Close(); err != nil {
return err
}
}
for _, service := range preservices {
if err := service.Close(); err != nil {
return err
}
}
return nil
}

0 comments on commit c5ba3e0

Please sign in to comment.