Skip to content

Commit 3628ca4

Browse files
authored
Merge pull request #2582 from v2fly/master
merge fly
2 parents f9935d0 + d6cad0b commit 3628ca4

File tree

24 files changed

+170
-349
lines changed

24 files changed

+170
-349
lines changed

.github/workflows/linter.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Lint Code Base
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
pull_request:
7+
branches: [ master ]
8+
9+
jobs:
10+
build:
11+
name: Lint Code Base
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- name: Checkout Code
16+
uses: actions/checkout@v2
17+
18+
- name: Lint Code Base
19+
uses: github/[email protected]
20+
env:
21+
VALIDATE_ALL_CODEBASE: false

.github/workflows/test.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Test
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
pull_request:
7+
branches: [ master ]
8+
9+
jobs:
10+
11+
build:
12+
name: Test
13+
runs-on: ${{ matrix.os }}
14+
strategy:
15+
matrix:
16+
os: [windows-latest, ubuntu-latest, macos-latest]
17+
18+
steps:
19+
20+
- name: Set up Go 1.x
21+
uses: actions/setup-go@v2
22+
with:
23+
go-version: ^1.14
24+
id: go
25+
26+
- name: Check out code into the Go module directory
27+
uses: actions/checkout@v2
28+
29+
- name: Get dependencies
30+
run: |
31+
go get -v -t -d ./...
32+
33+
- name: Test
34+
run: go test -parallel 1 -timeout 6h -v ./...

.vscode/settings.json

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

.vscode/tasks.json

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

app/proxyman/inbound/always.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ func NewAlwaysOnInboundHandler(ctx context.Context, tag string, receiverConfig *
103103
sniffingConfig: receiverConfig.GetEffectiveSniffingSettings(),
104104
uplinkCounter: uplinkCounter,
105105
downlinkCounter: downlinkCounter,
106+
ctx: ctx,
106107
}
107108
h.workers = append(h.workers, worker)
108109
}

app/proxyman/inbound/dynamic.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ type DynamicInboundHandler struct {
2828
lastRefresh time.Time
2929
mux *mux.Server
3030
task *task.Periodic
31+
32+
ctx context.Context
3133
}
3234

3335
func NewDynamicInboundHandler(ctx context.Context, tag string, receiverConfig *proxyman.ReceiverConfig, proxyConfig interface{}) (*DynamicInboundHandler, error) {
@@ -39,6 +41,7 @@ func NewDynamicInboundHandler(ctx context.Context, tag string, receiverConfig *p
3941
portsInUse: make(map[net.Port]bool),
4042
mux: mux.NewServer(ctx),
4143
v: v,
44+
ctx: ctx,
4245
}
4346

4447
mss, err := internet.ToMemoryStreamConfig(receiverConfig.StreamSettings)
@@ -134,6 +137,7 @@ func (h *DynamicInboundHandler) refresh() error {
134137
sniffingConfig: h.receiverConfig.GetEffectiveSniffingSettings(),
135138
uplinkCounter: uplinkCounter,
136139
downlinkCounter: downlinkCounter,
140+
ctx: h.ctx,
137141
}
138142
if err := worker.Start(); err != nil {
139143
newError("failed to create TCP worker").Base(err).AtWarning().WriteToLog()

app/proxyman/inbound/worker.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ type tcpWorker struct {
4343
downlinkCounter stats.Counter
4444

4545
hub internet.Listener
46+
47+
ctx context.Context
4648
}
4749

4850
func getTProxyType(s *internet.MemoryStreamConfig) internet.SocketConfig_TProxyMode {
@@ -53,7 +55,7 @@ func getTProxyType(s *internet.MemoryStreamConfig) internet.SocketConfig_TProxyM
5355
}
5456

5557
func (w *tcpWorker) callback(conn internet.Connection) {
56-
ctx, cancel := context.WithCancel(context.Background())
58+
ctx, cancel := context.WithCancel(w.ctx)
5759
sid := session.NewID()
5860
ctx = session.ContextWithID(ctx, sid)
5961

@@ -330,7 +332,7 @@ func (w *udpWorker) clean() error {
330332
}
331333

332334
for addr, conn := range w.activeConn {
333-
if nowSec-atomic.LoadInt64(&conn.lastActivityTime) > 8 {
335+
if nowSec-atomic.LoadInt64(&conn.lastActivityTime) > 8 { //TODO Timeout too small
334336
delete(w.activeConn, addr)
335337
conn.Close() // nolint: errcheck
336338
}

app/proxyman/outbound/handler.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ func (h *Handler) Dial(ctx context.Context, dest net.Destination) (internet.Conn
144144
conn := net.NewConnection(net.ConnectionInputMulti(uplinkWriter), net.ConnectionOutputMulti(downlinkReader))
145145

146146
if config := tls.ConfigFromStreamSettings(h.streamSettings); config != nil {
147-
tlsConfig := config.GetTLSConfig(tls.WithDestination(dest), tls.WithNextProto("h2"))
147+
tlsConfig := config.GetTLSConfig(tls.WithDestination(dest))
148148
conn = tls.Client(conn, tlsConfig)
149149
}
150150

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.24.2"
22+
version = "4.25.0"
2323
build = "Custom"
2424
codename = "V2Fly, a community-driven edition of V2Ray."
2525
intro = "A unified platform for anti-censorship."

functions.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import (
1414

1515
// CreateObject creates a new object based on the given V2Ray instance and config. The V2Ray instance may be nil.
1616
func CreateObject(v *Instance, config interface{}) (interface{}, error) {
17-
ctx := context.Background()
17+
ctx := v.ctx
1818
if v != nil {
1919
ctx = context.WithValue(ctx, v2rayKey, v)
2020
}

0 commit comments

Comments
 (0)