Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
x committed Oct 20, 2024
1 parent c70e3b9 commit a0e09ea
Show file tree
Hide file tree
Showing 47 changed files with 1,276 additions and 8,327 deletions.
6 changes: 3 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ go version go1.21.1 darwin/arm64

> if you're not interested in building/contributing to the Go code, you can skip this section
The Go code for Hiddify can be found in the `libcore` folder, as a [git submodule](https://git-scm.com/book/en/v2/Git-Tools-Submodules) and in [core repository](https://github.com/hiddify/hiddify-next-core). The entrypoints for the desktop version are available in the [`libcore/custom`](https://github.com/hiddify/hiddify-next-core/tree/main/custom) folder and for the mobile version they can be found in the [`libcore/mobile`](https://github.com/hiddify/hiddify-next-core/tree/main/mobile) folder.
The Go code for Hiddify can be found in the `hiddify-core` folder, as a [git submodule](https://git-scm.com/book/en/v2/Git-Tools-Submodules) and in [core repository](https://github.com/hiddify/hiddify-next-core). The entrypoints for the desktop version are available in the [`hiddify-core/custom`](https://github.com/hiddify/hiddify-next-core/tree/main/custom) folder and for the mobile version they can be found in the [`hiddify-core/mobile`](https://github.com/hiddify/hiddify-next-core/tree/main/mobile) folder.

For the desktop version, we have to compile the Go code into a C shared library. We are providing a Makefile to generate the C shared libraries for all operating systems. The following Make commands will build libcore and copy the resulting output in [`libcore/bin`](https://github.com/hiddify/hiddify-next-core/tree/main/bin):
For the desktop version, we have to compile the Go code into a C shared library. We are providing a Makefile to generate the C shared libraries for all operating systems. The following Make commands will build hiddify-core and copy the resulting output in [`hiddify-core/bin`](https://github.com/hiddify/hiddify-next-core/tree/main/bin):

- `make windows-amd64`
- `make linux-amd64`
- `make macos-universal`

For the mobile version, we are using the [`gomobile`](https://github.com/golang/go/wiki/Mobile) tools. The following Make commands will build libcore for Android and iOS and copy the resulting output in [`libcore/bin`](https://github.com/hiddify/hiddify-next-core/tree/main/bin):
For the mobile version, we are using the [`gomobile`](https://github.com/golang/go/wiki/Mobile) tools. The following Make commands will build hiddify-core for Android and iOS and copy the resulting output in [`hiddify-core/bin`](https://github.com/hiddify/hiddify-next-core/tree/main/bin):

- `make android`
- `make ios`
15 changes: 8 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,13 @@ GOBUILDSRV=CGO_ENABLED=1 go build -ldflags "-s -w" -trimpath -tags $(TAGS)
protos:
go install github.com/pseudomuto/protoc-gen-doc/cmd/protoc-gen-doc@latest
# protoc --go_out=./ --go-grpc_out=./ --proto_path=hiddifyrpc hiddifyrpc/*.proto
for f in $(shell find v2 -name "*.proto"); do \
protoc --go_opt=paths=source_relative --go-grpc_opt=paths=source_relative --go_out=./ --go-grpc_out=./ $$f; \
done
for f in $(shell find extension -name "*.proto"); do \
protoc --go_opt=paths=source_relative --go-grpc_opt=paths=source_relative --go_out=./ --go-grpc_out=./ $$f; \
done
# for f in $(shell find v2 -name "*.proto"); do \
# protoc --go_opt=paths=source_relative --go-grpc_opt=paths=source_relative --go_out=./ --go-grpc_out=./ $$f; \
# done
# for f in $(shell find extension -name "*.proto"); do \
# protoc --go_opt=paths=source_relative --go-grpc_opt=paths=source_relative --go_out=./ --go-grpc_out=./ $$f; \
# done
protoc --go_opt=paths=source_relative --go-grpc_opt=paths=source_relative --go_out=./ --go-grpc_out=./ $(shell find v2 -name "*.proto") $(shell find extension -name "*.proto")
protoc --doc_out=./docs --doc_opt=markdown,hiddifyrpc.md $(shell find v2 -name "*.proto") $(shell find extension -name "*.proto")
# protoc --js_out=import_style=commonjs,binary:./extension/html/rpc/ --grpc-web_out=import_style=commonjs,mode=grpcwebtext:./extension/html/rpc/ $(shell find v2 -name "*.proto") $(shell find extension -name "*.proto")
# npx browserify extension/html/rpc/extension.js >extension/html/rpc.js
Expand All @@ -37,7 +38,7 @@ lib_install:
npm install

headers:
go build -buildmode=c-archive -o $(BINDIR)/$(LIBNAME).h ./platform/desktop
go build -buildmode=c-archive -o $(BINDIR)/ ./platform/desktop

android: lib_install
gomobile bind -v -androidapi=21 -javapkg=com.hiddify.core -libname=hiddify-core -tags=$(TAGS) -trimpath -target=android -o $(BINDIR)/$(LIBNAME).aar github.com/sagernet/sing-box/experimental/libbox ./platform/mobile
Expand Down
10 changes: 5 additions & 5 deletions build_windows.bat
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ set GOARCH=amd64
set CC=x86_64-w64-mingw32-gcc
set CGO_ENABLED=1
go run ./cli tunnel exit
del bin\libcore.dll bin\HiddifyCli.exe
del bin\hiddify-core.dll bin\HiddifyCli.exe
set CGO_LDFLAGS=
go build -trimpath -tags with_gvisor,with_quic,with_wireguard,with_ech,with_utls,with_clash_api,with_grpc -ldflags="-w -s" -buildmode=c-shared -o bin/libcore.dll ./custom
go build -trimpath -tags with_gvisor,with_quic,with_wireguard,with_ech,with_utls,with_clash_api,with_grpc -ldflags="-w -s" -buildmode=c-shared -o bin/hiddify-core.dll ./custom
go get github.com/akavel/rsrc
go install github.com/akavel/rsrc

rsrc -ico .\assets\hiddify-cli.ico -o cli\bydll\cli.syso

copy bin\libcore.dll .
set CGO_LDFLAGS="libcore.dll"
copy bin\hiddify-core.dll .
set CGO_LDFLAGS="hiddify-core.dll"
go build -o bin/HiddifyCli.exe ./cli/bydll/
del libcore.dll
del hiddify-core.dll
53 changes: 31 additions & 22 deletions cmd/cmd_temp.go
Original file line number Diff line number Diff line change
@@ -1,32 +1,41 @@
package cmd

import (
"encoding/json"
"fmt"
"context"
"log"
"time"

"github.com/hiddify/hiddify-core/v2/config"
"github.com/hiddify/hiddify-core/v2/hcommon"
hcore "github.com/hiddify/hiddify-core/v2/hcore"
"google.golang.org/grpc"
)

// "github.com/hiddify/hiddify-core/extension_repository/cleanip_scanner"
"github.com/spf13/cobra"
const (
address = "localhost:17078"
defaultName = "world"
)

var commandTemp = &cobra.Command{
Use: "temp",
Short: "temp",
Args: cobra.MaximumNArgs(2),
Run: func(cmd *cobra.Command, args []string) {
// fmt.Printf("Ping time: %d ms\n", Ping())
tmp := map[string][]string{
"direct-dns-address": {"1.1.1.1"},
"tls-tricks.enable-fragment": {"true"},
"tls-tricks.fragment-size": {"2-4"},
func init() {
conn, err := grpc.Dial(address, grpc.WithInsecure())
if err != nil {
log.Fatalf("did not connect: %v", err)
}
defer conn.Close()
c := hcore.NewCoreClient(conn)

ctx, cancel := context.WithTimeout(context.Background(), time.Second*10)
defer cancel()

// SayHello
stream, err := c.OutboundsInfo(ctx, &hcommon.Empty{})

for {
r, err := stream.Recv()
if err != nil {
log.Fatalf("could not receive: %v", err)
}
h := config.GetOverridableHiddifyOptions(tmp)
j, _ := json.Marshal(h)
fmt.Println(string(j))
},
}
log.Printf("Received1: %s", r.String())

func init() {
mainCommand.AddCommand(commandTemp)
time.Sleep(1 * time.Second)
}
}
2 changes: 1 addition & 1 deletion cmd/internal/build_libcore/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ var (
iosTags []string
)

const libName = "libcore"
const libName = "hiddify-core"

func init() {
sharedFlags = append(sharedFlags, "-trimpath")
Expand Down
Loading

0 comments on commit a0e09ea

Please sign in to comment.