Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix incompatible errors when building with bazel 0.26+ #1775

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions infra/bazel/zip.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ def _zip_file(ctx):
if (s.startswith("/") or s.endswith("/") or
d.startswith("/") or d.endswith("/")):
fail("mappings should not begin or end with slash")
srcs = depset()
srcs += ctx.files.srcs
srcs += ctx.files.data
srcs += collect_runfiles(ctx.attr.data)
srcs = depset(transitive = [depset(ctx.files.srcs),depset(ctx.files.data),depset(collect_runfiles(ctx.attr.data))])
# srcs += ctx.files.srcs
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can delete these comments

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I'll do that

# srcs += ctx.files.data
# srcs += collect_runfiles(ctx.attr.data)
mapped = _map_sources(ctx, srcs, ctx.attr.mappings)
cmd = [
"#!/bin/sh",
Expand All @@ -74,7 +74,7 @@ def _zip_file(ctx):
for _, zip_path in mapped
if "/" in zip_path
],
)
).to_list()
]
cmd += [
'ln -sf "${repo}/%s" "${tmp}/%s"' % (path, zip_path)
Expand All @@ -86,12 +86,12 @@ def _zip_file(ctx):
'cd "${repo}"',
'rm -rf "${tmp}"',
]
script = ctx.new_file(ctx.bin_dir, "%s.sh" % ctx.label.name)
ctx.file_action(output = script, content = "\n".join(cmd), executable = True)
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)
ctx.action(
inputs += list(srcs.to_list())
ctx.actions.run(
inputs = inputs,
outputs = [ctx.outputs.out],
executable = script,
Expand All @@ -117,7 +117,7 @@ def _map_sources(ctx, srcs, mappings):
mappings_indexes = range(len(mappings))
used = {i: False for i in mappings_indexes}
mapped = []
for file_ in srcs:
for file_ in srcs.to_list():
run_path = long_path(ctx, file_)
zip_path = None
for i in mappings_indexes:
Expand Down Expand Up @@ -159,6 +159,6 @@ pkg_zip = rule(
"deps": attr.label_list(providers = ["zip_file"]),
"exclude": attr.string_list(),
"mappings": attr.string_dict(),
"_zipper": attr.label(default = Label(ZIPPER), single_file = True),
"_zipper": attr.label(default = Label(ZIPPER), allow_single_file = True),
},
)
34 changes: 31 additions & 3 deletions transport/internet/http/hub.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ import (
"v2ray.com/core/common/signal/done"
"v2ray.com/core/transport/internet"
"v2ray.com/core/transport/internet/tls"

"golang.org/x/net/http2"
"golang.org/x/net/http2/h2c"
)

type Listener struct {
Expand Down Expand Up @@ -104,9 +107,35 @@ func Listen(ctx context.Context, address net.Address, port net.Port, streamSetti

config := tls.ConfigFromStreamSettings(streamSettings)
if config == nil {
return nil, newError("TLS must be enabled for http transport.").AtWarning()
}
// return nil, newError("TLS must be enabled for http transport.").AtWarning()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

H2C has been sent separately, I suggest you re-initiate PR

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right, I'll re-initiate PR.

h2s := &http2.Server{}

server := &http.Server{
Addr: serial.Concat(address, ":", port),
// TLSConfig: config.GetTLSConfig(tls.WithNextProto("h2")),
Handler: h2c.NewHandler(listener, h2s),
ReadHeaderTimeout: time.Second * 4,
}

listener.server = server
go func() {
tcpListener, err := internet.ListenSystem(ctx, &net.TCPAddr{
IP: address.IP(),
Port: int(port),
}, streamSettings.SocketSettings)
if err != nil {
newError("failed to listen on", address, ":", port).Base(err).WriteToLog(session.ExportIDToError(ctx))
return
}

err = server.Serve(tcpListener)
if err != nil {
newError("stoping serving H2C").Base(err).WriteToLog(session.ExportIDToError(ctx))
}
}()

return listener, nil
}
server := &http.Server{
Addr: serial.Concat(address, ":", port),
TLSConfig: config.GetTLSConfig(tls.WithNextProto("h2")),
Expand All @@ -130,7 +159,6 @@ func Listen(ctx context.Context, address net.Address, port net.Port, streamSetti
newError("stoping serving TLS").Base(err).WriteToLog(session.ExportIDToError(ctx))
}
}()

return listener, nil
}

Expand Down