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

Add HTTP2 mode #134

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
11 changes: 9 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import (
"v2ray.com/core/transport/internet"
"v2ray.com/core/transport/internet/quic"
"v2ray.com/core/transport/internet/tls"
"v2ray.com/core/transport/internet/http"
"v2ray.com/core/transport/internet/websocket"

vlog "v2ray.com/core/app/log"
Expand All @@ -51,13 +52,13 @@ var (
localPort = flag.String("localPort", "1984", "local port to listen on.")
remoteAddr = flag.String("remoteAddr", "127.0.0.1", "remote address to forward.")
remotePort = flag.String("remotePort", "1080", "remote port to forward.")
path = flag.String("path", "/", "URL path for websocket.")
path = flag.String("path", "/", "URL path for websocket or http2.")
host = flag.String("host", "cloudfront.com", "Hostname for server.")
tlsEnabled = flag.Bool("tls", false, "Enable TLS.")
cert = flag.String("cert", "", "Path to TLS certificate file. Overrides certRaw. Default: ~/.acme.sh/{host}/fullchain.cer")
certRaw = flag.String("certRaw", "", "Raw TLS certificate content. Intended only for Android.")
key = flag.String("key", "", "(server) Path to TLS key file. Default: ~/.acme.sh/{host}/{host}.key")
mode = flag.String("mode", "websocket", "Transport mode: websocket, quic (enforced tls).")
mode = flag.String("mode", "websocket", "Transport mode: websocket, http (enforced tls), quic (enforced tls).")
mux = flag.Int("mux", 1, "Concurrent multiplexed connections (websocket client mode only).")
server = flag.Bool("server", false, "Run in server mode")
logLevel = flag.String("loglevel", "", "loglevel for v2ray: debug, info, warning (default), error, none.")
Expand Down Expand Up @@ -142,6 +143,12 @@ func generateConfig() (*core.Config, error) {
if *mux != 0 {
connectionReuse = true
}
case "http":
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe http2 is better.

transportSettings = &http.Config{
Path: *path,
Host: []string{*host},
}
*tlsEnabled = true
case "quic":
transportSettings = &quic.Config{
Security: &protocol.SecurityConfig{Type: protocol.SecurityType_NONE},
Expand Down