| 3414 | } |
| 3415 | |
| 3416 | func requestIPEncodingHeaders(options RequestOptions) { |
| 3417 | encodedIPs := []string{ |
| 3418 | "127.0.0.1", |
| 3419 | "127.1", |
| 3420 | "0177.0.0.1", |
| 3421 | "0x7f.0x0.0x0.0x1", |
| 3422 | "2130706433", |
| 3423 | "localhost", |
| 3424 | "[::1]", |
| 3425 | "::ffff:127.0.0.1", |
| 3426 | } |
| 3427 | headersToTry := []string{ |
| 3428 | "X-Forwarded-For", |
| 3429 | "Client-IP", |
| 3430 | "True-Client-IP", |
| 3431 | "X-Real-IP", |
| 3432 | "CF-Connecting-IP", |
| 3433 | } |
| 3434 | |
| 3435 | type ipEncodingPayload struct { |
| 3436 | headers []header |
| 3437 | label string |
| 3438 | } |
| 3439 | var payloads []ipEncodingPayload |
| 3440 | for _, h := range headersToTry { |
| 3441 | for _, ip := range encodedIPs { |
| 3442 | payloads = append(payloads, ipEncodingPayload{ |
| 3443 | headers: []header{{h, ip}}, |
| 3444 | label: h + ": " + ip, |
| 3445 | }) |
| 3446 | } |
| 3447 | } |
| 3448 | |
| 3449 | w := goccm.New(maxGoroutines) |
| 3450 | p := newProgress("ip-encoding", len(payloads)) |
| 3451 | |
| 3452 | for _, payload := range payloads { |
| 3453 | time.Sleep(time.Duration(delay) * time.Millisecond) |
| 3454 | w.Wait() |
| 3455 | go func(payload ipEncodingPayload) { |
| 3456 | defer w.Done() |
| 3457 | defer p.done() |
| 3458 | |
| 3459 | headers := make([]header, len(options.headers)) |
| 3460 | copy(headers, options.headers) |
| 3461 | headers = append(headers, payload.headers...) |
| 3462 | |
| 3463 | resp, err := requestWithRetry(options.method, options.uri, headers, options.proxy, options.rateLimit, options.timeout, options.redirect) |
| 3464 | if err != nil { |
| 3465 | if errors.Is(err, ErrRateLimited) { |
| 3466 | return |
| 3467 | } |
| 3468 | logVerbose(err) |
| 3469 | return |
| 3470 | } |
| 3471 | if isCalibrationMatch(resp.contentLength) { |
| 3472 | return |
| 3473 | } |