1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-09-28 14:56:33 -04:00

Merge branch 'master' into v5

This commit is contained in:
loyalsoldier 2020-11-30 20:59:04 +08:00
commit 9475e8df3c
No known key found for this signature in database
GPG Key ID: 23829BBC1ACF2C90
22 changed files with 227 additions and 861 deletions

View File

@ -12,66 +12,198 @@ on:
- "**/*.go"
- "go.mod"
- "go.sum"
- ".github/workflows/*.yml"
pull_request:
types: [opened, synchronize, reopened]
paths:
- "**/*.go"
- "go.mod"
- "go.sum"
- ".github/workflows/*.yml"
jobs:
build:
if: github.repository != 'v2ray/v2ray-core'
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.x
uses: actions/setup-go@v2
with:
go-version: 1.15
strategy:
matrix:
# Include amd64 on all platforms.
goos: [windows, freebsd, openbsd, linux, dragonfly, darwin]
goarch: [amd64, 386]
exclude:
# Exclude i386 on darwin and dragonfly.
- goarch: 386
goos: dragonfly
- goarch: 386
goos: darwin
include:
# BEGIN Linux ARM 5 6 7
- goos: linux
goarch: arm
goarm: 7
- goos: linux
goarch: arm
goarm: 6
- goos: linux
goarch: arm
goarm: 5
# END Linux ARM 5 6 7
# Windows ARM 7
- goos: windows
goarch: arm
goarm: 7
# BEGIN Other architectures
- goos: linux
goarch: arm64
- goos: linux
goarch: riscv64
# BEGIN MIPS
- goos: linux
goarch: mips64
- goos: linux
goarch: mips64le
- goos: linux
goarch: mipsle
- goos: linux
goarch: mips
# END MIPS
# END Other architectures
fail-fast: false
runs-on: ubuntu-latest
env:
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
GOARM: ${{ matrix.goarm }}
CGO_ENABLED: 0
steps:
- name: Checkout codebase
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Show workflow information
id: get_filename
run: |
export _NAME=$(jq ".[\"$GOOS-$GOARCH$GOARM\"].friendlyName" -r < release/friendly-filenames.json)
echo "GOOS: $GOOS, GOARCH: $GOARCH, GOARM: $GOARM, RELEASE_NAME: $_NAME"
echo "::set-output name=ASSET_NAME::$_NAME"
echo "ASSET_NAME=$_NAME" >> $GITHUB_ENV
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.15
- name: Get project dependencies
run: go mod download
- name: Set variables
- name: Build V2Ray
run: |
echo "BleedingReleaseTag=$(date +%Y%m%d%H%M%S)" >> $GITHUB_ENV
echo "TagReleaseTag=$(git describe --tags $(git rev-list --tags --max-count=1))" >> $GITHUB_ENV
shell: bash
mkdir -p build_assets
go build -v -o build_assets/v2ray -trimpath -ldflags "-s -w -buildid=" ./main
go build -v -o build_assets/v2ctl -trimpath -ldflags "-s -w -buildid=" -tags confonly ./infra/control/main
- name: Build binaries
run: bazel build --action_env=PATH=$PATH --action_env=GOPATH=$(go env GOPATH) --action_env=GOCACHE=$(go env GOCACHE) --action_env=SPWD=$(pwd) --spawn_strategy local //release:all
- name: Upload binaries to repo "v2fly/V2FlyBleedingEdgeBinary"
if: github.event_name != 'release' && github.repository == 'v2fly/v2ray-core'
env:
IsBleedingRelease: true
WORKDIR: ${{ github.workspace }}
PRERELEASE: true
RELEASE_SHA: ${{ github.sha }}
RELEASE_TAG: ${{ env.BleedingReleaseTag }}
UPLOAD_REPO: v2fly/V2FlyBleedingEdgeBinary
PERSONAL_TOKEN: ${{ secrets.BLEEDINGEDGEBINARY_REPO_TOKEN }}
COMMENT_TARGETTED_REPO_OWNER: v2fly
COMMENT_TARGETTED_REPO_NAME: v2ray-core
- name: Build Windows wv2ray
if: matrix.goos == 'windows'
run: |
chmod u+x ./release/release.sh
./release/release.sh
go build -v -o build_assets/wv2ray.exe -trimpath -ldflags "-s -w -H windowsgui -buildid=" ./main
cd ./build_assets || exit 1
mv v2ray v2ray.exe
mv v2ctl v2ctl.exe
- name: Upload binaries to current repo
- name: Prepare package
run: cp -v ./release/config/*.* ./build_assets
- name: Prepare package for Linux
if: matrix.goos == 'linux'
run: cp -rv ./release/config/systemd ./build_assets/
- name: Create ZIP archive
run: |
pushd build_assets || exit 1
zip -9vr ../v2ray-$ASSET_NAME.zip .
popd || exit 1
FILE=./v2ray-$ASSET_NAME.zip
DGST=$FILE.dgst
openssl dgst -md5 $FILE | sed 's/([^)]*)//g' >>$DGST
openssl dgst -sha1 $FILE | sed 's/([^)]*)//g' >>$DGST
openssl dgst -sha256 $FILE | sed 's/([^)]*)//g' >>$DGST
openssl dgst -sha512 $FILE | sed 's/([^)]*)//g' >>$DGST
- name: Upload ZIP file to Artifacts
uses: actions/upload-artifact@v2
with:
name: v2ray-${{ steps.get_filename.outputs.ASSET_NAME }}.zip
path: v2ray-${{ steps.get_filename.outputs.ASSET_NAME }}.zip
- name: Upload files to GitHub release
uses: svenstaro/upload-release-action@v2
if: github.event_name == 'release'
env:
IsBleedingRelease: false
WORKDIR: ${{ github.workspace }}
PRERELEASE: true
RELEASE_SHA: ${{ github.sha }}
RELEASE_TAG: ${{ env.TagReleaseTag }}
UPLOAD_REPO: ${{ github.repository }}
PERSONAL_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file_glob: true
file: ./v2ray-${{ steps.get_filename.outputs.ASSET_NAME }}.zip*
tag: ${{ github.ref }}
signature:
if: github.repository != 'v2ray/v2ray-core'
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout codebase
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.15
- uses: actions/download-artifact@v2
with:
path: build_artifacts
- name: Generate shasum
run: |
chmod u+x ./release/release.sh
./release/release.sh
cd build_artifacts || exit 1
mkdir .temp
mv ./*/*.zip ./.temp
rmdir ./*/
mv ./.temp/* .
ls -lah --recursive
{
go run github.com/v2fly/V2BuildAssist/v2buildutil gen version $(git describe --tags $(git rev-list --tags --max-count=1))
go run github.com/v2fly/V2BuildAssist/v2buildutil gen project "v2fly"
for zip in $(ls *.zip); do
go run github.com/v2fly/V2BuildAssist/v2buildutil gen file ${zip}
done
} >Release.unsigned.unsorted
go run github.com/v2fly/V2BuildAssist/v2buildutil gen sort < Release.unsigned.unsorted > Release.unsigned
rm -f Release.unsigned.unsorted
FILE=./Release.unsigned
DGST=$FILE.dgst
openssl dgst -md5 $FILE | sed 's/([^)]*)//g' >>$DGST
openssl dgst -sha1 $FILE | sed 's/([^)]*)//g' >>$DGST
openssl dgst -sha256 $FILE | sed 's/([^)]*)//g' >>$DGST
openssl dgst -sha512 $FILE | sed 's/([^)]*)//g' >>$DGST
- uses: actions/upload-artifact@v2
with:
name: Release.unsigned
path: build_artifacts/Release.unsigned
- uses: actions/upload-artifact@v2
with:
name: Release.unsigned.dgst
path: build_artifacts/Release.unsigned.dgst
- name: Upload Release.unsigned related files
uses: svenstaro/upload-release-action@v2
if: github.event_name == 'release'
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file_glob: true
file: build_artifacts/Release.unsigned*
tag: ${{ github.ref }}

View File

@ -14,7 +14,6 @@ jobs:
- name: Grant it execution permission
run: |
chmod +x $GITHUB_WORKSPACE/release/requestsign_github.sh
chmod +x $GITHUB_WORKSPACE/release/requestsign.sh
- name: Invoke release signing
@ -22,4 +21,7 @@ jobs:
SIGN_SERVICE_PASSWORD: ${{ secrets.SIGN_SERVICE_PASSWORD }}
SIGN_SERIVCE_URL: ${{ secrets.SIGN_SERIVCE_URL }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: $GITHUB_WORKSPACE/release/requestsign_github.sh
run: |
export SIGN_VERSION=$(cat $GITHUB_EVENT_PATH| jq -r ".release.tag_name")
echo $SIGN_VERSION
$GITHUB_WORKSPACE/release/requestsign.sh

View File

@ -1,24 +0,0 @@
############################
# STEP 1 build executable binary
############################
FROM golang:alpine AS builder
RUN apk update && apk add --no-cache git bash wget curl
WORKDIR /build
RUN git clone --progress https://github.com/v2fly/v2ray-core.git . && \
bash ./release/user-package.sh nosource noconf codename=$(git describe --abbrev=0 --tags) buildname=docker-fly abpathtgz=/tmp/v2ray.tgz
############################
# STEP 2 build a small image
############################
FROM alpine
LABEL maintainer "V2Fly Community <admin@v2fly.org>"
COPY --from=builder /tmp/v2ray.tgz /tmp
RUN apk update && apk add ca-certificates && \
mkdir -p /usr/bin/v2ray && \
tar xvfz /tmp/v2ray.tgz -C /usr/bin/v2ray
#ENTRYPOINT ["/usr/bin/v2ray/v2ray"]
ENV PATH /usr/bin/v2ray:$PATH
CMD ["v2ray", "-config=/etc/v2ray/config.json"]

View File

@ -1 +0,0 @@
workspace(name = "v2ray_core")

View File

@ -8,6 +8,7 @@ import (
"v2ray.com/core/common"
"v2ray.com/core/common/buf"
"v2ray.com/core/common/bytespool"
"v2ray.com/core/common/errors"
"v2ray.com/core/common/protocol"
)
@ -278,7 +279,11 @@ func (w *AuthenticationWriter) writeStream(mb buf.MultiBuffer) error {
}
payloadSize := buf.Size - int32(w.auth.Overhead()) - w.sizeParser.SizeBytes() - maxPadding
mb2Write := make(buf.MultiBuffer, 0, len(mb)+10)
if len(mb)+10 > 64*1024*1024 {
return errors.New("value too large")
}
sliceSize := len(mb) + 10
mb2Write := make(buf.MultiBuffer, 0, sliceSize)
temp := buf.New()
defer temp.Release()
@ -307,7 +312,11 @@ func (w *AuthenticationWriter) writeStream(mb buf.MultiBuffer) error {
func (w *AuthenticationWriter) writePacket(mb buf.MultiBuffer) error {
defer buf.ReleaseMulti(mb)
mb2Write := make(buf.MultiBuffer, 0, len(mb)+1)
if len(mb)+1 > 64*1024*1024 {
return errors.New("value too large")
}
sliceSize := len(mb) + 1
mb2Write := make(buf.MultiBuffer, 0, sliceSize)
for _, b := range mb {
if b.IsEmpty() {

View File

@ -3,6 +3,7 @@ package mux
import (
"v2ray.com/core/common"
"v2ray.com/core/common/buf"
"v2ray.com/core/common/errors"
"v2ray.com/core/common/net"
"v2ray.com/core/common/protocol"
"v2ray.com/core/common/serial"
@ -70,7 +71,11 @@ func writeMetaWithFrame(writer buf.Writer, meta FrameMetadata, data buf.MultiBuf
return err
}
mb2 := make(buf.MultiBuffer, 0, len(data)+1)
if len(data)+1 > 64*1024*1024 {
return errors.New("value too large")
}
sliceSize := len(data) + 1
mb2 := make(buf.MultiBuffer, 0, sliceSize)
mb2 = append(mb2, frame)
mb2 = append(mb2, data...)
return writer.WriteMultiBuffer(mb2)

View File

@ -9,6 +9,7 @@ import (
"v2ray.com/core/common"
"v2ray.com/core/common/buf"
"v2ray.com/core/common/errors"
"v2ray.com/core/common/signal/done"
)
@ -109,8 +110,12 @@ func (c *connection) Write(b []byte) (int, error) {
return 0, io.ErrClosedPipe
}
if len(b)/buf.Size+1 > 64*1024*1024 {
return 0, errors.New("value too large")
}
l := len(b)
mb := make(buf.MultiBuffer, 0, l/buf.Size+1)
sliceSize := l/buf.Size + 1
mb := make(buf.MultiBuffer, 0, sliceSize)
mb = buf.MergeBytes(mb, b)
return l, c.writer.WriteMultiBuffer(mb)
}

View File

@ -57,7 +57,7 @@ func ParseHost(rawHost string, defaultPort net.Port) (net.Destination, error) {
return net.Destination{}, err
}
} else if len(rawPort) > 0 {
intPort, err := strconv.Atoi(rawPort)
intPort, err := strconv.ParseUint(rawPort, 0, 16)
if err != nil {
return net.Destination{}, err
}

View File

@ -1,5 +0,0 @@
filegroup(
name = "rules",
srcs = glob(["*.bzl"]),
visibility = ["//visibility:public"],
)

View File

@ -1,68 +0,0 @@
def _go_command(ctx):
output = ctx.attr.output
if ctx.attr.os == "windows":
output = output + ".exe"
output_file = ctx.actions.declare_file(ctx.attr.os + "/" + ctx.attr.arch + "/" + ctx.attr.ver + "/" + output)
pkg = ctx.attr.pkg
ld_flags = "-s -w -buildid="
if ctx.attr.ld:
ld_flags = ld_flags + " " + ctx.attr.ld
options = [
"go",
"build",
"-trimpath",
"-o", output_file.path,
"-ldflags", "'%s'" % ld_flags,
"-tags", "'%s'" % ctx.attr.gotags,
pkg,
]
command = " ".join(options)
envs = [
"CGO_ENABLED=0",
"GOOS="+ctx.attr.os,
"GOARCH="+ctx.attr.arch,
"GO111MODULE=on",
"GOCACHE=${TMPDIR}/gocache"
]
if ctx.attr.mips: # https://github.com/golang/go/issues/27260
envs+=["GOMIPS="+ctx.attr.mips]
envs+=["GOMIPS64="+ctx.attr.mips]
envs+=["GOMIPSLE="+ctx.attr.mips]
envs+=["GOMIPS64LE="+ctx.attr.mips]
if ctx.attr.arm:
envs+=["GOARM="+ctx.attr.arm]
switchToPwd="cd ${SPWD} && "
command = switchToPwd + " ".join(envs) + " " + command
ctx.actions.run_shell(
outputs = [output_file],
command = command,
use_default_shell_env = True,
)
runfiles = ctx.runfiles(files = [output_file])
return [DefaultInfo(executable = output_file, runfiles = runfiles)]
foreign_go_binary = rule(
_go_command,
attrs = {
'pkg': attr.string(),
'output': attr.string(),
'os': attr.string(mandatory=True),
'arch': attr.string(mandatory=True),
'ver': attr.string(mandatory=True),
'mips': attr.string(),
'arm': attr.string(),
'ld': attr.string(),
'gotags': attr.string(),
},
executable = True,
)

View File

@ -1,25 +0,0 @@
SUPPORTED_MATRIX = [
("windows", "amd64", "0"),
("windows", "386", "0"),
("windows", "arm", "7"),
("darwin", "amd64", "0"),
("linux", "amd64", "0"),
("linux", "386", "0"),
("linux", "arm64", "0"),
("linux", "arm", "7"),
("linux", "arm", "6"),
("linux", "arm", "5"),
("linux", "mips64", "0"),
("linux", "mips", "0"),
("linux", "mips64le", "0"),
("linux", "mipsle", "0"),
("linux", "ppc64", "0"),
("linux", "ppc64le", "0"),
("linux", "riscv64", "0"),
("linux", "s390x", "0"),
("freebsd", "amd64", "0"),
("freebsd", "386", "0"),
("openbsd", "amd64", "0"),
("openbsd", "386", "0"),
("dragonfly", "amd64", "0"),
]

View File

@ -1,161 +0,0 @@
# Copied from google/nomulus project as we don't want to import the whole repository.
ZIPPER = "@bazel_tools//tools/zip:zipper"
def long_path(ctx, file_):
"""Constructs canonical runfile path relative to TEST_SRCDIR.
Args:
ctx: A Skylark rule context.
file_: A File object that should appear in the runfiles for the test.
Returns:
A string path relative to TEST_SRCDIR suitable for use in tests and
testing infrastructure.
"""
if file_.short_path.startswith("../"):
return file_.short_path[3:]
if file_.owner and file_.owner.workspace_root:
return file_.owner.workspace_root + "/" + file_.short_path
return ctx.workspace_name + "/" + file_.short_path
def collect_runfiles(targets):
"""Aggregates runfiles from targets.
Args:
targets: A list of Bazel targets.
Returns:
A list of Bazel files.
"""
data = depset()
for target in targets:
if hasattr(target, "runfiles"):
data += target.runfiles.files
continue
if hasattr(target, "data_runfiles"):
data += target.data_runfiles.files
if hasattr(target, "default_runfiles"):
data += target.default_runfiles.files
return data
def _get_runfiles(target, attribute):
runfiles = getattr(target, attribute, None)
if runfiles:
return runfiles.files
return []
def _zip_file(ctx):
"""Implementation of zip_file() rule."""
for s, d in ctx.attr.mappings.items():
if (s.startswith("/") or s.endswith("/") or
d.startswith("/") or d.endswith("/")):
fail("mappings should not begin or end with slash")
srcs = depset(transitive = [depset(ctx.files.srcs),depset(ctx.files.data),depset(collect_runfiles(ctx.attr.data))])
mapped = _map_sources(ctx, srcs, ctx.attr.mappings)
cmd = [
"#!/bin/sh",
"set -e",
'repo="$(pwd)"',
'zipper="${repo}/%s"' % ctx.file._zipper.path,
'archive="${repo}/%s"' % ctx.outputs.out.path,
'tmp="$(mktemp -d "${TMPDIR:-/tmp}/zip_file.XXXXXXXXXX")"',
'cd "${tmp}"',
]
cmd += [
'"${zipper}" x "${repo}/%s"' % dep.zip_file.path
for dep in ctx.attr.deps
]
cmd += ["rm %s" % filename for filename in ctx.attr.exclude]
cmd += [
'mkdir -p "${tmp}/%s"' % zip_path
for zip_path in depset(
[
zip_path[:zip_path.rindex("/")]
for _, zip_path in mapped
if "/" in zip_path
],
).to_list()
]
cmd += [
'ln -sf "${repo}/%s" "${tmp}/%s"' % (path, zip_path)
for path, zip_path in mapped
]
cmd += [
("find . | sed 1d | cut -c 3- | LC_ALL=C sort" +
' | xargs "${zipper}" cC "${archive}"'),
'cd "${repo}"',
'rm -rf "${tmp}"',
]
script = ctx.actions.declare_file("%s/%s.sh" % (ctx.bin_dir, ctx.label.name))
ctx.actions.write(output = script, content = "\n".join(cmd), is_executable = True)
inputs = [ctx.file._zipper]
inputs += [dep.zip_file for dep in ctx.attr.deps]
inputs += list(srcs.to_list())
ctx.actions.run(
inputs = inputs,
outputs = [ctx.outputs.out],
executable = script,
mnemonic = "zip",
progress_message = "Creating zip with %d inputs %s" % (
len(inputs),
ctx.label,
),
)
return struct(files = depset([ctx.outputs.out]), zip_file = ctx.outputs.out)
def _map_sources(ctx, srcs, mappings):
"""Calculates paths in zip file for srcs."""
# order mappings with more path components first
mappings = sorted([
(-len(source.split("/")), source, dest)
for source, dest in mappings.items()
])
# get rid of the integer part of tuple used for sorting
mappings = [(source, dest) for _, source, dest in mappings]
mappings_indexes = range(len(mappings))
used = {i: False for i in mappings_indexes}
mapped = []
for file_ in srcs.to_list():
run_path = long_path(ctx, file_)
zip_path = None
for i in mappings_indexes:
source = mappings[i][0]
dest = mappings[i][1]
if not source:
if dest:
zip_path = dest + "/" + run_path
else:
zip_path = run_path
elif source == run_path:
if dest:
zip_path = dest
else:
zip_path = run_path
elif run_path.startswith(source + "/"):
if dest:
zip_path = dest + run_path[len(source):]
else:
zip_path = run_path[len(source) + 1:]
else:
continue
used[i] = True
break
if not zip_path:
fail("no mapping matched: " + run_path)
mapped += [(file_.path, zip_path)]
for i in mappings_indexes:
if not used[i]:
fail('superfluous mapping: "%s" -> "%s"' % mappings[i])
return mapped
pkg_zip = rule(
implementation = _zip_file,
attrs = {
"out": attr.output(mandatory = True),
"srcs": attr.label_list(allow_files = True),
"data": attr.label_list(allow_files = True),
"deps": attr.label_list(providers = ["zip_file"]),
"exclude": attr.string_list(),
"mappings": attr.string_dict(),
"_zipper": attr.label(default = Label(ZIPPER), allow_single_file = True),
},
)

View File

@ -1,6 +0,0 @@
load("//infra/bazel:matrix.bzl", "SUPPORTED_MATRIX")
load("//infra/control/main:targets.bzl", "gen_targets")
package(default_visibility=["//visibility:public"])
gen_targets(SUPPORTED_MATRIX)

View File

@ -1,45 +0,0 @@
load("//infra/bazel:build.bzl", "foreign_go_binary")
def gen_targets(matrix):
pkg = "./infra/control/main"
output = "v2ctl"
for (os, arch, ver) in matrix:
if arch in ["arm"]:
bin_name = "v2ctl_" + os + "_" + arch + "_" + ver
foreign_go_binary(
name = bin_name,
pkg = pkg,
output = output,
os = os,
arch = arch,
ver = ver,
arm = ver,
gotags = "confonly",
)
else:
bin_name = "v2ctl_" + os + "_" + arch
foreign_go_binary(
name = bin_name,
pkg = pkg,
output = output,
os = os,
arch = arch,
ver = ver,
gotags = "confonly",
)
if arch in ["mips", "mipsle"]:
bin_name = "v2ctl_" + os + "_" + arch + "_softfloat"
foreign_go_binary(
name = bin_name,
pkg = pkg,
output = output + "_softfloat",
os = os,
arch = arch,
ver = ver,
mips = "softfloat",
gotags = "confonly",
)

View File

@ -1,6 +0,0 @@
load("//infra/bazel:matrix.bzl", "SUPPORTED_MATRIX")
load("//main:targets.bzl", "gen_targets")
package(default_visibility=["//visibility:public"])
gen_targets(SUPPORTED_MATRIX)

View File

@ -1,67 +0,0 @@
load("//infra/bazel:build.bzl", "foreign_go_binary")
def gen_targets(matrix):
pkg = "./main"
output = "v2ray"
for (os, arch, ver) in matrix:
if arch in ["arm"]:
bin_name = "v2ray_" + os + "_" + arch + "_" + ver
foreign_go_binary(
name = bin_name,
pkg = pkg,
output = output,
os = os,
arch = arch,
ver = ver,
arm = ver,
)
if os in ["windows"]:
bin_name = "v2ray_" + os + "_" + arch + "_" + ver + "_nowindow"
foreign_go_binary(
name = bin_name,
pkg = pkg,
output = "w" + output,
os = os,
arch = arch,
ver = ver,
arm = ver,
ld = "-H windowsgui",
)
else:
bin_name = "v2ray_" + os + "_" + arch
foreign_go_binary(
name = bin_name,
pkg = pkg,
output = output,
os = os,
arch = arch,
ver = ver,
)
if os in ["windows"]:
bin_name = "v2ray_" + os + "_" + arch + "_nowindow"
foreign_go_binary(
name = bin_name,
pkg = pkg,
output = "w" + output,
os = os,
arch = arch,
ver = ver,
ld = "-H windowsgui",
)
if arch in ["mips", "mipsle"]:
bin_name = "v2ray_" + os + "_" + arch + "_softfloat"
foreign_go_binary(
name = bin_name,
pkg = pkg,
output = output + "_softfloat",
os = os,
arch = arch,
ver = ver,
mips = "softfloat",
)

View File

@ -7,6 +7,7 @@ import (
"github.com/golang/protobuf/proto"
"v2ray.com/core/common/buf"
"v2ray.com/core/common/errors"
"v2ray.com/core/common/protocol"
)
@ -67,7 +68,12 @@ type MultiLengthPacketWriter struct {
func (w *MultiLengthPacketWriter) WriteMultiBuffer(mb buf.MultiBuffer) error {
defer buf.ReleaseMulti(mb)
mb2Write := make(buf.MultiBuffer, 0, len(mb)+1)
if len(mb)+1 > 64*1024*1024 {
return errors.New("value too large")
}
sliceSize := len(mb) + 1
mb2Write := make(buf.MultiBuffer, 0, sliceSize)
for _, b := range mb {
length := b.Len()
if length == 0 || length+2 > buf.Size {

View File

@ -1,326 +0,0 @@
package(default_visibility = ["//visibility:public"])
load("//infra/bazel:zip.bzl", "pkg_zip")
load("//release:mapping.bzl", "gen_mappings")
filegroup(
name = "config_json",
srcs = [
"config/config.json",
"config/vpoint_socks_vmess.json",
"config/vpoint_vmess_freedom.json",
],
)
filegroup(
name = "systemd",
srcs = [
"config/systemd/system/v2ray.service",
"config/systemd/system/v2ray@.service",
],
)
filegroup(
name = "geodata",
srcs = [
"config/geoip.dat",
"config/geosite.dat",
],
)
pkg_zip(
name = "v2ray_darwin_amd64_package",
srcs = [
":config_json",
":geodata",
"//infra/control/main:v2ctl_darwin_amd64",
"//main:v2ray_darwin_amd64",
],
out = "v2ray-macos-64.zip",
mappings = gen_mappings("darwin", "amd64", "0"),
)
pkg_zip(
name = "v2ray_windows_amd64_package",
srcs = [
":config_json",
":geodata",
"//infra/control/main:v2ctl_windows_amd64",
"//main:v2ray_windows_amd64",
"//main:v2ray_windows_amd64_nowindow",
],
out = "v2ray-windows-64.zip",
mappings = gen_mappings("windows", "amd64", "0"),
)
pkg_zip(
name = "v2ray_windows_x86_package",
srcs = [
":config_json",
":geodata",
"//infra/control/main:v2ctl_windows_386",
"//main:v2ray_windows_386",
"//main:v2ray_windows_386_nowindow",
],
out = "v2ray-windows-32.zip",
mappings = gen_mappings("windows", "386", "0"),
)
pkg_zip(
name = "v2ray_windows_armv7_package",
srcs = [
":config_json",
":geodata",
"//infra/control/main:v2ctl_windows_arm_7",
"//main:v2ray_windows_arm_7",
"//main:v2ray_windows_arm_7_nowindow",
],
out = "v2ray-windows-arm32-v7a.zip",
mappings = gen_mappings("windows", "arm", "7"),
)
pkg_zip(
name = "v2ray_freebsd_amd64_package",
srcs = [
":config_json",
":geodata",
"//infra/control/main:v2ctl_freebsd_amd64",
"//main:v2ray_freebsd_amd64",
],
out = "v2ray-freebsd-64.zip",
mappings = gen_mappings("freebsd", "amd64", "0"),
)
pkg_zip(
name = "v2ray_freebsd_x86_package",
srcs = [
":config_json",
":geodata",
"//infra/control/main:v2ctl_freebsd_386",
"//main:v2ray_freebsd_386",
],
out = "v2ray-freebsd-32.zip",
mappings = gen_mappings("freebsd", "386", "0"),
)
pkg_zip(
name = "v2ray_openbsd_amd64_package",
srcs = [
":config_json",
":geodata",
"//infra/control/main:v2ctl_openbsd_amd64",
"//main:v2ray_openbsd_amd64",
],
out = "v2ray-openbsd-64.zip",
mappings = gen_mappings("openbsd", "amd64", "0"),
)
pkg_zip(
name = "v2ray_openbsd_x86_package",
srcs = [
":config_json",
":geodata",
"//infra/control/main:v2ctl_openbsd_386",
"//main:v2ray_openbsd_386",
],
out = "v2ray-openbsd-32.zip",
mappings = gen_mappings("openbsd", "386", "0"),
)
pkg_zip(
name = "v2ray_dragonfly_amd64_package",
srcs = [
":config_json",
":geodata",
"//infra/control/main:v2ctl_dragonfly_amd64",
"//main:v2ray_dragonfly_amd64",
],
out = "v2ray-dragonfly-64.zip",
mappings = gen_mappings("dragonfly", "amd64", "0"),
)
pkg_zip(
name = "v2ray_linux_amd64_package",
srcs = [
":config_json",
":geodata",
":systemd",
"//infra/control/main:v2ctl_linux_amd64",
"//main:v2ray_linux_amd64",
],
out = "v2ray-linux-64.zip",
mappings = gen_mappings("linux", "amd64", "0"),
)
pkg_zip(
name = "v2ray_linux_x86_package",
srcs = [
":config_json",
":geodata",
":systemd",
"//infra/control/main:v2ctl_linux_386",
"//main:v2ray_linux_386",
],
out = "v2ray-linux-32.zip",
mappings = gen_mappings("linux", "386", "0"),
)
pkg_zip(
name = "v2ray_linux_arm64_package",
srcs = [
":config_json",
":geodata",
":systemd",
"//infra/control/main:v2ctl_linux_arm64",
"//main:v2ray_linux_arm64",
],
out = "v2ray-linux-arm64-v8a.zip",
mappings = gen_mappings("linux", "arm64", "0"),
)
pkg_zip(
name = "v2ray_linux_armv7_package",
srcs = [
":config_json",
":geodata",
":systemd",
"//infra/control/main:v2ctl_linux_arm_7",
"//main:v2ray_linux_arm_7",
],
out = "v2ray-linux-arm32-v7a.zip",
mappings = gen_mappings("linux", "arm", "7"),
)
pkg_zip(
name = "v2ray_linux_armv6_package",
srcs = [
":config_json",
":geodata",
":systemd",
"//infra/control/main:v2ctl_linux_arm_6",
"//main:v2ray_linux_arm_6",
],
out = "v2ray-linux-arm32-v6.zip",
mappings = gen_mappings("linux", "arm", "6"),
)
pkg_zip(
name = "v2ray_linux_armv5_package",
srcs = [
":config_json",
":geodata",
":systemd",
"//infra/control/main:v2ctl_linux_arm_5",
"//main:v2ray_linux_arm_5",
],
out = "v2ray-linux-arm32-v5.zip",
mappings = gen_mappings("linux", "arm", "5"),
)
pkg_zip(
name = "v2ray_linux_mips32_package",
srcs = [
":config_json",
":geodata",
":systemd",
"//infra/control/main:v2ctl_linux_mips",
"//infra/control/main:v2ctl_linux_mips_softfloat",
"//main:v2ray_linux_mips",
"//main:v2ray_linux_mips_softfloat",
],
out = "v2ray-linux-mips32.zip",
mappings = gen_mappings("linux", "mips", "0"),
)
pkg_zip(
name = "v2ray_linux_mips32le_package",
srcs = [
":config_json",
":geodata",
":systemd",
"//infra/control/main:v2ctl_linux_mipsle",
"//infra/control/main:v2ctl_linux_mipsle_softfloat",
"//main:v2ray_linux_mipsle",
"//main:v2ray_linux_mipsle_softfloat",
],
out = "v2ray-linux-mips32le.zip",
mappings = gen_mappings("linux", "mipsle", "0"),
)
pkg_zip(
name = "v2ray_linux_mips64_package",
srcs = [
":config_json",
":geodata",
":systemd",
"//infra/control/main:v2ctl_linux_mips64",
"//main:v2ray_linux_mips64",
],
out = "v2ray-linux-mips64.zip",
mappings = gen_mappings("linux", "mips64", "0"),
)
pkg_zip(
name = "v2ray_linux_mips64le_package",
srcs = [
":config_json",
":geodata",
":systemd",
"//infra/control/main:v2ctl_linux_mips64le",
"//main:v2ray_linux_mips64le",
],
out = "v2ray-linux-mips64le.zip",
mappings = gen_mappings("linux", "mips64le", "0"),
)
pkg_zip(
name = "v2ray_linux_riscv64_package",
srcs = [
":config_json",
":geodata",
":systemd",
"//infra/control/main:v2ctl_linux_riscv64",
"//main:v2ray_linux_riscv64",
],
out = "v2ray-linux-riscv64.zip",
mappings = gen_mappings("linux", "riscv64", "0"),
)
pkg_zip(
name = "v2ray_linux_s390x_package",
srcs = [
":config_json",
":geodata",
":systemd",
"//infra/control/main:v2ctl_linux_s390x",
"//main:v2ray_linux_s390x",
],
out = "v2ray-linux-s390x.zip",
mappings = gen_mappings("linux", "s390x", "0"),
)
pkg_zip(
name = "v2ray_linux_ppc64_package",
srcs = [
":config_json",
":geodata",
":systemd",
"//infra/control/main:v2ctl_linux_ppc64",
"//main:v2ray_linux_ppc64",
],
out = "v2ray-linux-ppc64.zip",
mappings = gen_mappings("linux", "ppc64", "0"),
)
pkg_zip(
name = "v2ray_linux_ppc64le_package",
srcs = [
":config_json",
":geodata",
":systemd",
"//infra/control/main:v2ctl_linux_ppc64le",
"//main:v2ray_linux_ppc64le",
],
out = "v2ray-linux-ppc64le.zip",
mappings = gen_mappings("linux", "ppc64le", "0"),
)

View File

@ -0,0 +1,22 @@
{
"darwin-amd64": { "friendlyName": "macos-64" },
"dragonfly-amd64": { "friendlyName": "dragonfly-64" },
"freebsd-386": { "friendlyName": "freebsd-32" },
"freebsd-amd64": { "friendlyName": "freebsd-64" },
"linux-386": { "friendlyName": "linux-32" },
"linux-amd64": { "friendlyName": "linux-64" },
"linux-arm5": { "friendlyName": "linux-arm32-v5" },
"linux-arm64": { "friendlyName": "linux-arm64-v8a" },
"linux-arm6": { "friendlyName": "linux-arm32-v6" },
"linux-arm7": { "friendlyName": "linux-arm32-v7a" },
"linux-mips64le": { "friendlyName": "linux-mips64le" },
"linux-mips64": { "friendlyName": "linux-mips64" },
"linux-mipsle": { "friendlyName": "linux-mips32le" },
"linux-mips": { "friendlyName": "linux-mips32" },
"linux-riscv64": { "friendlyName": "linux-riscv64" },
"openbsd-386": { "friendlyName": "openbsd-32" },
"openbsd-amd64": { "friendlyName": "openbsd-64" },
"windows-amd64": { "friendlyName": "windows-64" },
"windows-386": { "friendlyName": "windows-32" },
"windows-arm7": { "friendlyName": "windows-arm32-v7a" }
}

View File

@ -1,6 +0,0 @@
def gen_mappings(os, arch, ver):
return {
"v2ray_core/release/config": "",
"v2ray_core/main/" + os + "/" + arch + "/" + ver: "",
"v2ray_core/infra/control/main/" + os + "/" + arch + "/" + ver : "",
}

View File

@ -1,68 +0,0 @@
#!/usr/bin/env bash
ART_ROOT=${WORKDIR}/bazel-bin/release
pushd ${ART_ROOT} || exit 1
# Generate Release.unsigned.unsorted file
{
go run github.com/v2fly/V2BuildAssist/v2buildutil gen version ${RELEASE_TAG}
go run github.com/v2fly/V2BuildAssist/v2buildutil gen project "v2fly"
for zip in $(find -L . -type f -name "*.zip"); do
go run github.com/v2fly/V2BuildAssist/v2buildutil gen file ${zip}
done
} >Release.unsigned.unsorted
# Generate Release.unsigned file
go run github.com/v2fly/V2BuildAssist/v2buildutil gen sort < Release.unsigned.unsorted > Release.unsigned
rm -f Release.unsigned.unsorted
# Test if is bleeding edge release
if [[ "$IsBleedingRelease" == true ]]; then
# If it is a bleeding edge release
# Prepare JSON data, create a release and get release id
RELBODY="https://github.com/${COMMENT_TARGETTED_REPO_OWNER}/${COMMENT_TARGETTED_REPO_NAME}/commit/${RELEASE_SHA}"
JSON_DATA=$(echo "{}" | jq -c ".tag_name=\"${RELEASE_TAG}\"")
JSON_DATA=$(echo ${JSON_DATA} | jq -c ".name=\"${RELEASE_TAG}\"")
JSON_DATA=$(echo ${JSON_DATA} | jq -c ".prerelease=${PRERELEASE}")
JSON_DATA=$(echo ${JSON_DATA} | jq -c ".body=\"${RELBODY}\"")
RELEASE_DATA=$(curl -X POST --data "${JSON_DATA}" -H "Authorization: token ${PERSONAL_TOKEN}" "https://api.github.com/repos/${UPLOAD_REPO}/releases")
echo "Bleeding Edge Release data:"
echo $RELEASE_DATA
RELEASE_ID=$(echo $RELEASE_DATA | jq ".id")
# Prepare commit comment message and post it
echo "Build Finished" > buildcomment
echo "https://github.com/${UPLOAD_REPO}/releases/tag/${RELEASE_TAG}" >> buildcomment
go run github.com/v2fly/V2BuildAssist/v2buildutil post commit "${RELEASE_SHA}" < buildcomment
rm -f buildcomment
else
# If is a tag release then get the release id
RELEASE_DATA=$(curl -X GET -H "Authorization: token ${PERSONAL_TOKEN}" "https://api.github.com/repos/${UPLOAD_REPO}/releases/tags/${RELEASE_TAG}")
echo "Tag Release data:"
echo $RELEASE_DATA
RELEASE_ID=$(echo $RELEASE_DATA | jq ".id")
fi
function uploadfile() {
FILE=$1
CTYPE=$(file -b --mime-type $FILE)
curl -H "Authorization: token ${PERSONAL_TOKEN}" -H "Content-Type: ${CTYPE}" --data-binary @$FILE "https://uploads.github.com/repos/${UPLOAD_REPO}/releases/${RELEASE_ID}/assets?name=$(basename $FILE)"
}
function upload() {
FILE=$1
DGST=$1.dgst
openssl dgst -md5 $FILE | sed 's/([^)]*)//g' >>$DGST
openssl dgst -sha1 $FILE | sed 's/([^)]*)//g' >>$DGST
openssl dgst -sha256 $FILE | sed 's/([^)]*)//g' >>$DGST
openssl dgst -sha512 $FILE | sed 's/([^)]*)//g' >>$DGST
uploadfile $FILE
uploadfile $DGST
}
# Upload all files to release assets
for asset in $(find -L . -type f -name "*.zip" -or -type f -name "*.unsigned"); do
upload ${asset}
done

View File

@ -1,7 +0,0 @@
#!/usr/bin/env bash
export SIGN_VERSION=$(cat $GITHUB_EVENT_PATH| jq -r ".release.tag_name")
echo $SIGN_VERSION
$GITHUB_WORKSPACE/release/requestsign.sh