Skip to content

Commit 98911dc

Browse files
committed
Merge branch 'master' of https://github.com/v2fly/v2ray-core into v2fly-master
2 parents 9997567 + c50fef4 commit 98911dc

File tree

345 files changed

+1581
-37215
lines changed

Some content is hidden

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

345 files changed

+1581
-37215
lines changed

.github/linters/.golangci.yml

+4-20
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,23 @@
11
run:
22
timeout: 5m
3-
skip-dirs:
4-
- external
53
skip-files:
64
- generated.*
75

86
issues:
97
new: true
10-
exclude-rules:
11-
- path: _test\.go
12-
linters:
13-
- gocyclo
14-
- errcheck
15-
- dupl
16-
- gosec
17-
- goconst
188

199
linters:
2010
enable:
2111
- bodyclose
22-
- deadcode
2312
- depguard
24-
- dogsled
25-
- dupl
26-
- errcheck
27-
- exhaustive
28-
- goconst
2913
- gocritic
30-
- gocyclo
3114
- gofmt
3215
- goimports
3316
- golint
3417
- goprintffuncname
35-
- gosec
3618
- gosimple
3719
- govet
3820
- ineffassign
39-
- interfacer
4021
- misspell
4122
- nakedret
4223
- noctx
@@ -49,6 +30,9 @@ linters:
4930
- typecheck
5031
- unconvert
5132
- unparam
52-
- unused
5333
- varcheck
5434
- whitespace
35+
disable:
36+
- deadcode
37+
- errcheck
38+
- unused

.github/workflows/codeql-analysis.yml

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ on:
1515

1616
jobs:
1717
analyze:
18+
if: github.repository != 'v2ray/v2ray-core'
1819
runs-on: ubuntu-latest
1920
strategy:
2021
fail-fast: false

.github/workflows/coverage.yml

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ on:
88

99
jobs:
1010
coverage:
11+
if: github.repository != 'v2ray/v2ray-core'
1112
runs-on: ubuntu-latest
1213
steps:
1314
- name: Set up Go 1.x

.github/workflows/linter.yml

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ on:
1313

1414
jobs:
1515
lint:
16+
if: github.repository != 'v2ray/v2ray-core'
1617
runs-on: ubuntu-latest
1718
steps:
1819
- name: Set up Go 1.x

.github/workflows/sign.yml

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ on:
66

77
jobs:
88
sign:
9+
if: github.repository != 'v2ray/v2ray-core'
910
runs-on: ubuntu-latest
1011
steps:
1112
- name: Checkout default branch

.github/workflows/stale.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ jobs:
1414
stale-issue-message: "This issue is stale because it has been open 120 days with no activity. Remove stale label or comment or this will be closed in 5 days"
1515
stale-pr-message: 'It has been open 120 days with no activity. Remove stale label or comment or this will be closed in 5 days'
1616
days-before-stale: 120
17-
days-before-close: 5
17+
days-before-close: 5

.github/workflows/test.yml

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ on:
1717

1818
jobs:
1919
test:
20+
if: github.repository != 'v2ray/v2ray-core'
2021
runs-on: ${{ matrix.os }}
2122
strategy:
2223
matrix:

.github/workflows/updateGeofile.yml

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ on:
66

77
jobs:
88
update:
9+
if: github.repository == 'v2fly/v2ray-core'
910
runs-on: ubuntu-latest
1011
steps:
1112
- name: Checkout codebase

Dockerfile

+4-3
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@
22
# STEP 1 build executable binary
33
############################
44
FROM golang:alpine AS builder
5+
56
RUN apk update && apk add --no-cache git bash wget curl
6-
WORKDIR /go/src/v2ray.com/core
7+
WORKDIR /build
78
RUN git clone --progress https://github.com/v2fly/v2ray-core.git . && \
8-
bash ./release/user-package.sh nosource noconf codename=$(git describe --tags) buildname=docker-fly abpathtgz=/tmp/v2ray.tgz
9+
bash ./release/user-package.sh nosource noconf codename=$(git describe --abbrev=0 --tags) buildname=docker-fly abpathtgz=/tmp/v2ray.tgz
10+
911
############################
1012
# STEP 2 build a small image
1113
############################
@@ -20,4 +22,3 @@ RUN apk update && apk add ca-certificates && \
2022
#ENTRYPOINT ["/usr/bin/v2ray/v2ray"]
2123
ENV PATH /usr/bin/v2ray:$PATH
2224
CMD ["v2ray", "-config=/etc/v2ray/config.json"]
23-

LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright (c) 2015-2020 V2Ray
3+
Copyright (c) 2015-2020 V2Fly Community
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

+18-16
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,21 @@
33
***
44

55
# Project V
6-
![](https://github.com/v2fly/v2ray-core/workflows/Test/badge.svg)
7-
[![codecov.io][3]][4] [![GoDoc][5]][6] [![codebeat][7]][8] [![Downloads][9]][10] [![Downloads][11]][12]
86

9-
[3]: https://codecov.io/gh/v2fly/v2ray-core/branch/master/graph/badge.svg?branch=master "Coverage badge"
7+
[![GitHub Test Badge][1]][2] [![codecov.io][3]][4] [![GoDoc][5]][6] [![codebeat][7]][8] [![Downloads][9]][10] [![Downloads][11]][12]
8+
9+
[1]: https://github.com/v2fly/v2ray-core/workflows/Test/badge.svg "GitHub Test Badge"
10+
[2]: https://github.com/v2fly/v2ray-core/actions "GitHub Actions Page"
11+
[3]: https://codecov.io/gh/v2fly/v2ray-core/branch/master/graph/badge.svg?branch=master "Coverage Badge"
1012
[4]: https://codecov.io/gh/v2fly/v2ray-core?branch=master "Codecov Status"
11-
[5]: https://godoc.org/v2ray.com/core?status.svg "GoDoc badge"
13+
[5]: https://godoc.org/v2ray.com/core?status.svg "GoDoc Badge"
1214
[6]: https://godoc.org/v2ray.com/core "GoDoc"
13-
[7]: https://codebeat.co/badges/f2354ca8-3e24-463d-a2e3-159af73b2477 "Codebeat badge"
14-
[8]: https://codebeat.co/projects/github-com-v2ray-v2ray-core-master "Codebeat"
15-
[9]: https://img.shields.io/github/downloads/v2ray/v2ray-core/total.svg "All releases badge"
16-
[10]: https://github.com/v2ray/v2ray-core/releases/ "All releases number"
17-
[11]: https://img.shields.io/github/downloads/v2fly/v2ray-core/total.svg "All releases badge"
18-
[12]: https://github.com/v2fly/v2ray-core/releases/ "All releases number"
15+
[7]: https://goreportcard.com/badge/github.com/v2fly/v2ray-core "Goreportcard Badge"
16+
[8]: https://goreportcard.com/report/github.com/v2fly/v2ray-core "Goreportcard Result"
17+
[9]: https://img.shields.io/github/downloads/v2ray/v2ray-core/total.svg "v2ray/v2ray-core downloads count"
18+
[10]: https://github.com/v2ray/v2ray-core/releases "v2ray/v2ray-core release page"
19+
[11]: https://img.shields.io/github/downloads/v2fly/v2ray-core/total.svg "v2fly/v2ray-core downloads count"
20+
[12]: https://github.com/v2fly/v2ray-core/releases "v2fly/v2ray-core release page"
1921

2022
Project V is a set of network tools that help you to build your own computer network. It secures your network connections and thus protects your privacy. See [our website](https://www.v2fly.org/) for more information.
2123

@@ -27,9 +29,9 @@ Project V is a set of network tools that help you to build your own computer net
2729

2830
This repo relies on the following third-party projects:
2931

30-
* In production:
31-
* [gorilla/websocket](https://github.com/gorilla/websocket)
32-
* [gRPC](https://google.golang.org/grpc)
33-
* For testing only:
34-
* [miekg/dns](https://github.com/miekg/dns)
35-
* [h12w/socks](https://github.com/h12w/socks)
32+
- In production:
33+
- [gorilla/websocket](https://github.com/gorilla/websocket)
34+
- [gRPC](https://google.golang.org/grpc)
35+
- For testing only:
36+
- [miekg/dns](https://github.com/miekg/dns)
37+
- [h12w/socks](https://github.com/h12w/socks)

app/commander/commander.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
package commander
44

5-
//go:generate errorgen
5+
//go:generate go run v2ray.com/core/common/errors/errorgen
66

77
import (
88
"context"

app/commander/config.pb.go

+2-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/commander/config.proto

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import "common/serial/typed_message.proto";
1212
message Config {
1313
// Tag of the outbound handler that handles grpc connections.
1414
string tag = 1;
15-
// Services that supported by this server. All services must implement Service interface.
15+
// Services that supported by this server. All services must implement Service
16+
// interface.
1617
repeated v2ray.core.common.serial.TypedMessage service = 2;
1718
}

app/dispatcher/config.proto

-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ option java_multiple_files = true;
88

99
message SessionConfig {
1010
reserved 1;
11-
1211
}
1312

1413
message Config {

app/dispatcher/default.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
package dispatcher
44

5-
//go:generate errorgen
5+
//go:generate go run v2ray.com/core/common/errors/errorgen
66

77
import (
88
"context"

app/dispatcher/dispatcher.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33
package dispatcher
44

5-
//go:generate errorgen
5+
//go:generate go run v2ray.com/core/common/errors/errorgen

app/dns/config.pb.go

+8-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/dns/config.proto

+8-5
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,9 @@ enum DomainMatchingType {
3636
}
3737

3838
message Config {
39-
// Nameservers used by this DNS. Only traditional UDP servers are support at the moment.
40-
// A special value 'localhost' as a domain address can be set to use DNS on local system.
39+
// Nameservers used by this DNS. Only traditional UDP servers are support at
40+
// the moment. A special value 'localhost' as a domain address can be set to
41+
// use DNS on local system.
4142
repeated v2ray.core.common.net.Endpoint NameServers = 1 [deprecated = true];
4243

4344
// NameServer list used by this DNS client.
@@ -47,7 +48,8 @@ message Config {
4748
// Deprecated. Use static_hosts.
4849
map<string, v2ray.core.common.net.IPOrDomain> Hosts = 2 [deprecated = true];
4950

50-
// Client IP for EDNS client subnet. Must be 4 bytes (IPv4) or 16 bytes (IPv6).
51+
// Client IP for EDNS client subnet. Must be 4 bytes (IPv4) or 16 bytes
52+
// (IPv6).
5153
bytes client_ip = 3;
5254

5355
message HostMapping {
@@ -56,8 +58,9 @@ message Config {
5658

5759
repeated bytes ip = 3;
5860

59-
// ProxiedDomain indicates the mapped domain has the same IP address on this domain. V2Ray will use this domain for IP queries.
60-
// This field is only effective if ip is empty.
61+
// ProxiedDomain indicates the mapped domain has the same IP address on this
62+
// domain. V2Ray will use this domain for IP queries. This field is only
63+
// effective if ip is empty.
6164
string proxied_domain = 4;
6265
}
6366

app/dns/dns.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
// Package dns is an implementation of core.DNS feature.
22
package dns
33

4-
//go:generate errorgen
4+
//go:generate go run v2ray.com/core/common/errors/errorgen

app/dns/dohdns.go

+4-7
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,14 @@ import (
1414
"sync/atomic"
1515
"time"
1616

17-
dns_feature "v2ray.com/core/features/dns"
18-
1917
"golang.org/x/net/dns/dnsmessage"
2018
"v2ray.com/core/common"
2119
"v2ray.com/core/common/net"
2220
"v2ray.com/core/common/protocol/dns"
2321
"v2ray.com/core/common/session"
2422
"v2ray.com/core/common/signal/pubsub"
2523
"v2ray.com/core/common/task"
24+
dns_feature "v2ray.com/core/features/dns"
2625
"v2ray.com/core/features/routing"
2726
"v2ray.com/core/transport/internet"
2827
)
@@ -221,13 +220,11 @@ func (s *DoHNameServer) sendQuery(ctx context.Context, domain string, option IPO
221220
if d, ok := ctx.Deadline(); ok {
222221
deadline = d
223222
} else {
224-
deadline = time.Now().Add(time.Second * 8)
223+
deadline = time.Now().Add(time.Second * 5)
225224
}
226225

227226
for _, req := range reqs {
228-
229227
go func(r *dnsRequest) {
230-
231228
// generate new context for each req, using same context
232229
// may cause reqs all aborted if any one encounter an error
233230
dnsCtx := context.Background()
@@ -245,7 +242,8 @@ func (s *DoHNameServer) sendQuery(ctx context.Context, domain string, option IPO
245242
// forced to use mux for DOH
246243
dnsCtx = session.ContextWithMuxPrefered(dnsCtx, true)
247244

248-
dnsCtx, cancel := context.WithDeadline(dnsCtx, deadline)
245+
var cancel context.CancelFunc
246+
dnsCtx, cancel = context.WithDeadline(dnsCtx, deadline)
249247
defer cancel()
250248

251249
b, err := dns.PackMessage(r.msg)
@@ -269,7 +267,6 @@ func (s *DoHNameServer) sendQuery(ctx context.Context, domain string, option IPO
269267
}
270268

271269
func (s *DoHNameServer) dohHTTPSContext(ctx context.Context, b []byte) ([]byte, error) {
272-
273270
body := bytes.NewBuffer(b)
274271
req, err := http.NewRequest("POST", s.dohURL, body)
275272
if err != nil {

app/dns/server.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
package dns
44

5-
//go:generate errorgen
5+
//go:generate go run v2ray.com/core/common/errors/errorgen
66

77
import (
88
"context"
@@ -209,7 +209,7 @@ func New(ctx context.Context, config *Config) (*Server, error) {
209209
ruleIter = 0
210210
ruleCurr++
211211
}
212-
} else { // No original rule, generate one according to current domain matcher (majorly for compability with tests)
212+
} else { // No original rule, generate one according to current domain matcher (majorly for compatibility with tests)
213213
info.domainRuleIdx = uint16(len(rules))
214214
rules = append(rules, matcher.String())
215215
}

app/log/command/command.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
package command
44

5-
//go:generate errorgen
5+
//go:generate go run v2ray.com/core/common/errors/errorgen
66

77
import (
88
"context"

0 commit comments

Comments
 (0)