mirror of
https://github.com/v2fly/v2ray-core.git
synced 2025-02-20 23:47:21 -05:00
isolate jsonv4 format that invalided selective compile
This commit is contained in:
parent
8989dd8336
commit
ca7a16104d
@ -16,9 +16,5 @@ var CmdAPI = &base.Command{
|
||||
cmdBalancerCheck,
|
||||
cmdBalancerInfo,
|
||||
cmdBalancerOverride,
|
||||
cmdAddInbounds,
|
||||
cmdAddOutbounds,
|
||||
cmdRemoveInbounds,
|
||||
cmdRemoveOutbounds,
|
||||
},
|
||||
}
|
||||
|
@ -1,7 +1,8 @@
|
||||
package api
|
||||
package jsonv4
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/v2fly/v2ray-core/v4/main/commands/all/api"
|
||||
|
||||
handlerService "github.com/v2fly/v2ray-core/v4/app/proxyman/command"
|
||||
"github.com/v2fly/v2ray-core/v4/main/commands/base"
|
||||
@ -43,10 +44,10 @@ Example:
|
||||
}
|
||||
|
||||
func executeAddInbounds(cmd *base.Command, args []string) {
|
||||
setSharedFlags(cmd)
|
||||
setSharedConfigFlags(cmd)
|
||||
api.SetSharedFlags(cmd)
|
||||
api.SetSharedConfigFlags(cmd)
|
||||
cmd.Flag.Parse(args)
|
||||
c, err := helpers.LoadConfig(cmd.Flag.Args(), apiConfigFormat, apiConfigRecursively)
|
||||
c, err := helpers.LoadConfig(cmd.Flag.Args(), api.ApiConfigFormat, api.ApiConfigRecursively)
|
||||
if err != nil {
|
||||
base.Fatalf("failed to load: %s", err)
|
||||
}
|
||||
@ -54,7 +55,7 @@ func executeAddInbounds(cmd *base.Command, args []string) {
|
||||
base.Fatalf("no valid inbound found")
|
||||
}
|
||||
|
||||
conn, ctx, close := dialAPIServer()
|
||||
conn, ctx, close := api.DialAPIServer()
|
||||
defer close()
|
||||
|
||||
client := handlerService.NewHandlerServiceClient(conn)
|
@ -1,7 +1,8 @@
|
||||
package api
|
||||
package jsonv4
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/v2fly/v2ray-core/v4/main/commands/all/api"
|
||||
|
||||
handlerService "github.com/v2fly/v2ray-core/v4/app/proxyman/command"
|
||||
"github.com/v2fly/v2ray-core/v4/main/commands/base"
|
||||
@ -47,8 +48,8 @@ Example:
|
||||
}
|
||||
|
||||
func executeRemoveInbounds(cmd *base.Command, args []string) {
|
||||
setSharedFlags(cmd)
|
||||
setSharedConfigFlags(cmd)
|
||||
api.SetSharedFlags(cmd)
|
||||
api.SetSharedConfigFlags(cmd)
|
||||
isTags := cmd.Flag.Bool("tags", false, "")
|
||||
cmd.Flag.Parse(args)
|
||||
|
||||
@ -56,7 +57,7 @@ func executeRemoveInbounds(cmd *base.Command, args []string) {
|
||||
if *isTags {
|
||||
tags = cmd.Flag.Args()
|
||||
} else {
|
||||
c, err := helpers.LoadConfig(cmd.Flag.Args(), apiConfigFormat, apiConfigRecursively)
|
||||
c, err := helpers.LoadConfig(cmd.Flag.Args(), api.ApiConfigFormat, api.ApiConfigRecursively)
|
||||
if err != nil {
|
||||
base.Fatalf("failed to load: %s", err)
|
||||
}
|
||||
@ -69,7 +70,7 @@ func executeRemoveInbounds(cmd *base.Command, args []string) {
|
||||
base.Fatalf("no inbound to remove")
|
||||
}
|
||||
|
||||
conn, ctx, close := dialAPIServer()
|
||||
conn, ctx, close := api.DialAPIServer()
|
||||
defer close()
|
||||
|
||||
client := handlerService.NewHandlerServiceClient(conn)
|
12
main/commands/all/api/jsonv4/init.go
Normal file
12
main/commands/all/api/jsonv4/init.go
Normal file
@ -0,0 +1,12 @@
|
||||
package jsonv4
|
||||
|
||||
import "github.com/v2fly/v2ray-core/v4/main/commands/all/api"
|
||||
|
||||
func init() {
|
||||
api.CmdAPI.Commands = append(api.CmdAPI.Commands,
|
||||
cmdAddInbounds,
|
||||
cmdAddOutbounds,
|
||||
cmdRemoveInbounds,
|
||||
cmdRemoveOutbounds)
|
||||
|
||||
}
|
@ -1,7 +1,8 @@
|
||||
package api
|
||||
package jsonv4
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/v2fly/v2ray-core/v4/main/commands/all/api"
|
||||
|
||||
handlerService "github.com/v2fly/v2ray-core/v4/app/proxyman/command"
|
||||
"github.com/v2fly/v2ray-core/v4/main/commands/base"
|
||||
@ -43,10 +44,10 @@ Example:
|
||||
}
|
||||
|
||||
func executeAddOutbounds(cmd *base.Command, args []string) {
|
||||
setSharedFlags(cmd)
|
||||
setSharedConfigFlags(cmd)
|
||||
api.SetSharedFlags(cmd)
|
||||
api.SetSharedConfigFlags(cmd)
|
||||
cmd.Flag.Parse(args)
|
||||
c, err := helpers.LoadConfig(cmd.Flag.Args(), apiConfigFormat, apiConfigRecursively)
|
||||
c, err := helpers.LoadConfig(cmd.Flag.Args(), api.ApiConfigFormat, api.ApiConfigRecursively)
|
||||
if err != nil {
|
||||
base.Fatalf("failed to load: %s", err)
|
||||
}
|
||||
@ -54,7 +55,7 @@ func executeAddOutbounds(cmd *base.Command, args []string) {
|
||||
base.Fatalf("no valid outbound found")
|
||||
}
|
||||
|
||||
conn, ctx, close := dialAPIServer()
|
||||
conn, ctx, close := api.DialAPIServer()
|
||||
defer close()
|
||||
|
||||
client := handlerService.NewHandlerServiceClient(conn)
|
@ -1,7 +1,8 @@
|
||||
package api
|
||||
package jsonv4
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/v2fly/v2ray-core/v4/main/commands/all/api"
|
||||
|
||||
handlerService "github.com/v2fly/v2ray-core/v4/app/proxyman/command"
|
||||
"github.com/v2fly/v2ray-core/v4/main/commands/base"
|
||||
@ -47,8 +48,8 @@ Example:
|
||||
}
|
||||
|
||||
func executeRemoveOutbounds(cmd *base.Command, args []string) {
|
||||
setSharedFlags(cmd)
|
||||
setSharedConfigFlags(cmd)
|
||||
api.SetSharedFlags(cmd)
|
||||
api.SetSharedConfigFlags(cmd)
|
||||
isTags := cmd.Flag.Bool("tags", false, "")
|
||||
cmd.Flag.Parse(args)
|
||||
|
||||
@ -56,7 +57,7 @@ func executeRemoveOutbounds(cmd *base.Command, args []string) {
|
||||
if *isTags {
|
||||
tags = cmd.Flag.Args()
|
||||
} else {
|
||||
c, err := helpers.LoadConfig(cmd.Flag.Args(), apiConfigFormat, apiConfigRecursively)
|
||||
c, err := helpers.LoadConfig(cmd.Flag.Args(), api.ApiConfigFormat, api.ApiConfigRecursively)
|
||||
if err != nil {
|
||||
base.Fatalf("failed to load: %s", err)
|
||||
}
|
||||
@ -69,7 +70,7 @@ func executeRemoveOutbounds(cmd *base.Command, args []string) {
|
||||
base.Fatalf("no outbound to remove")
|
||||
}
|
||||
|
||||
conn, ctx, close := dialAPIServer()
|
||||
conn, ctx, close := api.DialAPIServer()
|
||||
defer close()
|
||||
|
||||
client := handlerService.NewHandlerServiceClient(conn)
|
@ -16,13 +16,20 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
apiServerAddrPtr string
|
||||
apiTimeout int
|
||||
apiJSON bool
|
||||
apiConfigFormat string
|
||||
apiConfigRecursively bool
|
||||
apiServerAddrPtr string
|
||||
apiTimeout int
|
||||
apiJSON bool
|
||||
// ApiConfigFormat is an internal variable
|
||||
ApiConfigFormat string
|
||||
// ApiConfigRecursively is an internal variable
|
||||
ApiConfigRecursively bool
|
||||
)
|
||||
|
||||
// SetSharedFlags is an internal API
|
||||
func SetSharedFlags(cmd *base.Command) {
|
||||
setSharedFlags(cmd)
|
||||
}
|
||||
|
||||
func setSharedFlags(cmd *base.Command) {
|
||||
cmd.Flag.StringVar(&apiServerAddrPtr, "s", "127.0.0.1:8080", "")
|
||||
cmd.Flag.StringVar(&apiServerAddrPtr, "server", "127.0.0.1:8080", "")
|
||||
@ -31,9 +38,19 @@ func setSharedFlags(cmd *base.Command) {
|
||||
cmd.Flag.BoolVar(&apiJSON, "json", false, "")
|
||||
}
|
||||
|
||||
// SetSharedConfigFlags is an internal API
|
||||
func SetSharedConfigFlags(cmd *base.Command) {
|
||||
setSharedConfigFlags(cmd)
|
||||
}
|
||||
|
||||
func setSharedConfigFlags(cmd *base.Command) {
|
||||
cmd.Flag.StringVar(&apiConfigFormat, "format", core.FormatAuto, "")
|
||||
cmd.Flag.BoolVar(&apiConfigRecursively, "r", false, "")
|
||||
cmd.Flag.StringVar(&ApiConfigFormat, "format", core.FormatAuto, "")
|
||||
cmd.Flag.BoolVar(&ApiConfigRecursively, "r", false, "")
|
||||
}
|
||||
|
||||
// SetSharedFlags is an internal API
|
||||
func DialAPIServer() (conn *grpc.ClientConn, ctx context.Context, close func()) {
|
||||
return dialAPIServer()
|
||||
}
|
||||
|
||||
func dialAPIServer() (conn *grpc.ClientConn, ctx context.Context, close func()) {
|
||||
|
@ -12,7 +12,6 @@ func init() {
|
||||
base.RootCommand.Commands = append(
|
||||
base.RootCommand.Commands,
|
||||
api.CmdAPI,
|
||||
cmdConvert,
|
||||
cmdLove,
|
||||
tls.CmdTLS,
|
||||
cmdUUID,
|
||||
|
@ -1,12 +1,12 @@
|
||||
package all
|
||||
package jsonv4
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"github.com/pelletier/go-toml"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/pelletier/go-toml"
|
||||
"google.golang.org/protobuf/proto"
|
||||
|
||||
core "github.com/v2fly/v2ray-core/v4"
|
7
main/commands/all/jsonv4/init.go
Normal file
7
main/commands/all/jsonv4/init.go
Normal file
@ -0,0 +1,7 @@
|
||||
package jsonv4
|
||||
|
||||
import "github.com/v2fly/v2ray-core/v4/main/commands/base"
|
||||
|
||||
func init() {
|
||||
base.RegisterCommand(cmdConvert)
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user