You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+33-33Lines changed: 33 additions & 33 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -26,7 +26,7 @@ Subscribe to the [quarterly newsletter](https://tinyletter.com/gor) to stay info
26
26
### Capture traffic from port
27
27
```bash
28
28
# Run on servers where you want to catch traffic. You can run it on each `web` machine.
29
-
sudo gor --input-raw 127.0.0.1:80 --output-tcp replay.local:28020
29
+
sudo gor --input-raw :80 --output-tcp replay.local:28020
30
30
31
31
# Replay server (replay.local).
32
32
gor --input-tcp replay.local:28020 --output-http http://staging.com
@@ -38,7 +38,7 @@ Since Gor use raw sockets to capture traffic it require `sudo` access. Alternati
38
38
It's recommended to use separate server for replaying traffic, but if you have enough CPU resources you can use single Gor instance.
39
39
40
40
```
41
-
sudo gor --input-raw 127.0.0.1:80 --output-http "http://staging.com"
41
+
sudo gor --input-raw :80 --output-http "http://staging.com"
42
42
```
43
43
44
44
## Configuration
@@ -98,18 +98,18 @@ gor --input-tcp :28020 --output-http "http://staging.com|10"
98
98
```
99
99
# replay server will not get more than 10% of requests
100
100
# useful for high-load environments
101
-
gor --input-raw 127.0.0.1:80 --output-tcp "replay.local:28020|10%"
101
+
gor --input-raw :80 --output-tcp "replay.local:28020|10%"
102
102
```
103
103
104
104
#### Limiting based on Header or URL param value
105
105
If you have unique user id (like API key) stored in header or URL you can consistently forward specified percent of traffic only for fraction of this users.
106
106
Basic formula looks like this: `FNV32-1A_hashing(value) % 100 >= chance`. Examples:
107
107
```
108
108
# Limit based on header value
109
-
gor --input-raw 127.0.0.1:80 --output-tcp "replay.local:28020|10%" --http-header-limiter "X-API-KEY: 10%"
109
+
gor --input-raw :80 --output-tcp "replay.local:28020|10%" --http-header-limiter "X-API-KEY: 10%"
110
110
111
111
# Limit based on header value
112
-
gor --input-raw 127.0.0.1:80 --output-tcp "replay.local:28020|10%" --http-param-limiter "api_key: 10%"
112
+
gor --input-raw :80 --output-tcp "replay.local:28020|10%" --http-param-limiter "api_key: 10%"
113
113
```
114
114
Only percentage based limiting supported.
115
115
@@ -118,29 +118,29 @@ Only percentage based limiting supported.
118
118
#### Allow url regexp
119
119
```
120
120
# only forward requests being sent to the /api endpoint
121
-
gor --input-raw 127.0.0.1:8080 --output-http staging.com --http-allow-url /api
121
+
gor --input-raw :8080 --output-http staging.com --http-allow-url /api
122
122
```
123
123
124
124
#### Disallow url regexp
125
125
```
126
126
# only forward requests NOT being sent to the /api... endpoint
127
-
gor --input-raw 127.0.0.1:8080 --output-http staging.com --http-disallow-url /api
127
+
gor --input-raw :8080 --output-http staging.com --http-disallow-url /api
128
128
```
129
129
#### Filter based on regexp of header
130
130
131
131
```
132
132
# only forward requests with an api version of 1.0x
133
-
gor --input-raw 127.0.0.1:8080 --output-http staging.com --http-allow-header api-version:^1\.0\d
133
+
gor --input-raw :8080 --output-http staging.com --http-allow-header api-version:^1\.0\d
134
134
135
135
# only forward requests NOT containing User-Agent header value "Replayed by Gor"
136
-
gor --input-raw 127.0.0.1:8080 --output-http staging.com --http-disallow-header "User-Agent: Replayed by Gor"
136
+
gor --input-raw :8080 --output-http staging.com --http-disallow-header "User-Agent: Replayed by Gor"
137
137
```
138
138
139
139
#### Filter based on http method
140
140
Requests not matching a specified whitelist can be filtered out. For example to strip non-nullipotent requests:
141
141
142
142
```
143
-
gor --input-raw 127.0.0.1:80 --output-http "http://staging.server" \
143
+
gor --input-raw :80 --output-http "http://staging.server" \
144
144
--http-allow-method GET \
145
145
--http-allow-method OPTIONS
146
146
```
@@ -151,20 +151,20 @@ Gor supports some basic request rewriting support. For complex logic you can use
151
151
#### Rewrite URL based on a mapping
152
152
```
153
153
# rewrite url to match the following
154
-
gor --input-raw 127.0.0.1:8080 --output-http staging.com --http-rewrite-url /v1/user/([^\\/]+)/ping:/v2/user/$1/ping
154
+
gor --input-raw :8080 --output-http staging.com --http-rewrite-url /v1/user/([^\\/]+)/ping:/v2/user/$1/ping
155
155
```
156
156
157
157
#### Set URL param
158
158
Set request url param, if param already exists it will be overwritten
159
159
```
160
-
gor --input-raw 127.0.0.1:8080 --output-http staging.com --http-set-param api_key=1
160
+
gor --input-raw :8080 --output-http staging.com --http-set-param api_key=1
161
161
```
162
162
163
163
#### Set Header
164
164
Set request header, if header already exists it will be overwritten. This may be useful if you need to identify requests generated by Gor or enable feature flagged functionality in an application:
165
165
166
166
```
167
-
gor --input-raw 127.0.0.1:80 --output-http "http://staging.server" \
167
+
gor --input-raw :80 --output-http "http://staging.server" \
168
168
--http-header "User-Agent: Replayed by Gor" \
169
169
--http-header "Enable-Feature-X: true"
170
170
```
@@ -204,7 +204,7 @@ end
204
204
205
205
Middleware can be enabled using `--middleware` option, by specifying path to executable file:
206
206
```
207
-
gor --input-raw 127.0.0.1:80 --middleware "/opt/middleware_executable" --output-http "http://staging.server"
207
+
gor --input-raw :80 --middleware "/opt/middleware_executable" --output-http "http://staging.server"
208
208
```
209
209
210
210
#### Communication protocol
@@ -246,7 +246,7 @@ Imagine that you have auth system that randomly generate access tokens, which us
246
246
You can save requests to file, and replay them later:
247
247
```
248
248
# write to file
249
-
gor --input-raw 127.0.0.1:80 --output-file requests.gor
249
+
gor --input-raw :80 --output-file requests.gor
250
250
251
251
# read from file
252
252
gor --input-file requests.gor --output-http "http://staging.com"
@@ -268,7 +268,7 @@ gor --input-file "requests.gor|200%" --output-http "staging.com"
268
268
If your development or staging environment is protected by Basic Authentication then those credentials can be injected in during the replay:
269
269
270
270
```
271
-
gor --input-raw 127.0.0.1:80 --output-http "http://user:pass@staging .com"
271
+
gor --input-raw :80 --output-http "http://user:pass@staging .com"
272
272
```
273
273
274
274
Note: This will overwrite any Authorization headers in the original request.
@@ -277,7 +277,7 @@ Note: This will overwrite any Authorization headers in the original request.
277
277
By default Gor use `libpcap`for intercepting traffic. If you have any troubles with it, you may try alternative engine: `raw_socket`.
278
278
279
279
```
280
-
sudo gor --input-raw 127.0.0.1:80 --input-raw-engine "libpcap" --output-http "http://staging.com"
280
+
sudo gor --input-raw :80 --input-raw-engine "libpcap" --output-http "http://staging.com"
0 commit comments