Skip to content

Commit 90a61a5

Browse files
authored
Merge pull request #2667 from v2fly/master
merge fly
2 parents 59cd686 + 75363de commit 90a61a5

Some content is hidden

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

63 files changed

+3086
-470
lines changed

.github/workflows/docker.yaml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Release Docker Image
2+
3+
on:
4+
push:
5+
tags:
6+
- v*
7+
8+
jobs:
9+
release:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Set up Checkout
13+
uses: actions/checkout@v2
14+
15+
- name: Install Buildx and QEMU
16+
run: |
17+
export DOCKER_BUILDKIT=1
18+
docker build --platform=local -o . git://github.com/docker/buildx
19+
mkdir -p ~/.docker/cli-plugins
20+
mv buildx ~/.docker/cli-plugins/docker-buildx
21+
docker run --rm --privileged multiarch/qemu-user-static:latest --reset -p yes --credential yes
22+
docker buildx create --use --name build --node build --driver-opt network=host
23+
24+
- name: Log in to Docker Hub
25+
env:
26+
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
27+
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
28+
run: |
29+
echo "${DOCKER_PASSWORD}" | docker login --username ${DOCKER_USERNAME} --password-stdin
30+
31+
- name: Build and push Docker image
32+
env:
33+
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
34+
DOCKER_IMAGE_PLATFORM: linux/386,linux/amd64,linux/arm/v7,linux/arm64
35+
run: |
36+
DOCKER_IMAGE_NAME=$(echo $DOCKER_USERNAME | tr '[:upper:]' '[:lower:]')/v2fly-core
37+
DOCKER_IMAGE_VERSION=${GITHUB_REF#refs/*/}
38+
docker buildx build \
39+
--platform "$DOCKER_IMAGE_PLATFORM" \
40+
--output "type=image,push=true" \
41+
--tag "$DOCKER_IMAGE_NAME":"$DOCKER_IMAGE_VERSION" \
42+
--tag "$DOCKER_IMAGE_NAME":latest \
43+
--file ./Dockerfile .

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# STEP 1 build executable binary
33
############################
44
FROM golang:alpine AS builder
5-
RUN apk update && apk add --no-cache git bash wget
5+
RUN apk update && apk add --no-cache git bash wget curl
66
WORKDIR /go/src/v2ray.com/core
77
RUN git clone --progress https://github.com/v2fly/v2ray-core.git . && \
88
bash ./release/user-package.sh nosource noconf codename=$(git describe --tags) buildname=docker-fly abpathtgz=/tmp/v2ray.tgz

app/dns/dohdns.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ func NewDoHNameServer(url *url.URL, dispatcher routing.Dispatcher, clientIP net.
5858
MaxIdleConns: 30,
5959
IdleConnTimeout: 90 * time.Second,
6060
TLSHandshakeTimeout: 30 * time.Second,
61+
ForceAttemptHTTP2: true,
6162
DialContext: func(ctx context.Context, network, addr string) (net.Conn, error) {
6263
dest, err := net.ParseDestination(network + ":" + addr)
6364
if err != nil {
@@ -89,7 +90,8 @@ func NewDoHLocalNameServer(url *url.URL, clientIP net.IP) *DoHNameServer {
8990
url.Scheme = "https"
9091
s := baseDOHNameServer(url, "DOHL", clientIP)
9192
tr := &http.Transport{
92-
IdleConnTimeout: 90 * time.Second,
93+
IdleConnTimeout: 90 * time.Second,
94+
ForceAttemptHTTP2: true,
9395
DialContext: func(ctx context.Context, network, addr string) (net.Conn, error) {
9496
dest, err := net.ParseDestination(network + ":" + addr)
9597
if err != nil {

app/proxyman/inbound/inbound.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,13 @@ func NewHandler(ctx context.Context, config *core.InboundHandlerConfig) (inbound
150150
return nil, newError("not a ReceiverConfig").AtError()
151151
}
152152

153+
streamSettings := receiverSettings.StreamSettings
154+
if streamSettings != nil && streamSettings.SocketSettings != nil {
155+
ctx = session.ContextWithSockopt(ctx, &session.Sockopt{
156+
Mark: streamSettings.SocketSettings.Mark,
157+
})
158+
}
159+
153160
allocStrategy := receiverSettings.AllocationStrategy
154161
if allocStrategy == nil || allocStrategy.Type == proxyman.AllocationStrategy_Always {
155162
return NewAlwaysOnInboundHandler(ctx, tag, receiverSettings, proxySettings)

azure-pipelines.template.yml

Lines changed: 0 additions & 22 deletions
This file was deleted.

azure-pipelines.yml

Lines changed: 13 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -2,71 +2,25 @@ trigger:
22
batch: true
33
branches:
44
include:
5-
- master
6-
- dev*
7-
- refs/tags/*
5+
- master
6+
- dev*
7+
- refs/tags/*
88

9-
pr:
10-
- master
11-
- dev*
9+
pool:
10+
vmImage: 'ubuntu-latest'
1211

13-
jobs:
14-
- template: azure-pipelines.template.yml
15-
parameters:
16-
name: linux
17-
vmImage: 'ubuntu-latest'
12+
variables:
13+
- group: GithubToken
14+
- name: GOPATH
15+
value: '$(system.defaultWorkingDirectory)/gopath'
16+
- name: BAZEL_VER
17+
value: '0.23.0'
1818

19-
- template: azure-pipelines.template.yml
20-
parameters:
21-
name: windows
22-
vmImage: 'windows-latest'
23-
24-
- template: azure-pipelines.template.yml
25-
parameters:
26-
name: macos
27-
vmImage: 'macOS-latest'
28-
29-
- job: linux_coverage
30-
dependsOn: linux
31-
condition: and(succeeded(), ne(variables['Build.Reason'], 'PullRequest'))
32-
timeoutInMinutes: 30
33-
34-
pool:
35-
vmImage: 'ubuntu-latest'
36-
37-
#variables:
38-
# CODECOV_TOKEN: '$(coverage.token)'
39-
40-
41-
steps:
42-
- checkout: self
43-
- task: GoTool@0
44-
inputs:
45-
version: '1.14.4'
46-
- script: |
47-
bash ./testing/coverage/coverall
48-
workingDirectory: '$(Build.SourcesDirectory)'
49-
displayName: 'Coverage'
50-
51-
- job: make_release
52-
dependsOn: linux
53-
condition: and(succeeded(), ne(variables['Build.Reason'], 'PullRequest'))
54-
timeoutInMinutes: 60
55-
56-
pool:
57-
vmImage: 'ubuntu-latest'
58-
variables:
59-
- group: GithubToken
60-
- name: GOPATH
61-
value: '$(system.defaultWorkingDirectory)/gopath'
62-
- name: BAZEL_VER
63-
value: '0.23.0'
64-
65-
steps:
19+
steps:
6620
- checkout: self
6721
- task: GoTool@0
6822
inputs:
69-
version: '1.14.4'
23+
version: '1.14.6'
7024
- script: |
7125
mkdir triggersrc
7226
ls -I "triggersrc" | xargs cp -rf -t triggersrc

common/buf/buffer_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ func TestBufferClear(t *testing.T) {
2222

2323
buffer.Clear()
2424
if buffer.Len() != 0 {
25-
t.Error("expect 0 lenght, but got ", buffer.Len())
25+
t.Error("expect 0 length, but got ", buffer.Len())
2626
}
2727
}
2828

common/crypto/auth.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,13 +248,14 @@ func (w *AuthenticationWriter) seal(b []byte) (*buf.Buffer, error) {
248248
paddingSize = int32(w.padding.NextPaddingLen())
249249
}
250250

251-
totalSize := encryptedSize + paddingSize
251+
sizeBytes := w.sizeParser.SizeBytes()
252+
totalSize := sizeBytes + encryptedSize + paddingSize
252253
if totalSize > buf.Size {
253254
return nil, newError("size too large: ", totalSize)
254255
}
255256

256257
eb := buf.New()
257-
w.sizeParser.Encode(uint16(encryptedSize+paddingSize), eb.Extend(w.sizeParser.SizeBytes()))
258+
w.sizeParser.Encode(uint16(encryptedSize+paddingSize), eb.Extend(sizeBytes))
258259
if _, err := w.auth.Seal(eb.Extend(encryptedSize)[:0], b); err != nil {
259260
eb.Release()
260261
return nil, err

common/mux/server.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ func (s *Server) Type() interface{} {
3535
return s.dispatcher.Type()
3636
}
3737

38-
// Dispatch impliments routing.Dispatcher
38+
// Dispatch implements routing.Dispatcher
3939
func (s *Server) Dispatch(ctx context.Context, dest net.Destination) (*transport.Link, error) {
4040
if dest.Address != muxCoolAddress {
4141
return s.dispatcher.Dispatch(ctx, dest)

common/session/context.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ const (
1010
outboundSessionKey
1111
contentSessionKey
1212
muxPreferedSessionKey
13+
sockoptSessionKey
1314
)
1415

1516
// ContextWithID returns a new context with the given ID.
@@ -70,3 +71,16 @@ func MuxPreferedFromContext(ctx context.Context) bool {
7071
}
7172
return false
7273
}
74+
75+
// ContextWithSockopt returns a new context with Socket configs included
76+
func ContextWithSockopt(ctx context.Context, s *Sockopt) context.Context {
77+
return context.WithValue(ctx, sockoptSessionKey, s)
78+
}
79+
80+
// SockoptFromContext returns Socket configs in this context, or nil if not contained.
81+
func SockoptFromContext(ctx context.Context) *Sockopt {
82+
if sockopt, ok := ctx.Value(sockoptSessionKey).(*Sockopt); ok {
83+
return sockopt
84+
}
85+
return nil
86+
}

common/session/session.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,12 @@ type Content struct {
7272
SkipRoutePick bool
7373
}
7474

75+
// Sockopt is the settings for socket connection.
76+
type Sockopt struct {
77+
// Mark of the socket connection.
78+
Mark int32
79+
}
80+
7581
func (c *Content) SetAttribute(name string, value interface{}) {
7682
if c.Attributes == nil {
7783
c.Attributes = make(map[string]interface{})

core.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import (
1919
)
2020

2121
var (
22-
version = "4.26.0"
22+
version = "4.27.0"
2323
build = "Custom"
2424
codename = "V2Fly, a community-driven edition of V2Ray."
2525
intro = "A unified platform for anti-censorship."

features/stats/stats.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ type Counter interface {
2222
type Manager interface {
2323
features.Feature
2424

25-
// RegisterCounter registers a new counter to the manager. The identifier string must not be emtpy, and unique among other counters.
25+
// RegisterCounter registers a new counter to the manager. The identifier string must not be empty, and unique among other counters.
2626
RegisterCounter(string) (Counter, error)
2727
UnregisterCounter(string) error
2828
// GetCounter returns a counter by its identifier.

go.mod

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,11 @@ module v2ray.com/core
22

33
require (
44
github.com/dgryski/go-metro v0.0.0-20180109044635-280f6062b5bc // indirect
5-
github.com/golang/mock v1.4.3
5+
github.com/golang/mock v1.4.4
66
github.com/golang/protobuf v1.4.2
7-
github.com/google/go-cmp v0.5.0
7+
github.com/google/go-cmp v0.5.1
88
github.com/gorilla/websocket v1.4.2
9-
github.com/miekg/dns v1.1.29
10-
github.com/refraction-networking/utls v0.0.0-20190909200633-43c36d3c1f57
9+
github.com/miekg/dns v1.1.31
1110
github.com/seiflotfy/cuckoofilter v0.0.0-20200511222245-56093a4d3841
1211
github.com/stretchr/testify v1.6.1
1312
github.com/xiaokangwang/VSign v0.0.0-20200704130305-63f4b4d7a751
@@ -16,7 +15,7 @@ require (
1615
golang.org/x/net v0.0.0-20200602114024-627f9648deb9
1716
golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a
1817
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd
19-
google.golang.org/grpc v1.30.0
18+
google.golang.org/grpc v1.31.0
2019
google.golang.org/protobuf v1.25.0
2120
h12.io/socks v1.0.1
2221
)

go.sum

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfU
1818
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
1919
github.com/golang/mock v1.4.3 h1:GV+pQPG/EUUbkh47niozDcADz6go/dUwhVzdUQHIVRw=
2020
github.com/golang/mock v1.4.3/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw=
21+
github.com/golang/mock v1.4.4 h1:l75CXGRSwbaYNpl/Z2X1XIIAMSCquvXgpVZDhwEIJsc=
22+
github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71h+4=
2123
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
2224
github.com/golang/protobuf v1.3.2 h1:6nsPYzhq5kReh6QImI3k5qWzO4PEbvbIW2cwSfR/6xs=
2325
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
@@ -38,19 +40,23 @@ github.com/google/go-cmp v0.4.0 h1:xsAVV57WRhGj6kEIi8ReJzQlHHqcBYCElAvkovg3B/4=
3840
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
3941
github.com/google/go-cmp v0.5.0 h1:/QaMHBdZ26BB3SSst0Iwl10Epc+xhTquomWX0oZEB6w=
4042
github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
43+
github.com/google/go-cmp v0.5.1 h1:JFrFEBb2xKufg6XkJsJr+WbKb4FQlURi5RUcBveYu9k=
44+
github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
4145
github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc=
4246
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
4347
github.com/h12w/go-socks5 v0.0.0-20200522160539-76189e178364 h1:5XxdakFhqd9dnXoAZy1Mb2R/DZ6D1e+0bGC/JhucGYI=
4448
github.com/h12w/go-socks5 v0.0.0-20200522160539-76189e178364/go.mod h1:eDJQioIyy4Yn3MVivT7rv/39gAJTrA7lgmYr8EW950c=
4549
github.com/miekg/dns v1.1.29 h1:xHBEhR+t5RzcFJjBLJlax2daXOrTYtr9z4WdKEfWFzg=
4650
github.com/miekg/dns v1.1.29/go.mod h1:KNUDUusw/aVsxyTYZM1oqvCicbwhgbNgztCETuNZ7xM=
51+
github.com/miekg/dns v1.1.30 h1:Qww6FseFn8PRfw07jueqIXqodm0JKiiKuK0DeXSqfyo=
52+
github.com/miekg/dns v1.1.30/go.mod h1:KNUDUusw/aVsxyTYZM1oqvCicbwhgbNgztCETuNZ7xM=
53+
github.com/miekg/dns v1.1.31 h1:sJFOl9BgwbYAWOGEwr61FU28pqsBNdpRBnhGXtO06Oo=
54+
github.com/miekg/dns v1.1.31/go.mod h1:KNUDUusw/aVsxyTYZM1oqvCicbwhgbNgztCETuNZ7xM=
4755
github.com/phayes/freeport v0.0.0-20180830031419-95f893ade6f2 h1:JhzVVoYvbOACxoUmOs6V/G4D5nPVUW73rKvXxP4XUJc=
4856
github.com/phayes/freeport v0.0.0-20180830031419-95f893ade6f2/go.mod h1:iIss55rKnNBTvrwdmkUpLnDpZoAHvWaiq5+iMmen4AE=
4957
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
5058
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
5159
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
52-
github.com/refraction-networking/utls v0.0.0-20190909200633-43c36d3c1f57 h1:SL1K0QAuC1b54KoY1pjPWe6kSlsFHwK9/oC960fKrTY=
53-
github.com/refraction-networking/utls v0.0.0-20190909200633-43c36d3c1f57/go.mod h1:tz9gX959MEFfFN5whTIocCLUG57WiILqtdVxI8c6Wj0=
5460
github.com/seiflotfy/cuckoofilter v0.0.0-20200511222245-56093a4d3841 h1:pnfutQFsV7ySmHUeX6ANGfPsBo29RctUvDn8G3rmJVw=
5561
github.com/seiflotfy/cuckoofilter v0.0.0-20200511222245-56093a4d3841/go.mod h1:ET5mVvNjwaGXRgZxO9UZr7X+8eAf87AfIYNwRSp9s4Y=
5662
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
@@ -126,6 +132,8 @@ google.golang.org/grpc v1.27.0 h1:rRYRFMVgRv6E0D70Skyfsr28tDXIuuPZyWGMPdMcnXg=
126132
google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
127133
google.golang.org/grpc v1.30.0 h1:M5a8xTlYTxwMn5ZFkwhRabsygDY5G8TYLyQDBxJNAxE=
128134
google.golang.org/grpc v1.30.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak=
135+
google.golang.org/grpc v1.31.0 h1:T7P4R73V3SSDPhH7WW7ATbfViLtmamH0DKrP3f9AuDI=
136+
google.golang.org/grpc v1.31.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak=
129137
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
130138
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
131139
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=

infra/bazel/build.bzl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ def _go_command(ctx):
33
if ctx.attr.os == "windows":
44
output = output + ".exe"
55

6-
output_file = ctx.actions.declare_file(ctx.attr.os + "/" + ctx.attr.arch + "/" + output)
6+
output_file = ctx.actions.declare_file(ctx.attr.os + "/" + ctx.attr.arch + "/" + ctx.attr.ver + "/" + output)
77
pkg = ctx.attr.pkg
88

99
ld_flags = "-s -w"
@@ -61,6 +61,7 @@ foreign_go_binary = rule(
6161
'output': attr.string(),
6262
'os': attr.string(mandatory=True),
6363
'arch': attr.string(mandatory=True),
64+
'ver': attr.string(mandatory=True),
6465
'mips': attr.string(),
6566
'arm': attr.string(),
6667
'ld': attr.string(),

0 commit comments

Comments
 (0)