Skip to content

Commit a0e09ea

Browse files
author
x
committed
update
1 parent c70e3b9 commit a0e09ea

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+1276
-8327
lines changed

CONTRIBUTING.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@ go version go1.21.1 darwin/arm64
1212

1313
> if you're not interested in building/contributing to the Go code, you can skip this section
1414
15-
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.
15+
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.
1616

17-
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):
17+
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):
1818

1919
- `make windows-amd64`
2020
- `make linux-amd64`
2121
- `make macos-universal`
2222

23-
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):
23+
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):
2424

2525
- `make android`
2626
- `make ios`

Makefile

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,13 @@ GOBUILDSRV=CGO_ENABLED=1 go build -ldflags "-s -w" -trimpath -tags $(TAGS)
2020
protos:
2121
go install github.com/pseudomuto/protoc-gen-doc/cmd/protoc-gen-doc@latest
2222
# protoc --go_out=./ --go-grpc_out=./ --proto_path=hiddifyrpc hiddifyrpc/*.proto
23-
for f in $(shell find v2 -name "*.proto"); do \
24-
protoc --go_opt=paths=source_relative --go-grpc_opt=paths=source_relative --go_out=./ --go-grpc_out=./ $$f; \
25-
done
26-
for f in $(shell find extension -name "*.proto"); do \
27-
protoc --go_opt=paths=source_relative --go-grpc_opt=paths=source_relative --go_out=./ --go-grpc_out=./ $$f; \
28-
done
23+
# for f in $(shell find v2 -name "*.proto"); do \
24+
# protoc --go_opt=paths=source_relative --go-grpc_opt=paths=source_relative --go_out=./ --go-grpc_out=./ $$f; \
25+
# done
26+
# for f in $(shell find extension -name "*.proto"); do \
27+
# protoc --go_opt=paths=source_relative --go-grpc_opt=paths=source_relative --go_out=./ --go-grpc_out=./ $$f; \
28+
# done
29+
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")
2930
protoc --doc_out=./docs --doc_opt=markdown,hiddifyrpc.md $(shell find v2 -name "*.proto") $(shell find extension -name "*.proto")
3031
# 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")
3132
# npx browserify extension/html/rpc/extension.js >extension/html/rpc.js
@@ -37,7 +38,7 @@ lib_install:
3738
npm install
3839

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

4243
android: lib_install
4344
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

build_windows.bat

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ set GOARCH=amd64
44
set CC=x86_64-w64-mingw32-gcc
55
set CGO_ENABLED=1
66
go run ./cli tunnel exit
7-
del bin\libcore.dll bin\HiddifyCli.exe
7+
del bin\hiddify-core.dll bin\HiddifyCli.exe
88
set CGO_LDFLAGS=
9-
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
9+
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
1010
go get github.com/akavel/rsrc
1111
go install github.com/akavel/rsrc
1212

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

15-
copy bin\libcore.dll .
16-
set CGO_LDFLAGS="libcore.dll"
15+
copy bin\hiddify-core.dll .
16+
set CGO_LDFLAGS="hiddify-core.dll"
1717
go build -o bin/HiddifyCli.exe ./cli/bydll/
18-
del libcore.dll
18+
del hiddify-core.dll

cmd/cmd_temp.go

Lines changed: 31 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,41 @@
11
package cmd
22

33
import (
4-
"encoding/json"
5-
"fmt"
4+
"context"
5+
"log"
6+
"time"
67

7-
"github.com/hiddify/hiddify-core/v2/config"
8+
"github.com/hiddify/hiddify-core/v2/hcommon"
9+
hcore "github.com/hiddify/hiddify-core/v2/hcore"
10+
"google.golang.org/grpc"
11+
)
812

9-
// "github.com/hiddify/hiddify-core/extension_repository/cleanip_scanner"
10-
"github.com/spf13/cobra"
13+
const (
14+
address = "localhost:17078"
15+
defaultName = "world"
1116
)
1217

13-
var commandTemp = &cobra.Command{
14-
Use: "temp",
15-
Short: "temp",
16-
Args: cobra.MaximumNArgs(2),
17-
Run: func(cmd *cobra.Command, args []string) {
18-
// fmt.Printf("Ping time: %d ms\n", Ping())
19-
tmp := map[string][]string{
20-
"direct-dns-address": {"1.1.1.1"},
21-
"tls-tricks.enable-fragment": {"true"},
22-
"tls-tricks.fragment-size": {"2-4"},
18+
func init() {
19+
conn, err := grpc.Dial(address, grpc.WithInsecure())
20+
if err != nil {
21+
log.Fatalf("did not connect: %v", err)
22+
}
23+
defer conn.Close()
24+
c := hcore.NewCoreClient(conn)
25+
26+
ctx, cancel := context.WithTimeout(context.Background(), time.Second*10)
27+
defer cancel()
28+
29+
// SayHello
30+
stream, err := c.OutboundsInfo(ctx, &hcommon.Empty{})
31+
32+
for {
33+
r, err := stream.Recv()
34+
if err != nil {
35+
log.Fatalf("could not receive: %v", err)
2336
}
24-
h := config.GetOverridableHiddifyOptions(tmp)
25-
j, _ := json.Marshal(h)
26-
fmt.Println(string(j))
27-
},
28-
}
37+
log.Printf("Received1: %s", r.String())
2938

30-
func init() {
31-
mainCommand.AddCommand(commandTemp)
39+
time.Sleep(1 * time.Second)
40+
}
3241
}

cmd/internal/build_libcore/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ var (
4242
iosTags []string
4343
)
4444

45-
const libName = "libcore"
45+
const libName = "hiddify-core"
4646

4747
func init() {
4848
sharedFlags = append(sharedFlags, "-trimpath")

0 commit comments

Comments
 (0)