1 Star 2 Fork 0

distill / gupload

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
README.md 2.97 KB
一键复制 编辑 原始数据 按行查看 历史
Hu Lyndon 提交于 2019-08-28 15:32 . README 修改

gupload 📡

Upload files with gRPC and/or HTTP2

Overview

gupload is an experiment to verify how uploading files via gRPC compares to a barebones HTTP2 server.

See sending-files-via-grpc to check the experiment.

NAME:
   gupload - upload files as fast as possible

USAGE:
   gupload [global options] command [command options] [arguments...]

VERSION:
   0.0.0

COMMANDS:
     serve    initiates a gRPC server
     upload   uploads a file
     help, h  Shows a list of commands or help for one command

GLOBAL OPTIONS:
   --debug        enables debug logging (default: false)
   --help, -h     show help (default: false)
   --version, -v  print the version (default: false)

Use serve to initiate a server (either gRPC or http2 based) and upload to upload a file to a given address (either via gRPC or http2).

HTTP2

The http2 version of both server and client require certificates / private keys. This is needed to have a well formed TLS connection between them.

The server takes both of them (certificate and private key) while the client just takes the certificate.

I've already created some certificates at ./certs so you can just reference them as you wish (you can regenerate at any time with make certs).

# Start the HTTP2 server making use of HTTP2
# with the TLS configuration using the key
# and certificate from ./certs
gupload serve \
        --port 1313 \
        --http2 \
        --key ./certs/localhost.key \
        --certificate ./certs/localhost.cert


# Perform the upload of the file `./main.go` to the 
# server at `localhost:1313` via HTTP2 appending
# the self-signed certificate from `certs` to the
# root CAs.
gupload upload \
        --http2 \
        --address localhost:1313 \
        --root-certificate ./certs/localhost.cert \
        --file ./main.go

note.: the certificates have CN (common name) set to localhost. As the client is not skipping insecure certificates, it'll check the address you're trying to connect to and see if it matches the certificate's CN. If you want to customize that (e.g, connect to example.com, make sure you issue a certificate with CN=example.com - or make use of SAN).

GRPC

grpc is the default mechanism used (i.e., to make use of it you should not specify --http2) for both clients and servers.

There are two forms of running it:

  • via "plain-text" TCP
  • via TLS-based http2

To use the first, don't specify certificates, private keys or root certificates. To use the second, do the opposite.

For instance, to use plain tcp:

# Create a server
gupload serve

# Upload a file
gupload upload --file ./main.go

To use tls-based connections:

# Create a server
gupload serve \
        --key ./certs/localhost.key \
        --certificate ./certs/localhost.cert

# Upload a file
gupload upload \
        --root-certificate ./certs/localhost.cert \
        --file ./main.go
1
https://gitee.com/banyanhouse/gupload.git
git@gitee.com:banyanhouse/gupload.git
banyanhouse
gupload
gupload
master

搜索帮助