mirror of
https://github.com/v2fly/v2ray-core.git
synced 2024-11-02 17:27:50 -04:00
Fix according to go vet results
This commit is contained in:
parent
30edcef67a
commit
f9175e3bc8
@ -50,8 +50,8 @@ func (p *Policy) overrideWith(another *Policy) {
|
||||
p.Timeout.overrideWith(another.Timeout)
|
||||
}
|
||||
if another.Stats != nil && p.Stats == nil {
|
||||
p.Stats = new(Policy_Stats)
|
||||
*p.Stats = *another.Stats
|
||||
p.Stats = &Policy_Stats{}
|
||||
p.Stats = another.Stats
|
||||
}
|
||||
if another.Buffer != nil {
|
||||
p.Buffer = &Policy_Buffer{
|
||||
|
@ -44,17 +44,17 @@ func (p Port) String() string {
|
||||
}
|
||||
|
||||
// FromPort returns the beginning port of this PortRange.
|
||||
func (p PortRange) FromPort() Port {
|
||||
func (p *PortRange) FromPort() Port {
|
||||
return Port(p.From)
|
||||
}
|
||||
|
||||
// ToPort returns the end port of this PortRange.
|
||||
func (p PortRange) ToPort() Port {
|
||||
func (p *PortRange) ToPort() Port {
|
||||
return Port(p.To)
|
||||
}
|
||||
|
||||
// Contains returns true if the given port is within the range of a PortRange.
|
||||
func (p PortRange) Contains(port Port) bool {
|
||||
func (p *PortRange) Contains(port Port) bool {
|
||||
return p.FromPort() <= port && port <= p.ToPort()
|
||||
}
|
||||
|
||||
|
@ -58,7 +58,7 @@ func NewServerSpec(dest net.Destination, valid ValidationStrategy, users ...*Mem
|
||||
}
|
||||
}
|
||||
|
||||
func NewServerSpecFromPB(spec ServerEndpoint) (*ServerSpec, error) {
|
||||
func NewServerSpecFromPB(spec *ServerEndpoint) (*ServerSpec, error) {
|
||||
dest := net.TCPDestination(spec.Address.AsAddress(), net.Port(spec.Port))
|
||||
mUsers := make([]*MemoryUser, len(spec.User))
|
||||
for idx, u := range spec.User {
|
||||
|
@ -135,7 +135,7 @@ func TestUDPDNSTunnel(t *testing.T) {
|
||||
m1.Id = dns.Id()
|
||||
m1.RecursionDesired = true
|
||||
m1.Question = make([]dns.Question, 1)
|
||||
m1.Question[0] = dns.Question{"google.com.", dns.TypeA, dns.ClassINET}
|
||||
m1.Question[0] = dns.Question{Name: "google.com.", Qtype: dns.TypeA, Qclass: dns.ClassINET}
|
||||
|
||||
c := new(dns.Client)
|
||||
in, _, err := c.Exchange(m1, "127.0.0.1:"+strconv.Itoa(int(serverPort)))
|
||||
@ -159,7 +159,7 @@ func TestUDPDNSTunnel(t *testing.T) {
|
||||
m1.Id = dns.Id()
|
||||
m1.RecursionDesired = true
|
||||
m1.Question = make([]dns.Question, 1)
|
||||
m1.Question[0] = dns.Question{"ipv4only.google.com.", dns.TypeAAAA, dns.ClassINET}
|
||||
m1.Question[0] = dns.Question{Name: "ipv4only.google.com.", Qtype: dns.TypeAAAA, Qclass: dns.ClassINET}
|
||||
|
||||
c := new(dns.Client)
|
||||
c.Timeout = 10 * time.Second
|
||||
@ -176,7 +176,7 @@ func TestUDPDNSTunnel(t *testing.T) {
|
||||
m1.Id = dns.Id()
|
||||
m1.RecursionDesired = true
|
||||
m1.Question = make([]dns.Question, 1)
|
||||
m1.Question[0] = dns.Question{"notexist.google.com.", dns.TypeAAAA, dns.ClassINET}
|
||||
m1.Question[0] = dns.Question{Name: "notexist.google.com.", Qtype: dns.TypeAAAA, Qclass: dns.ClassINET}
|
||||
|
||||
c := new(dns.Client)
|
||||
in, _, err := c.Exchange(m1, "127.0.0.1:"+strconv.Itoa(int(serverPort)))
|
||||
@ -253,7 +253,7 @@ func TestTCPDNSTunnel(t *testing.T) {
|
||||
m1.Id = dns.Id()
|
||||
m1.RecursionDesired = true
|
||||
m1.Question = make([]dns.Question, 1)
|
||||
m1.Question[0] = dns.Question{"google.com.", dns.TypeA, dns.ClassINET}
|
||||
m1.Question[0] = dns.Question{Name: "google.com.", Qtype: dns.TypeA, Qclass: dns.ClassINET}
|
||||
|
||||
c := &dns.Client{
|
||||
Net: "tcp",
|
||||
@ -343,7 +343,7 @@ func TestUDP2TCPDNSTunnel(t *testing.T) {
|
||||
m1.Id = dns.Id()
|
||||
m1.RecursionDesired = true
|
||||
m1.Question = make([]dns.Question, 1)
|
||||
m1.Question[0] = dns.Question{"google.com.", dns.TypeA, dns.ClassINET}
|
||||
m1.Question[0] = dns.Question{Name: "google.com.", Qtype: dns.TypeA, Qclass: dns.ClassINET}
|
||||
|
||||
c := &dns.Client{
|
||||
Net: "tcp",
|
||||
|
@ -39,12 +39,12 @@ func init() {
|
||||
type Handler struct {
|
||||
policyManager policy.Manager
|
||||
dns dns.Client
|
||||
config Config
|
||||
config *Config
|
||||
}
|
||||
|
||||
// Init initializes the Handler with necessary parameters.
|
||||
func (h *Handler) Init(config *Config, pm policy.Manager, d dns.Client) error {
|
||||
h.config = *config
|
||||
h.config = config
|
||||
h.policyManager = pm
|
||||
h.dns = d
|
||||
|
||||
|
@ -48,7 +48,7 @@ var (
|
||||
func NewClient(ctx context.Context, config *ClientConfig) (*Client, error) {
|
||||
serverList := protocol.NewServerList()
|
||||
for _, rec := range config.Server {
|
||||
s, err := protocol.NewServerSpecFromPB(*rec)
|
||||
s, err := protocol.NewServerSpecFromPB(rec)
|
||||
if err != nil {
|
||||
return nil, newError("failed to get server spec").Base(err)
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ type Client struct {
|
||||
func NewClient(ctx context.Context, config *ClientConfig) (*Client, error) {
|
||||
serverList := protocol.NewServerList()
|
||||
for _, rec := range config.Server {
|
||||
s, err := protocol.NewServerSpecFromPB(*rec)
|
||||
s, err := protocol.NewServerSpecFromPB(rec)
|
||||
if err != nil {
|
||||
return nil, newError("failed to parse server spec").Base(err)
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ import (
|
||||
)
|
||||
|
||||
type Server struct {
|
||||
config ServerConfig
|
||||
config *ServerConfig
|
||||
user *protocol.MemoryUser
|
||||
policyManager policy.Manager
|
||||
}
|
||||
@ -41,7 +41,7 @@ func NewServer(ctx context.Context, config *ServerConfig) (*Server, error) {
|
||||
|
||||
v := core.MustFromContext(ctx)
|
||||
s := &Server{
|
||||
config: *config,
|
||||
config: config,
|
||||
user: mUser,
|
||||
policyManager: v.GetFeature(policy.ManagerType()).(policy.Manager),
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ type Client struct {
|
||||
func NewClient(ctx context.Context, config *ClientConfig) (*Client, error) {
|
||||
serverList := protocol.NewServerList()
|
||||
for _, rec := range config.Server {
|
||||
s, err := protocol.NewServerSpecFromPB(*rec)
|
||||
s, err := protocol.NewServerSpecFromPB(rec)
|
||||
if err != nil {
|
||||
return nil, newError("failed to get server spec").Base(err)
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ func New(ctx context.Context, config *Config) (*Handler, error) {
|
||||
|
||||
serverList := protocol.NewServerList()
|
||||
for _, rec := range config.Receiver {
|
||||
s, err := protocol.NewServerSpecFromPB(*rec)
|
||||
s, err := protocol.NewServerSpecFromPB(rec)
|
||||
if err != nil {
|
||||
return nil, newError("failed to parse server spec").Base(err).AtError()
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ type Handler struct {
|
||||
func New(ctx context.Context, config *Config) (*Handler, error) {
|
||||
serverList := protocol.NewServerList()
|
||||
for _, rec := range config.Receiver {
|
||||
s, err := protocol.NewServerSpecFromPB(*rec)
|
||||
s, err := protocol.NewServerSpecFromPB(rec)
|
||||
if err != nil {
|
||||
return nil, newError("failed to parse server spec").Base(err)
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ type Listener struct {
|
||||
server *http.Server
|
||||
handler internet.ConnHandler
|
||||
local net.Addr
|
||||
config Config
|
||||
config *Config
|
||||
}
|
||||
|
||||
func (l *Listener) Addr() net.Addr {
|
||||
@ -102,7 +102,7 @@ func Listen(ctx context.Context, address net.Address, port net.Port, streamSetti
|
||||
IP: address.IP(),
|
||||
Port: int(port),
|
||||
},
|
||||
config: *httpSettings,
|
||||
config: httpSettings,
|
||||
}
|
||||
|
||||
var server *http.Server
|
||||
|
Loading…
Reference in New Issue
Block a user