Skip to content

Commit

Permalink
Merge pull request #2582 from v2fly/master
Browse files Browse the repository at this point in the history
merge fly
  • Loading branch information
kslr committed Jun 19, 2020
2 parents f9935d0 + d6cad0b commit 3628ca4
Show file tree
Hide file tree
Showing 24 changed files with 170 additions and 349 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/linter.yml
@@ -0,0 +1,21 @@
name: Lint Code Base

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
build:
name: Lint Code Base
runs-on: ubuntu-latest

steps:
- name: Checkout Code
uses: actions/checkout@v2

- name: Lint Code Base
uses: github/super-linter@v2.0.0
env:
VALIDATE_ALL_CODEBASE: false
34 changes: 34 additions & 0 deletions .github/workflows/test.yml
@@ -0,0 +1,34 @@
name: Test

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:

build:
name: Test
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [windows-latest, ubuntu-latest, macos-latest]

steps:

- name: Set up Go 1.x
uses: actions/setup-go@v2
with:
go-version: ^1.14
id: go

- name: Check out code into the Go module directory
uses: actions/checkout@v2

- name: Get dependencies
run: |
go get -v -t -d ./...
- name: Test
run: go test -parallel 1 -timeout 6h -v ./...
10 changes: 0 additions & 10 deletions .vscode/settings.json

This file was deleted.

51 changes: 0 additions & 51 deletions .vscode/tasks.json

This file was deleted.

1 change: 1 addition & 0 deletions app/proxyman/inbound/always.go
Expand Up @@ -103,6 +103,7 @@ func NewAlwaysOnInboundHandler(ctx context.Context, tag string, receiverConfig *
sniffingConfig: receiverConfig.GetEffectiveSniffingSettings(),
uplinkCounter: uplinkCounter,
downlinkCounter: downlinkCounter,
ctx: ctx,
}
h.workers = append(h.workers, worker)
}
Expand Down
4 changes: 4 additions & 0 deletions app/proxyman/inbound/dynamic.go
Expand Up @@ -28,6 +28,8 @@ type DynamicInboundHandler struct {
lastRefresh time.Time
mux *mux.Server
task *task.Periodic

ctx context.Context
}

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

mss, err := internet.ToMemoryStreamConfig(receiverConfig.StreamSettings)
Expand Down Expand Up @@ -134,6 +137,7 @@ func (h *DynamicInboundHandler) refresh() error {
sniffingConfig: h.receiverConfig.GetEffectiveSniffingSettings(),
uplinkCounter: uplinkCounter,
downlinkCounter: downlinkCounter,
ctx: h.ctx,
}
if err := worker.Start(); err != nil {
newError("failed to create TCP worker").Base(err).AtWarning().WriteToLog()
Expand Down
6 changes: 4 additions & 2 deletions app/proxyman/inbound/worker.go
Expand Up @@ -43,6 +43,8 @@ type tcpWorker struct {
downlinkCounter stats.Counter

hub internet.Listener

ctx context.Context
}

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

func (w *tcpWorker) callback(conn internet.Connection) {
ctx, cancel := context.WithCancel(context.Background())
ctx, cancel := context.WithCancel(w.ctx)
sid := session.NewID()
ctx = session.ContextWithID(ctx, sid)

Expand Down Expand Up @@ -330,7 +332,7 @@ func (w *udpWorker) clean() error {
}

for addr, conn := range w.activeConn {
if nowSec-atomic.LoadInt64(&conn.lastActivityTime) > 8 {
if nowSec-atomic.LoadInt64(&conn.lastActivityTime) > 8 { //TODO Timeout too small
delete(w.activeConn, addr)
conn.Close() // nolint: errcheck
}
Expand Down
2 changes: 1 addition & 1 deletion app/proxyman/outbound/handler.go
Expand Up @@ -144,7 +144,7 @@ func (h *Handler) Dial(ctx context.Context, dest net.Destination) (internet.Conn
conn := net.NewConnection(net.ConnectionInputMulti(uplinkWriter), net.ConnectionOutputMulti(downlinkReader))

if config := tls.ConfigFromStreamSettings(h.streamSettings); config != nil {
tlsConfig := config.GetTLSConfig(tls.WithDestination(dest), tls.WithNextProto("h2"))
tlsConfig := config.GetTLSConfig(tls.WithDestination(dest))
conn = tls.Client(conn, tlsConfig)
}

Expand Down
2 changes: 1 addition & 1 deletion core.go
Expand Up @@ -19,7 +19,7 @@ import (
)

var (
version = "4.24.2"
version = "4.25.0"
build = "Custom"
codename = "V2Fly, a community-driven edition of V2Ray."
intro = "A unified platform for anti-censorship."
Expand Down
2 changes: 1 addition & 1 deletion functions.go
Expand Up @@ -14,7 +14,7 @@ import (

// CreateObject creates a new object based on the given V2Ray instance and config. The V2Ray instance may be nil.
func CreateObject(v *Instance, config interface{}) (interface{}, error) {
ctx := context.Background()
ctx := v.ctx
if v != nil {
ctx = context.WithValue(ctx, v2rayKey, v)
}
Expand Down
16 changes: 9 additions & 7 deletions infra/conf/transport_internet.go
Expand Up @@ -274,12 +274,13 @@ func (c *TLSCertConfig) Build() (*tls.Certificate, error) {
}

type TLSConfig struct {
Insecure bool `json:"allowInsecure"`
InsecureCiphers bool `json:"allowInsecureCiphers"`
Certs []*TLSCertConfig `json:"certificates"`
ServerName string `json:"serverName"`
ALPN *StringList `json:"alpn"`
DiableSystemRoot bool `json:"disableSystemRoot"`
Insecure bool `json:"allowInsecure"`
InsecureCiphers bool `json:"allowInsecureCiphers"`
Certs []*TLSCertConfig `json:"certificates"`
ServerName string `json:"serverName"`
ALPN *StringList `json:"alpn"`
DisableSessionResumption bool `json:"disableSessionResumption"`
DisableSystemRoot bool `json:"disableSystemRoot"`
}

// Build implements Buildable.
Expand All @@ -302,7 +303,8 @@ func (c *TLSConfig) Build() (proto.Message, error) {
if c.ALPN != nil && len(*c.ALPN) > 0 {
config.NextProtocol = []string(*c.ALPN)
}
config.DisableSystemRoot = c.DiableSystemRoot
config.DisableSessionResumption = c.DisableSessionResumption
config.DisableSystemRoot = c.DisableSystemRoot
return config, nil
}

Expand Down
15 changes: 15 additions & 0 deletions main/targets.bzl
Expand Up @@ -82,3 +82,18 @@ def gen_targets(matrix):
name = bin_name + "_sig",
base = ":" + bin_name,
)

bin_name = "v2ray_" + os + "_" + arch + "_armv5"
foreign_go_binary(
name = bin_name,
pkg = pkg,
output = output+"_armv5",
os = os,
arch = arch,
arm = "5",
)

gpg_sign(
name = bin_name + "_sig",
base = ":" + bin_name,
)
4 changes: 3 additions & 1 deletion proxy/dokodemo/dokodemo.go
Expand Up @@ -188,7 +188,9 @@ func (d *DokodemoDoor) Process(ctx context.Context, network net.Network, conn in
return nil
}

if err := task.Run(ctx, task.OnSuccess(requestDone, task.Close(link.Writer)), responseDone, tproxyRequest); err != nil {
if err := task.Run(ctx, task.OnSuccess(func() error {
return task.Run(ctx, requestDone, tproxyRequest)
}, task.Close(link.Writer)), responseDone); err != nil {
common.Interrupt(link.Reader)
common.Interrupt(link.Writer)
return newError("connection ends").Base(err)
Expand Down
9 changes: 5 additions & 4 deletions proxy/shadowsocks/server.go
Expand Up @@ -132,20 +132,21 @@ func (s *Server) handlerUDPPayload(ctx context.Context, conn internet.Connection
continue
}

currentPacketCtx := ctx
dest := request.Destination()
if inbound.Source.IsValid() {
ctx = log.ContextWithAccessMessage(ctx, &log.AccessMessage{
currentPacketCtx = log.ContextWithAccessMessage(ctx, &log.AccessMessage{
From: inbound.Source,
To: dest,
Status: log.AccessAccepted,
Reason: "",
Email: request.User.Email,
})
}
newError("tunnelling request to ", dest).WriteToLog(session.ExportIDToError(ctx))
newError("tunnelling request to ", dest).WriteToLog(session.ExportIDToError(currentPacketCtx))

ctx = protocol.ContextWithRequestHeader(ctx, request)
udpServer.Dispatch(ctx, dest, data)
currentPacketCtx = protocol.ContextWithRequestHeader(currentPacketCtx, request)
udpServer.Dispatch(currentPacketCtx, dest, data)
}
}

Expand Down
8 changes: 4 additions & 4 deletions proxy/socks/server.go
Expand Up @@ -229,19 +229,19 @@ func (s *Server) handleUDPPayload(ctx context.Context, conn internet.Connection,
payload.Release()
continue
}

currentPacketCtx := ctx
newError("send packet to ", request.Destination(), " with ", payload.Len(), " bytes").AtDebug().WriteToLog(session.ExportIDToError(ctx))
if inbound := session.InboundFromContext(ctx); inbound != nil && inbound.Source.IsValid() {
ctx = log.ContextWithAccessMessage(ctx, &log.AccessMessage{
currentPacketCtx = log.ContextWithAccessMessage(ctx, &log.AccessMessage{
From: inbound.Source,
To: request.Destination(),
Status: log.AccessAccepted,
Reason: "",
})
}

ctx = protocol.ContextWithRequestHeader(ctx, request)
udpServer.Dispatch(ctx, request.Destination(), payload)
currentPacketCtx = protocol.ContextWithRequestHeader(currentPacketCtx, request)
udpServer.Dispatch(currentPacketCtx, request.Destination(), payload)
}
}
}
Expand Down
4 changes: 3 additions & 1 deletion release/BUILD
Expand Up @@ -201,11 +201,13 @@ pkg_zip(
"//infra/control/main:v2ctl_linux_arm_armv7_sig",
"//infra/control/main:v2ctl_linux_arm_sig",
"//main:v2ray_linux_arm",
"//main:v2ray_linux_arm_sig",
"//main:v2ray_linux_arm_armv5",
"//main:v2ray_linux_arm_armv5_sig",
"//main:v2ray_linux_arm_armv6",
"//main:v2ray_linux_arm_armv6_sig",
"//main:v2ray_linux_arm_armv7",
"//main:v2ray_linux_arm_armv7_sig",
"//main:v2ray_linux_arm_sig",
],
out = "v2ray-linux-arm.zip",
mappings = gen_mappings("linux", "arm"),
Expand Down
26 changes: 0 additions & 26 deletions release/install.sh

This file was deleted.

0 comments on commit 3628ca4

Please sign in to comment.