Skip to content

Commit

Permalink
add live ipinfo
Browse files Browse the repository at this point in the history
  • Loading branch information
x committed Oct 20, 2024
1 parent a0e09ea commit 3eaa9dc
Show file tree
Hide file tree
Showing 7 changed files with 477 additions and 272 deletions.
38 changes: 21 additions & 17 deletions cmd/cmd_temp.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package cmd
import (
"context"
"log"
"os"
"time"

"github.com/hiddify/hiddify-core/v2/hcommon"
Expand All @@ -16,26 +17,29 @@ const (
)

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)
if os.Args[1] == "test" {
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()
// ctx, cancel := context.WithTimeout(context.Background(), time.Second*10)
// defer cancel()
ctx := context.Background()

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

for {
r, err := stream.Recv()
if err != nil {
log.Fatalf("could not receive: %v", err)
}
log.Printf("Received1: %s", r.String())
for {
r, err := stream.Recv()
if err != nil {
log.Fatalf("could not receive: %v", err)
}
log.Printf("Received1: %s", r.String())

time.Sleep(1 * time.Second)
time.Sleep(1 * time.Second)
}
}
}
25 changes: 25 additions & 0 deletions docs/hiddifyrpc.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
- [GenerateConfigRequest](#hcore-GenerateConfigRequest)
- [GenerateConfigResponse](#hcore-GenerateConfigResponse)
- [GenerateWarpConfigRequest](#hcore-GenerateWarpConfigRequest)
- [IpInfo](#hcore-IpInfo)
- [LogMessage](#hcore-LogMessage)
- [OutboundGroup](#hcore-OutboundGroup)
- [OutboundGroupList](#hcore-OutboundGroupList)
Expand Down Expand Up @@ -192,6 +193,29 @@



<a name="hcore-IpInfo"></a>

### IpInfo



| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| ip | [string](#string) | | The IP address. |
| country_code | [string](#string) | | The country code. |
| region | [string](#string) | | The region (optional). |
| city | [string](#string) | | The city (optional). |
| asn | [int32](#int32) | | The Autonomous System Number (optional). |
| org | [string](#string) | | The organization (optional). |
| latitude | [double](#double) | | The latitude (optional). |
| longitude | [double](#double) | | The longitude (optional). |
| postal_code | [string](#string) | | The postal code (optional). |






<a name="hcore-LogMessage"></a>

### LogMessage
Expand Down Expand Up @@ -257,6 +281,7 @@
| type | [string](#string) | | |
| url_test_time | [google.protobuf.Timestamp](#google-protobuf-Timestamp) | | |
| url_test_delay | [int32](#int32) | | |
| ipinfo | [IpInfo](#hcore-IpInfo) | | |



Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ require (
lukechampine.com/blake3 v1.3.0 // indirect
)

replace github.com/sagernet/sing-box => github.com/hiddify/hiddify-sing-box v1.8.9-0.20241020064059-08c71ee5f82f
replace github.com/sagernet/sing-box => github.com/hiddify/hiddify-sing-box v1.8.9-0.20241020111745-22b807080fe7

replace github.com/xtls/xray-core => github.com/hiddify/xray-core v0.0.0-20241019134126-3f94892df016

Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -242,8 +242,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/hectane/go-acl v0.0.0-20230122075934-ca0b05cb1adb h1:PGufWXXDq9yaev6xX1YQauaO1MV90e6Mpoq1I7Lz/VM=
github.com/hectane/go-acl v0.0.0-20230122075934-ca0b05cb1adb/go.mod h1:QiyDdbZLaJ/mZP4Zwc9g2QsfaEA4o7XvvgZegSci5/E=
github.com/hiddify/hiddify-sing-box v1.8.9-0.20241020064059-08c71ee5f82f h1:UYYtEiK8bx2sBzUkr1YV9HhAvBMjb+4Dm0Uc0OvnUfY=
github.com/hiddify/hiddify-sing-box v1.8.9-0.20241020064059-08c71ee5f82f/go.mod h1:6apAGQPqJIb58BIYsr66tu49S5UcCNyuv1lVX+72eQA=
github.com/hiddify/hiddify-sing-box v1.8.9-0.20241020111745-22b807080fe7 h1:+eeJtla199xUya0DonMvsMhpr/rsQrM5ePFTgfJZunI=
github.com/hiddify/hiddify-sing-box v1.8.9-0.20241020111745-22b807080fe7/go.mod h1:6apAGQPqJIb58BIYsr66tu49S5UcCNyuv1lVX+72eQA=
github.com/hiddify/ray2sing v0.0.0-20240928221833-190b549d5222 h1:+MFxFxoWCA44WhqIixqL/Zkt4DwnqhQvafS0Dm4+dKM=
github.com/hiddify/ray2sing v0.0.0-20240928221833-190b549d5222/go.mod h1:cFEg1b0eBgL9kBgIPAD71lHO1Q5g20PZL4dUGhQpAO8=
github.com/hiddify/warp-plus v0.0.0-20240717223357-4f3122e0d11d h1:vRGKh9ou+/vQGfVYa8MczhbIVjHxlP52OWwrDWO77RA=
Expand Down
Loading

0 comments on commit 3eaa9dc

Please sign in to comment.