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+
}

0 commit comments

Comments
 (0)