diff --git a/README.md b/README.md index 1c3fe78..d156411 100644 --- a/README.md +++ b/README.md @@ -33,12 +33,12 @@ frp also offers a P2P connect mode. * [Development Status](#development-status) * [Architecture](#architecture) * [Example Usage](#example-usage) - * [Access your computer in LAN by SSH](#access-your-computer-in-lan-by-ssh) - * [Visit your web service in LAN by custom domains](#visit-your-web-service-in-lan-by-custom-domains) - * [Forward DNS query request](#forward-dns-query-request) - * [Forward Unix domain socket](#forward-unix-domain-socket) + * [Access your computer in a LAN network via SSH](#access-your-computer-in-a-lan-network-via-ssh) + * [Accessing Internal Web Services with Custom Domains in LAN](#accessing-internal-web-services-with-custom-domains-in-lan) + * [Forward DNS query requests](#forward-dns-query-requests) + * [Forward Unix Domain Socket](#forward-unix-domain-socket) * [Expose a simple HTTP file server](#expose-a-simple-http-file-server) - * [Enable HTTPS for local HTTP(S) service](#enable-https-for-local-https-service) + * [Enable HTTPS for a local HTTP(S) service](#enable-https-for-a-local-https-service) * [Expose your service privately](#expose-your-service-privately) * [P2P Mode](#p2p-mode) * [Features](#features) @@ -101,15 +101,15 @@ We will transition from version 0 to version 1 at the appropriate time and will ## Example Usage -Firstly, download the latest programs from [Release](https://github.com/fatedier/frp/releases) page according to your operating system and architecture. +To begin, download the latest program for your operating system and architecture from the [Release](https://github.com/fatedier/frp/releases) page. -Put `frps` and `frps.ini` onto your server A with public IP. +Next, place the `frps` binary and `frps.ini` configuration file on Server A, which has a public IP address. -Put `frpc` and `frpc.ini` onto your server B in LAN (that can't be connected from public Internet). +Finally, place the `frpc` binary and `frpc.ini` configuration file on Server B, which is located on a LAN that cannot be directly accessed from the public internet. -### Access your computer in LAN by SSH +### Access your computer in a LAN network via SSH -1. Modify `frps.ini` on server A and set the `bind_port` to be connected to frp clients: +1. Modify `frps.ini` on server A by setting the `bind_port` for frp clients to connect to: ```ini # frps.ini @@ -121,7 +121,7 @@ Put `frpc` and `frpc.ini` onto your server B in LAN (that can't be connected fro `./frps -c ./frps.ini` -3. On server B, modify `frpc.ini` to put in your `frps` server public IP as `server_addr` field: +3. Modify `frpc.ini` on server B and set the `server_addr` field to the public IP address of your frps server: ```ini # frpc.ini @@ -136,23 +136,23 @@ Put `frpc` and `frpc.ini` onto your server B in LAN (that can't be connected fro remote_port = 6000 ``` -Note that `local_port` (listened on client) and `remote_port` (exposed on server) are for traffic goes in/out the frp system, whereas `server_port` is used between frps. +Note that the `local_port` (listened on the client) and `remote_port` (exposed on the server) are used for traffic going in and out of the frp system, while the `server_port` is used for communication between frps and frpc. 4. Start `frpc` on server B: `./frpc -c ./frpc.ini` -5. From another machine, SSH to server B via server A like this (assuming that username is `test`): +5. To access server B from another machine through server A via SSH (assuming the username is `test`), use the following command: `ssh -oPort=6000 test@x.x.x.x` -### Visit your web service in LAN by custom domains +### Accessing Internal Web Services with Custom Domains in LAN -Sometimes we want to expose a local web service behind a NAT network to others for testing with your own domain name and unfortunately we can't resolve a domain name to a local IP. +Sometimes we need to expose a local web service behind a NAT network to others for testing purposes with our own domain name. -However, we can expose an HTTP(S) service using frp. +Unfortunately, we cannot resolve a domain name to a local IP. However, we can use frp to expose an HTTP(S) service. -1. Modify `frps.ini`, set the vhost HTTP port to 8080: +1. Modify `frps.ini` and set the HTTP port for vhost to 8080: ```ini # frps.ini @@ -165,7 +165,7 @@ However, we can expose an HTTP(S) service using frp. `./frps -c ./frps.ini` -3. Modify `frpc.ini` and set `server_addr` to the IP address of the remote frps server. The `local_port` is the port of your web service: +3. Modify `frpc.ini` and set `server_addr` to the IP address of the remote frps server. Specify the `local_port` of your web service: ```ini # frpc.ini @@ -183,11 +183,11 @@ However, we can expose an HTTP(S) service using frp. `./frpc -c ./frpc.ini` -5. Resolve A record of `www.example.com` to the public IP of the remote frps server or CNAME record to your origin domain. +5. Map the A record of `www.example.com` to either the public IP of the remote frps server or a CNAME record pointing to your original domain. -6. Now visit your local web service using url `http://www.example.com:8080`. +6. Visit your local web service using url `http://www.example.com:8080`. -### Forward DNS query request +### Forward DNS query requests 1. Modify `frps.ini`: @@ -201,7 +201,7 @@ However, we can expose an HTTP(S) service using frp. `./frps -c ./frps.ini` -3. Modify `frpc.ini` and set `server_addr` to the IP address of the remote frps server, forward DNS query request to Google Public DNS server `8.8.8.8:53`: +3. Modify `frpc.ini` and set `server_addr` to the IP address of the remote frps server. Forward DNS query requests to the Google Public DNS server `8.8.8.8:53`: ```ini # frpc.ini @@ -220,17 +220,17 @@ However, we can expose an HTTP(S) service using frp. `./frpc -c ./frpc.ini` -5. Test DNS resolution using `dig` command: +5. Test DNS resolution using the `dig` command: `dig @x.x.x.x -p 6000 www.google.com` -### Forward Unix domain socket +### Forward Unix Domain Socket Expose a Unix domain socket (e.g. the Docker daemon socket) as TCP. -Configure `frps` same as above. +Configure `frps` as above. -1. Start `frpc` with configuration: +1. Start `frpc` with the following configuration: ```ini # frpc.ini @@ -245,17 +245,17 @@ Configure `frps` same as above. plugin_unix_path = /var/run/docker.sock ``` -2. Test: Get Docker version using `curl`: +2. Test the configuration by getting the docker version using `curl`: `curl http://x.x.x.x:6000/version` ### Expose a simple HTTP file server -Browser your files stored in the LAN, from public Internet. +Expose a simple HTTP file server to access files stored in the LAN from the public Internet. -Configure `frps` same as above. +Configure `frps` as described above, then: -1. Start `frpc` with configuration: +1. Start `frpc` with the following configuration: ```ini # frpc.ini @@ -273,13 +273,13 @@ Configure `frps` same as above. plugin_http_passwd = abc ``` -2. Visit `http://x.x.x.x:6000/static/` from your browser and specify correct user and password to view files in `/tmp/files` on the `frpc` machine. +2. Visit `http://x.x.x.x:6000/static/` from your browser and specify correct username and password to view files in `/tmp/files` on the `frpc` machine. -### Enable HTTPS for local HTTP(S) service +### Enable HTTPS for a local HTTP(S) service You may substitute `https2https` for the plugin, and point the `plugin_local_addr` to a HTTPS endpoint. -1. Start `frpc` with configuration: +1. Start `frpc` with the following configuration: ```ini # frpc.ini @@ -303,7 +303,7 @@ You may substitute `https2https` for the plugin, and point the `plugin_local_add ### Expose your service privately -Some services will be at risk if exposed directly to the public network. With **STCP** (secret TCP) mode, a preshared key is needed to access the service from another client. +To mitigate risks associated with exposing certain services directly to the public network, STCP (Secret TCP) mode requires a preshared key to be used for access to the service from other clients. Configure `frps` same as above. @@ -345,9 +345,9 @@ Configure `frps` same as above. ### P2P Mode -**xtcp** is designed for transmitting large amounts of data directly between clients. A frps server is still needed, as P2P here only refers the actual data transmission. +**xtcp** is designed to transmit large amounts of data directly between clients. A frps server is still needed, as P2P here only refers to the actual data transmission. -Note it can't penetrate all types of NAT devices. You might want to fallback to **stcp** if **xtcp** doesn't work. +Note that it may not work with all types of NAT devices. You might want to fallback to stcp if xtcp doesn't work. 1. In `frps.ini` configure a UDP port for xtcp: @@ -356,7 +356,7 @@ Note it can't penetrate all types of NAT devices. You might want to fallback to bind_udp_port = 7001 ``` -2. Start `frpc` on machine B, expose the SSH port. Note that `remote_port` field is removed: +2. Start `frpc` on machine B, and expose the SSH port. Note that the `remote_port` field is removed: ```ini # frpc.ini @@ -371,7 +371,7 @@ Note it can't penetrate all types of NAT devices. You might want to fallback to local_port = 22 ``` -3. Start another `frpc` (typically on another machine C) with the config to connect to SSH using P2P mode: +3. Start another `frpc` (typically on another machine C) with the configuration to connect to SSH using P2P mode: ```ini # frpc.ini diff --git a/go.mod b/go.mod index 6c261c2..41773bd 100644 --- a/go.mod +++ b/go.mod @@ -13,15 +13,15 @@ require ( github.com/gorilla/mux v1.8.0 github.com/gorilla/websocket v1.5.0 github.com/hashicorp/yamux v0.1.1 - github.com/onsi/ginkgo v1.16.4 - github.com/onsi/gomega v1.23.0 + github.com/onsi/ginkgo/v2 v2.8.3 + github.com/onsi/gomega v1.27.0 github.com/pires/go-proxyproto v0.6.2 github.com/prometheus/client_golang v1.13.0 github.com/quic-go/quic-go v0.32.0 github.com/rodaine/table v1.0.1 github.com/spf13/cobra v1.1.3 github.com/stretchr/testify v1.8.0 - golang.org/x/net v0.4.0 + golang.org/x/net v0.7.0 golang.org/x/oauth2 v0.3.0 golang.org/x/time v0.0.0-20220210224613-90d013bbcef8 gopkg.in/ini.v1 v1.67.0 @@ -34,7 +34,7 @@ require ( github.com/beorn7/perks v1.0.1 // indirect github.com/cespare/xxhash/v2 v2.1.2 // indirect github.com/davecgh/go-spew v1.1.1 // indirect - github.com/fsnotify/fsnotify v1.4.9 // indirect + github.com/go-logr/logr v1.2.3 // indirect github.com/go-playground/locales v0.14.0 // indirect github.com/go-playground/universal-translator v0.18.0 // indirect github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0 // indirect @@ -48,8 +48,6 @@ require ( github.com/klauspost/reedsolomon v1.9.15 // indirect github.com/leodido/go-urn v1.2.1 // indirect github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect - github.com/nxadm/tail v1.4.8 // indirect - github.com/onsi/ginkgo/v2 v2.4.0 // indirect github.com/pkg/errors v0.9.1 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/prometheus/client_model v0.2.0 // indirect @@ -64,14 +62,13 @@ require ( github.com/tjfoc/gmsm v1.4.1 // indirect golang.org/x/crypto v0.4.0 // indirect golang.org/x/exp v0.0.0-20221205204356-47842c84f3db // indirect - golang.org/x/mod v0.6.0 // indirect - golang.org/x/sys v0.3.0 // indirect - golang.org/x/text v0.5.0 // indirect - golang.org/x/tools v0.2.0 // indirect + golang.org/x/mod v0.8.0 // indirect + golang.org/x/sys v0.5.0 // indirect + golang.org/x/text v0.7.0 // indirect + golang.org/x/tools v0.6.0 // indirect google.golang.org/appengine v1.6.7 // indirect google.golang.org/protobuf v1.28.1 // indirect gopkg.in/square/go-jose.v2 v2.6.0 // indirect - gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect k8s.io/utils v0.0.0-20221107191617-1a15be271d1d // indirect ) diff --git a/go.sum b/go.sum index 500e06b..9925c93 100644 --- a/go.sum +++ b/go.sum @@ -127,8 +127,6 @@ github.com/fatedier/kcp-go v2.0.4-0.20190803094908-fe8645b0a904+incompatible h1: github.com/fatedier/kcp-go v2.0.4-0.20190803094908-fe8645b0a904+incompatible/go.mod h1:YpCOaxj7vvMThhIQ9AfTOPW2sfztQR5WDfs7AflSy4s= github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= -github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4= -github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= @@ -142,6 +140,7 @@ github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A= github.com/go-logfmt/logfmt v0.5.1/go.mod h1:WYhtIu8zTZfxdn5+rREduYbwxfcBr/Vr6KEVveWlfTs= github.com/go-logr/logr v1.2.3 h1:2DntVwHkVopvECVRSlL5PSo9eG+cAkDCuckLubN+rq0= +github.com/go-logr/logr v1.2.3/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= github.com/go-playground/assert/v2 v2.0.1 h1:MsBgLAaY856+nPRTKrp3/OZK38U/wa0CcBYNjji3q3A= github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= github.com/go-playground/locales v0.14.0 h1:u50s323jtVGugKlcYeyzC0etD1HifMjqmJqb8WugfUU= @@ -273,7 +272,6 @@ github.com/hashicorp/memberlist v0.1.3/go.mod h1:ajVTdAv/9Im8oMAAj5G31PhhMCZJV2p github.com/hashicorp/serf v0.8.2/go.mod h1:6hOLApaqBFA1NXqRQAsxw9QxuDEvNxSQRwA/JwenrHc= github.com/hashicorp/yamux v0.1.1 h1:yrQxtgseBDrq9Y652vSRDvsKCJKOUD+GzTS4Y0Y8pvE= github.com/hashicorp/yamux v0.1.1/go.mod h1:CtWFDAQgb7dxtzFs4tWbplKIe2jSi3+5vKbgIO0SLnQ= -github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM= @@ -331,20 +329,11 @@ github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3Rllmb github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= -github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= -github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE= -github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU= github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U= -github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= -github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk= -github.com/onsi/ginkgo v1.16.4 h1:29JGrr5oVBm5ulCWet69zQkzWipVXIol6ygQUe/EzNc= -github.com/onsi/ginkgo v1.16.4/go.mod h1:dX+/inL/fNMqNlz0e9LfyB9TswhZpCVdJM/Z6Vvnwo0= -github.com/onsi/ginkgo/v2 v2.4.0 h1:+Ig9nvqgS5OBSACXNk15PLdp0U9XPYROt9CFzVdFGIs= -github.com/onsi/ginkgo/v2 v2.4.0/go.mod h1:iHkDK1fKGcBoEHT5W7YBq4RFWaQulw+caOMkAt4OrFo= -github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= -github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= -github.com/onsi/gomega v1.23.0 h1:/oxKu9c2HVap+F3PfKort2Hw5DEU+HGlW8n+tguWsys= -github.com/onsi/gomega v1.23.0/go.mod h1:Z/NWtiqwBrwUt4/2loMmHL63EDLnYHmVbuBpDr2vQAg= +github.com/onsi/ginkgo/v2 v2.8.3 h1:RpbK1G8nWPNaCVFBWsOGnEQQGgASi6b8fxcWBvDYjxQ= +github.com/onsi/ginkgo/v2 v2.8.3/go.mod h1:6OaUA8BCi0aZfmzYT/q9AacwTzDpNbxILUT+TlBq6MY= +github.com/onsi/gomega v1.27.0 h1:QLidEla4bXUuZVFa4KX6JHCsuGgbi85LC/pCHrt/O08= +github.com/onsi/gomega v1.27.0/go.mod h1:i189pavgK95OSIipFBa74gC2V4qrQuvjuyGEr3GmbXA= github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= github.com/pires/go-proxyproto v0.6.2 h1:KAZ7UteSOt6urjme6ZldyFm4wDe/z0ZUP0Yv0Dos0d8= @@ -510,11 +499,10 @@ golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.6.0 h1:b9gGHsz9/HhJ3HF5DHQytPpuwocVTChQJK3AvoLRD5I= -golang.org/x/mod v0.6.0/go.mod h1:4mET923SAdbXp2ki8ey+zGs1SLqsuM2Y0uvdZR/fUNI= +golang.org/x/mod v0.8.0 h1:LUYupSeNrTNCGzR/hVBk2NHZO4hXcVaW1k4Qx7rjPx8= +golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20181023162649-9b4f9f5ad519/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20181201002055-351d144fa1fc/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -540,7 +528,6 @@ golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/ golang.org/x/net v0.0.0-20200501053045-e0ff5e5a1de5/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20200506145744-7e3656a0809f/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20200513185701-a91f0712d120/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= -golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20200520182314-0ba52f642ac2/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= @@ -565,8 +552,8 @@ golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4/go.mod h1:CfG3xpIq0wQ8r1q4Su golang.org/x/net v0.0.0-20220607020251-c690dde0001d/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.0.0-20220624214902-1bab6f366d9e/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.0.0-20220826154423-83b083e8dc8b/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk= -golang.org/x/net v0.4.0 h1:Q5QPcMlvfxFTAPV0+07Xz/MpK9NTXu2VDUuy0FeMfaU= -golang.org/x/net v0.4.0/go.mod h1:MBQ8lrhLObU/6UmLb4fmbmk5OcyYmqtbGd/9yIeKjEE= +golang.org/x/net v0.7.0 h1:rJrUqqhjsgNp7KqAIc25s9pZnjU7TUcSY7HcVZjdn1g= +golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -605,7 +592,6 @@ golang.org/x/sync v0.0.0-20220601150217-0de741cfad7f/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181026203630-95b1ffbd15a5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181107165924-66b7b1311ac8/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -618,10 +604,7 @@ golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200106162015-b016eb3dc98e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -645,7 +628,6 @@ golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201201145000-ef89a241ccb3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210104204734-6f8348627aad/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210220050731-9a76102bfb43/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -678,8 +660,8 @@ golang.org/x/sys v0.0.0-20220503163025-988cb79eb6c6/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220610221304-9f5ed59c137d/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.3.0 h1:w8ZOecv6NaNa/zC8944JTU3vz4u6Lagfk4RPQxv92NQ= -golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU= +golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -691,8 +673,8 @@ golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= -golang.org/x/text v0.5.0 h1:OLmvp0KP+FVG99Ct/qFiL/Fhk4zp4QQnZ7b2U+5piUM= -golang.org/x/text v0.5.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= +golang.org/x/text v0.7.0 h1:4BRB4x83lYWy72KwLD/qYDuTu7q9PjSagHvijDw7cLo= +golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= @@ -745,7 +727,6 @@ golang.org/x/tools v0.0.0-20200904185747-39188db58858/go.mod h1:Cj7w3i3Rnn0Xh82u golang.org/x/tools v0.0.0-20201110124207-079ba7bd75cd/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.0.0-20201201161351-ac6f37ff4c2a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.0.0-20201208233053-a543418bbed2/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.0.0-20210105154028-b0ab187a4818/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0= golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= @@ -753,8 +734,8 @@ golang.org/x/tools v0.1.2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.3/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.4/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= -golang.org/x/tools v0.2.0 h1:G6AHpWxTMGY1KyEYoAQ5WTtIekUUvDNjan3ugu60JvE= -golang.org/x/tools v0.2.0/go.mod h1:y4OqIKeOV/fWJetJ8bXPU1sEVniLMIyDAZWeHdV+NTA= +golang.org/x/tools v0.6.0 h1:BOw41kyTf3PuCW1pVQf8+Cyg8pMlkYB1oo9iJ6D/lKM= +golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -942,15 +923,12 @@ gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8 gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= -gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= gopkg.in/ini.v1 v1.51.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA= gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo= gopkg.in/square/go-jose.v2 v2.6.0 h1:NGk74WTnPKBNUhNzQX7PYcTLUjoq7mzKk2OKbvwk2iI= gopkg.in/square/go-jose.v2 v2.6.0/go.mod h1:M9dMgbHiYLoDGQrXy7OpJDJWiKiU//h+vD76mk0e1AI= -gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= -gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74= gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/hack/run-e2e.sh b/hack/run-e2e.sh index d8cfb05..ab59c11 100755 --- a/hack/run-e2e.sh +++ b/hack/run-e2e.sh @@ -5,7 +5,7 @@ ROOT=$(unset CDPATH && cd $(dirname "${BASH_SOURCE[0]}")/.. && pwd) which ginkgo &> /dev/null if [ $? -ne 0 ]; then echo "ginkgo not found, try to install..." - go install github.com/onsi/ginkgo/ginkgo@v1.16.5 + go install github.com/onsi/ginkgo/v2/ginkgo@v2.8.3 fi debug=false @@ -17,4 +17,4 @@ if [ x${LOG_LEVEL} != x"" ]; then logLevel=${LOG_LEVEL} fi -ginkgo -nodes=8 -slowSpecThreshold=20 ${ROOT}/test/e2e -- -frpc-path=${ROOT}/bin/frpc -frps-path=${ROOT}/bin/frps -log-level=${logLevel} -debug=${debug} +ginkgo -nodes=8 --poll-progress-after=20s ${ROOT}/test/e2e -- -frpc-path=${ROOT}/bin/frpc -frps-path=${ROOT}/bin/frps -log-level=${logLevel} -debug=${debug} diff --git a/test/e2e/basic/basic.go b/test/e2e/basic/basic.go index 1f1b200..7fd74e9 100644 --- a/test/e2e/basic/basic.go +++ b/test/e2e/basic/basic.go @@ -5,7 +5,7 @@ import ( "fmt" "strings" - "github.com/onsi/ginkgo" + "github.com/onsi/ginkgo/v2" "github.com/fatedier/frp/pkg/transport" "github.com/fatedier/frp/test/e2e/framework" diff --git a/test/e2e/basic/client.go b/test/e2e/basic/client.go index 10489d4..95561a3 100644 --- a/test/e2e/basic/client.go +++ b/test/e2e/basic/client.go @@ -6,7 +6,7 @@ import ( "strings" "time" - "github.com/onsi/ginkgo" + "github.com/onsi/ginkgo/v2" "github.com/fatedier/frp/test/e2e/framework" "github.com/fatedier/frp/test/e2e/framework/consts" diff --git a/test/e2e/basic/client_server.go b/test/e2e/basic/client_server.go index 32a6bbe..65ba2ba 100644 --- a/test/e2e/basic/client_server.go +++ b/test/e2e/basic/client_server.go @@ -4,7 +4,7 @@ import ( "fmt" "strings" - "github.com/onsi/ginkgo" + "github.com/onsi/ginkgo/v2" "github.com/fatedier/frp/test/e2e/framework" "github.com/fatedier/frp/test/e2e/framework/consts" diff --git a/test/e2e/basic/cmd.go b/test/e2e/basic/cmd.go index bf8f246..89f2435 100644 --- a/test/e2e/basic/cmd.go +++ b/test/e2e/basic/cmd.go @@ -5,7 +5,7 @@ import ( "strconv" "strings" - "github.com/onsi/ginkgo" + "github.com/onsi/ginkgo/v2" "github.com/fatedier/frp/test/e2e/framework" "github.com/fatedier/frp/test/e2e/pkg/request" diff --git a/test/e2e/basic/config.go b/test/e2e/basic/config.go index 3ea07b3..acee2c5 100644 --- a/test/e2e/basic/config.go +++ b/test/e2e/basic/config.go @@ -3,7 +3,7 @@ package basic import ( "fmt" - "github.com/onsi/ginkgo" + "github.com/onsi/ginkgo/v2" "github.com/fatedier/frp/test/e2e/framework" "github.com/fatedier/frp/test/e2e/framework/consts" diff --git a/test/e2e/basic/http.go b/test/e2e/basic/http.go index 0de24ab..f8b1738 100644 --- a/test/e2e/basic/http.go +++ b/test/e2e/basic/http.go @@ -7,7 +7,7 @@ import ( "strconv" "github.com/gorilla/websocket" - "github.com/onsi/ginkgo" + "github.com/onsi/ginkgo/v2" "github.com/fatedier/frp/test/e2e/framework" "github.com/fatedier/frp/test/e2e/framework/consts" diff --git a/test/e2e/basic/server.go b/test/e2e/basic/server.go index a06f6d1..4ae8251 100644 --- a/test/e2e/basic/server.go +++ b/test/e2e/basic/server.go @@ -5,7 +5,7 @@ import ( "net" "strconv" - "github.com/onsi/ginkgo" + "github.com/onsi/ginkgo/v2" "github.com/fatedier/frp/test/e2e/framework" "github.com/fatedier/frp/test/e2e/framework/consts" diff --git a/test/e2e/e2e.go b/test/e2e/e2e.go index 6b0d3e0..30887d2 100644 --- a/test/e2e/e2e.go +++ b/test/e2e/e2e.go @@ -3,8 +3,7 @@ package e2e import ( "testing" - "github.com/onsi/ginkgo" - "github.com/onsi/ginkgo/config" + "github.com/onsi/ginkgo/v2" "github.com/onsi/gomega" "github.com/fatedier/frp/pkg/util/log" @@ -33,9 +32,15 @@ var _ = ginkgo.SynchronizedAfterSuite(func() { func RunE2ETests(t *testing.T) { gomega.RegisterFailHandler(framework.Fail) + suiteConfig, reporterConfig := ginkgo.GinkgoConfiguration() + // Turn on EmitSpecProgress to get spec progress (especially on interrupt) + suiteConfig.EmitSpecProgress = true + // Randomize specs as well as suites + suiteConfig.RandomizeAllSpecs = true + log.Info("Starting e2e run %q on Ginkgo node %d of total %d", - framework.RunID, config.GinkgoConfig.ParallelNode, config.GinkgoConfig.ParallelTotal) - ginkgo.RunSpecs(t, "frp e2e suite") + framework.RunID, suiteConfig.ParallelProcess, suiteConfig.ParallelTotal) + ginkgo.RunSpecs(t, "frp e2e suite", suiteConfig, reporterConfig) } // setupSuite is the boilerplate that can be used to setup ginkgo test suites, on the SynchronizedBeforeSuite step. diff --git a/test/e2e/e2e_test.go b/test/e2e/e2e_test.go index d1cc639..f809288 100644 --- a/test/e2e/e2e_test.go +++ b/test/e2e/e2e_test.go @@ -6,7 +6,7 @@ import ( "os" "testing" - _ "github.com/onsi/ginkgo" + _ "github.com/onsi/ginkgo/v2" "github.com/fatedier/frp/pkg/util/log" // test source diff --git a/test/e2e/examples.go b/test/e2e/examples.go index 26eca20..9accdf9 100644 --- a/test/e2e/examples.go +++ b/test/e2e/examples.go @@ -3,7 +3,7 @@ package e2e import ( "fmt" - "github.com/onsi/ginkgo" + "github.com/onsi/ginkgo/v2" "github.com/fatedier/frp/test/e2e/framework" "github.com/fatedier/frp/test/e2e/framework/consts" diff --git a/test/e2e/features/bandwidth_limit.go b/test/e2e/features/bandwidth_limit.go index 238055a..96d2364 100644 --- a/test/e2e/features/bandwidth_limit.go +++ b/test/e2e/features/bandwidth_limit.go @@ -5,7 +5,7 @@ import ( "strings" "time" - "github.com/onsi/ginkgo" + "github.com/onsi/ginkgo/v2" plugin "github.com/fatedier/frp/pkg/plugin/server" "github.com/fatedier/frp/test/e2e/framework" diff --git a/test/e2e/features/chaos.go b/test/e2e/features/chaos.go index bae6eb7..9fccc4c 100644 --- a/test/e2e/features/chaos.go +++ b/test/e2e/features/chaos.go @@ -4,7 +4,7 @@ import ( "fmt" "time" - "github.com/onsi/ginkgo" + "github.com/onsi/ginkgo/v2" "github.com/fatedier/frp/test/e2e/framework" ) diff --git a/test/e2e/features/group.go b/test/e2e/features/group.go index f36e75b..8ec6112 100644 --- a/test/e2e/features/group.go +++ b/test/e2e/features/group.go @@ -6,7 +6,7 @@ import ( "sync" "time" - "github.com/onsi/ginkgo" + "github.com/onsi/ginkgo/v2" "github.com/fatedier/frp/test/e2e/framework" "github.com/fatedier/frp/test/e2e/framework/consts" diff --git a/test/e2e/features/heartbeat.go b/test/e2e/features/heartbeat.go index 3ffbd83..09bf0e6 100644 --- a/test/e2e/features/heartbeat.go +++ b/test/e2e/features/heartbeat.go @@ -4,7 +4,7 @@ import ( "fmt" "time" - "github.com/onsi/ginkgo" + "github.com/onsi/ginkgo/v2" "github.com/fatedier/frp/test/e2e/framework" ) diff --git a/test/e2e/features/monitor.go b/test/e2e/features/monitor.go index bf074e6..74996d2 100644 --- a/test/e2e/features/monitor.go +++ b/test/e2e/features/monitor.go @@ -5,7 +5,7 @@ import ( "strings" "time" - "github.com/onsi/ginkgo" + "github.com/onsi/ginkgo/v2" "github.com/fatedier/frp/pkg/util/log" "github.com/fatedier/frp/test/e2e/framework" diff --git a/test/e2e/features/real_ip.go b/test/e2e/features/real_ip.go index 3a2a7e4..31f02fe 100644 --- a/test/e2e/features/real_ip.go +++ b/test/e2e/features/real_ip.go @@ -6,7 +6,7 @@ import ( "net" "net/http" - "github.com/onsi/ginkgo" + "github.com/onsi/ginkgo/v2" pp "github.com/pires/go-proxyproto" "github.com/fatedier/frp/pkg/util/log" diff --git a/test/e2e/framework/framework.go b/test/e2e/framework/framework.go index c22c6af..b2f65f2 100644 --- a/test/e2e/framework/framework.go +++ b/test/e2e/framework/framework.go @@ -9,8 +9,7 @@ import ( "strings" "text/template" - "github.com/onsi/ginkgo" - "github.com/onsi/ginkgo/config" + "github.com/onsi/ginkgo/v2" "github.com/fatedier/frp/test/e2e/mock/server" "github.com/fatedier/frp/test/e2e/pkg/port" @@ -63,9 +62,10 @@ type Framework struct { } func NewDefaultFramework() *Framework { + suiteConfig, _ := ginkgo.GinkgoConfiguration() options := Options{ - TotalParallelNode: config.GinkgoConfig.ParallelTotal, - CurrentNodeIndex: config.GinkgoConfig.ParallelNode, + TotalParallelNode: suiteConfig.ParallelTotal, + CurrentNodeIndex: suiteConfig.ParallelProcess, FromPortIndex: 20000, ToPortIndex: 50000, } diff --git a/test/e2e/framework/ginkgowrapper/wrapper.go b/test/e2e/framework/ginkgowrapper/wrapper.go deleted file mode 100644 index 01ccf4d..0000000 --- a/test/e2e/framework/ginkgowrapper/wrapper.go +++ /dev/null @@ -1,80 +0,0 @@ -// Package ginkgowrapper wraps Ginkgo Fail and Skip functions to panic -// with structured data instead of a constant string. -package ginkgowrapper - -import ( - "bufio" - "bytes" - "regexp" - "runtime" - "runtime/debug" - "strings" - - "github.com/onsi/ginkgo" -) - -// FailurePanic is the value that will be panicked from Fail. -type FailurePanic struct { - Message string // The failure message passed to Fail - Filename string // The filename that is the source of the failure - Line int // The line number of the filename that is the source of the failure - FullStackTrace string // A full stack trace starting at the source of the failure -} - -// String makes FailurePanic look like the old Ginkgo panic when printed. -func (FailurePanic) String() string { return ginkgo.GINKGO_PANIC } - -// Fail wraps ginkgo.Fail so that it panics with more useful -// information about the failure. This function will panic with a -// FailurePanic. -func Fail(message string, callerSkip ...int) { - skip := 1 - if len(callerSkip) > 0 { - skip += callerSkip[0] - } - - _, file, line, _ := runtime.Caller(skip) - fp := FailurePanic{ - Message: message, - Filename: file, - Line: line, - FullStackTrace: pruneStack(skip), - } - - defer func() { - e := recover() - if e != nil { - panic(fp) - } - }() - - ginkgo.Fail(message, skip) -} - -// ginkgo adds a lot of test running infrastructure to the stack, so -// we filter those out -var stackSkipPattern = regexp.MustCompile(`onsi/ginkgo`) - -func pruneStack(skip int) string { - skip += 2 // one for pruneStack and one for debug.Stack - stack := debug.Stack() - scanner := bufio.NewScanner(bytes.NewBuffer(stack)) - var prunedStack []string - - // skip the top of the stack - for i := 0; i < 2*skip+1; i++ { - scanner.Scan() - } - - for scanner.Scan() { - if stackSkipPattern.Match(scanner.Bytes()) { - scanner.Scan() // these come in pairs - } else { - prunedStack = append(prunedStack, scanner.Text()) - scanner.Scan() // these come in pairs - prunedStack = append(prunedStack, scanner.Text()) - } - } - - return strings.Join(prunedStack, "\n") -} diff --git a/test/e2e/framework/log.go b/test/e2e/framework/log.go index 34ba293..3cd9906 100644 --- a/test/e2e/framework/log.go +++ b/test/e2e/framework/log.go @@ -1,15 +1,10 @@ package framework import ( - "bytes" "fmt" - "regexp" - "runtime/debug" "time" - "github.com/onsi/ginkgo" - - e2eginkgowrapper "github.com/fatedier/frp/test/e2e/framework/ginkgowrapper" + "github.com/onsi/ginkgo/v2" ) func nowStamp() string { @@ -25,71 +20,14 @@ func Logf(format string, args ...interface{}) { log("INFO", format, args...) } -// Failf logs the fail info, including a stack trace. +// Failf logs the fail info, including a stack trace starts with its direct caller +// (for example, for call chain f -> g -> Failf("foo", ...) error would be logged for "g"). func Failf(format string, args ...interface{}) { - FailfWithOffset(1, format, args...) -} - -// FailfWithOffset calls "Fail" and logs the error with a stack trace that starts at "offset" levels above its caller -// (for example, for call chain f -> g -> FailfWithOffset(1, ...) error would be logged for "f"). -func FailfWithOffset(offset int, format string, args ...interface{}) { msg := fmt.Sprintf(format, args...) - skip := offset + 1 - log("FAIL", "%s\n\nFull Stack Trace\n%s", msg, PrunedStack(skip)) - e2eginkgowrapper.Fail(nowStamp()+": "+msg, skip) -} - -// Fail is a replacement for ginkgo.Fail which logs the problem as it occurs -// together with a stack trace and then calls ginkgowrapper.Fail. -func Fail(msg string, callerSkip ...int) { skip := 1 - if len(callerSkip) > 0 { - skip += callerSkip[0] - } - log("FAIL", "%s\n\nFull Stack Trace\n%s", msg, PrunedStack(skip)) - e2eginkgowrapper.Fail(nowStamp()+": "+msg, skip) + ginkgo.Fail(msg, skip) + panic("unreachable") } -var codeFilterRE = regexp.MustCompile(`/github.com/onsi/ginkgo/`) - -// PrunedStack is a wrapper around debug.Stack() that removes information -// about the current goroutine and optionally skips some of the initial stack entries. -// With skip == 0, the returned stack will start with the caller of PruneStack. -// From the remaining entries it automatically filters out useless ones like -// entries coming from Ginkgo. -// -// This is a modified copy of PruneStack in -// https://github.com/onsi/ginkgo/blob/f90f37d87fa6b1dd9625e2b1e83c23ffae3de228/internal/codelocation/code_location.go#L25: -// - simplified API and thus renamed (calls debug.Stack() instead of taking a parameter) -// - source code filtering updated to be specific to Kubernetes -// - optimized to use bytes and in-place slice filtering from -// https://github.com/golang/go/wiki/SliceTricks#filter-in-place -func PrunedStack(skip int) []byte { - fullStackTrace := debug.Stack() - stack := bytes.Split(fullStackTrace, []byte("\n")) - // Ensure that the even entries are the method names and the - // odd entries the source code information. - if len(stack) > 0 && bytes.HasPrefix(stack[0], []byte("goroutine ")) { - // Ignore "goroutine 29 [running]:" line. - stack = stack[1:] - } - // The "+2" is for skipping over: - // - runtime/debug.Stack() - // - PrunedStack() - skip += 2 - if len(stack) > 2*skip { - stack = stack[2*skip:] - } - n := 0 - for i := 0; i < len(stack)/2; i++ { - // We filter out based on the source code file name. - if !codeFilterRE.Match(stack[i*2+1]) { - stack[n] = stack[i*2] - stack[n+1] = stack[i*2+1] - n += 2 - } - } - stack = stack[:n] - - return bytes.Join(stack, []byte("\n")) -} +// Fail is an alias for ginkgo.Fail. +var Fail = ginkgo.Fail diff --git a/test/e2e/framework/test_context.go b/test/e2e/framework/test_context.go index 42a6644..38f0fb2 100644 --- a/test/e2e/framework/test_context.go +++ b/test/e2e/framework/test_context.go @@ -4,8 +4,6 @@ import ( "flag" "fmt" "os" - - "github.com/onsi/ginkgo/config" ) type TestContextType struct { @@ -25,12 +23,6 @@ var TestContext TestContextType // test-specific flags. However, those settings then get added // regardless whether the test is actually in the test suite. func RegisterCommonFlags(flags *flag.FlagSet) { - // Turn on EmitSpecProgress to get spec progress (especially on interrupt) - config.GinkgoConfig.EmitSpecProgress = true - - // Randomize specs as well as suites - config.GinkgoConfig.RandomizeAllSpecs = true - flags.StringVar(&TestContext.FRPClientPath, "frpc-path", "../../bin/frpc", "The frp client binary to use.") flags.StringVar(&TestContext.FRPServerPath, "frps-path", "../../bin/frps", "The frp server binary to use.") flags.StringVar(&TestContext.LogLevel, "log-level", "debug", "Log level.") diff --git a/test/e2e/plugin/client.go b/test/e2e/plugin/client.go index 081c88f..3046b90 100644 --- a/test/e2e/plugin/client.go +++ b/test/e2e/plugin/client.go @@ -5,7 +5,7 @@ import ( "fmt" "strconv" - "github.com/onsi/ginkgo" + "github.com/onsi/ginkgo/v2" "github.com/fatedier/frp/pkg/transport" "github.com/fatedier/frp/test/e2e/framework" diff --git a/test/e2e/plugin/server.go b/test/e2e/plugin/server.go index e461957..955e3b5 100644 --- a/test/e2e/plugin/server.go +++ b/test/e2e/plugin/server.go @@ -4,7 +4,7 @@ import ( "fmt" "time" - "github.com/onsi/ginkgo" + "github.com/onsi/ginkgo/v2" plugin "github.com/fatedier/frp/pkg/plugin/server" "github.com/fatedier/frp/pkg/transport"