Joe Mornin
Joe Mornin

Reputation: 9134

wget on behalf of a web user

I'm imagining a web interface that uses wget to retrieve a URL that the web user specifies. The interaction looks like this:

  1. The user enters a URL into a web form and submits it to the server.
  2. The server retrieves the page with wget and stores it at /path/to/index.html.
  3. The server redirects the user to example.com/path/to/index.html, which serves the page that was just downloaded.

The problem is that I'm worried sites may start throttling the server's IP address if it sends too many requests.

Is it possible to run wget in such a way that it redirects the output to the user's IP address, which the web interface would then redirect to the server? I'm aware that this could lead to a heinously ugly hack, but I'm curious if it's technically feasible.

Upvotes: 0

Views: 138

Answers (1)

Wug
Wug

Reputation: 13196

The short answer is no.

The long answer is that it's probably possible, but enormously impractical for the following reasons:

  1. Server would need to spoof TCP packets, which it shouldn't be able to.
  2. All hops between server and third party would have to accept spoofed traffic, which they shouldn't.
  3. Client routers/firewalls would have to accept unsolicited TCP responses, which they won't.
  4. Establishing the TCP connection like that would require forwarding all sorts of hairy data from the client to the server, which is a highly platform and network dependent process.
  5. In order to authenticate to the third party, you'd have to send your credentials through the process, which is an awful idea.
  6. Accepting unsolicited requests in this manner would make you extremely vulnerable to denial of service attacks (Someone generates 10 million requests on your behalf for a 40 megabyte file).

Upvotes: 1

Related Questions