1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-09-27 22:36:12 -04:00

apply coding style

This commit is contained in:
Shelikhoo 2021-04-08 20:56:04 +01:00
parent 5a61749328
commit 459a914ab7
No known key found for this signature in database
GPG Key ID: C4D5E79D22B25316
8 changed files with 38 additions and 28 deletions

View File

@ -2,11 +2,13 @@ package command
import ( import (
"context" "context"
"google.golang.org/grpc"
core "github.com/v2fly/v2ray-core/v4" core "github.com/v2fly/v2ray-core/v4"
"github.com/v2fly/v2ray-core/v4/app/observatory" "github.com/v2fly/v2ray-core/v4/app/observatory"
"github.com/v2fly/v2ray-core/v4/common" "github.com/v2fly/v2ray-core/v4/common"
"github.com/v2fly/v2ray-core/v4/features/extension" "github.com/v2fly/v2ray-core/v4/features/extension"
"google.golang.org/grpc"
) )
type service struct { type service struct {

View File

@ -1,13 +1,12 @@
// Code generated by protoc-gen-go. DO NOT EDIT. // Code generated by protoc-gen-go. DO NOT EDIT.
// versions: // versions:
// protoc-gen-go v1.25.0 // protoc-gen-go v1.26.0
// protoc v3.13.0 // protoc v3.15.6
// source: app/observatory/command/command.proto // source: app/observatory/command/command.proto
package command package command
import ( import (
proto "github.com/golang/protobuf/proto"
observatory "github.com/v2fly/v2ray-core/v4/app/observatory" observatory "github.com/v2fly/v2ray-core/v4/app/observatory"
protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl" protoimpl "google.golang.org/protobuf/runtime/protoimpl"
@ -22,10 +21,6 @@ const (
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
) )
// This is a compile-time assertion that a sufficiently up-to-date version
// of the legacy proto package is being used.
const _ = proto.ProtoPackageIsVersion4
type GetOutboundStatusRequest struct { type GetOutboundStatusRequest struct {
state protoimpl.MessageState state protoimpl.MessageState
sizeCache protoimpl.SizeCache sizeCache protoimpl.SizeCache

View File

@ -1,13 +1,12 @@
// Code generated by protoc-gen-go. DO NOT EDIT. // Code generated by protoc-gen-go. DO NOT EDIT.
// versions: // versions:
// protoc-gen-go v1.25.0 // protoc-gen-go v1.26.0
// protoc v3.13.0 // protoc v3.15.6
// source: app/observatory/config.proto // source: app/observatory/config.proto
package observatory package observatory
import ( import (
proto "github.com/golang/protobuf/proto"
protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl" protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect" reflect "reflect"
@ -21,10 +20,6 @@ const (
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
) )
// This is a compile-time assertion that a sufficiently up-to-date version
// of the legacy proto package is being used.
const _ = proto.ProtoPackageIsVersion4
type ObservationResult struct { type ObservationResult struct {
state protoimpl.MessageState state protoimpl.MessageState
sizeCache protoimpl.SizeCache sizeCache protoimpl.SizeCache

View File

@ -4,7 +4,14 @@ package observatory
import ( import (
"context" "context"
"net"
"net/http"
"net/url"
"sync"
"time"
"github.com/golang/protobuf/proto" "github.com/golang/protobuf/proto"
core "github.com/v2fly/v2ray-core/v4" core "github.com/v2fly/v2ray-core/v4"
"github.com/v2fly/v2ray-core/v4/common" "github.com/v2fly/v2ray-core/v4/common"
v2net "github.com/v2fly/v2ray-core/v4/common/net" v2net "github.com/v2fly/v2ray-core/v4/common/net"
@ -14,11 +21,6 @@ import (
"github.com/v2fly/v2ray-core/v4/features/extension" "github.com/v2fly/v2ray-core/v4/features/extension"
"github.com/v2fly/v2ray-core/v4/features/outbound" "github.com/v2fly/v2ray-core/v4/features/outbound"
"github.com/v2fly/v2ray-core/v4/transport/internet/tagged" "github.com/v2fly/v2ray-core/v4/transport/internet/tagged"
"net"
"net/http"
"net/url"
"sync"
"time"
) )
type Observer struct { type Observer struct {

View File

@ -160,9 +160,21 @@ func (rr *RoutingRule) BuildCondition() (Condition, error) {
} }
func (br *BalancingRule) Build(ohm outbound.Manager) (*Balancer, error) { func (br *BalancingRule) Build(ohm outbound.Manager) (*Balancer, error) {
return &Balancer{ switch br.Strategy {
selectors: br.OutboundSelector, case "leastPing":
strategy: &RandomStrategy{}, return &Balancer{
ohm: ohm, selectors: br.OutboundSelector,
}, nil strategy: &LeastPingStrategy{},
ohm: ohm,
}, nil
case "random":
fallthrough
default:
return &Balancer{
selectors: br.OutboundSelector,
strategy: &RandomStrategy{},
ohm: ohm,
}, nil
}
} }

View File

@ -1,9 +1,10 @@
package conf package conf
import ( import (
"strings"
"github.com/jhump/protoreflect/desc" "github.com/jhump/protoreflect/desc"
"github.com/jhump/protoreflect/dynamic" "github.com/jhump/protoreflect/dynamic"
"strings"
"github.com/v2fly/v2ray-core/v4/app/commander" "github.com/v2fly/v2ray-core/v4/app/commander"
loggerservice "github.com/v2fly/v2ray-core/v4/app/log/command" loggerservice "github.com/v2fly/v2ray-core/v4/app/log/command"

View File

@ -2,9 +2,11 @@ package conf
import ( import (
"encoding/json" "encoding/json"
"github.com/golang/protobuf/jsonpb" "github.com/golang/protobuf/jsonpb"
"github.com/jhump/protoreflect/desc" "github.com/jhump/protoreflect/desc"
"github.com/jhump/protoreflect/dynamic" "github.com/jhump/protoreflect/dynamic"
"github.com/v2fly/v2ray-core/v4/common/serial" "github.com/v2fly/v2ray-core/v4/common/serial"
) )

View File

@ -2,12 +2,13 @@ package conf
import ( import (
"encoding/json" "encoding/json"
"google.golang.org/protobuf/reflect/protoreflect"
"google.golang.org/protobuf/reflect/protoregistry"
"log" "log"
"os" "os"
"strings" "strings"
"google.golang.org/protobuf/reflect/protoreflect"
"google.golang.org/protobuf/reflect/protoregistry"
core "github.com/v2fly/v2ray-core/v4" core "github.com/v2fly/v2ray-core/v4"
"github.com/v2fly/v2ray-core/v4/app/dispatcher" "github.com/v2fly/v2ray-core/v4/app/dispatcher"
"github.com/v2fly/v2ray-core/v4/app/proxyman" "github.com/v2fly/v2ray-core/v4/app/proxyman"