Solved

Indy: trying to write a proxy

Posted on 2004-09-01
4
1,077 Views
Last Modified: 2008-01-09
What I am trying to do is create a http proxy. One that will check the url of the requested page, and only allow the connection if it is one held in a stringlist.
Delphi 7, latest version of Indy.
I place down an IDMappedPortTCP

onConnect I can athread.connection.readln() to pull out the requested address, but in doing so the page never gets downloaded.
How do I read from the thread without removing the data from the thread? I tried to link in an intercept or an IO handler, but in the object inspector the intercepts and iohandlers did not show.

What would be nice is the handfull of lines that let me see the requested url, and then stop the connection if it is not a defined one.

0
Comment
Question by:Molando
  • 2
  • 2
4 Comments
 
LVL 18

Accepted Solution

by:
Johnjces earned 250 total points
Comment Utility
Woops!

You might try installing the Indy HttpProxy component which can be found in the Indy folder called:

 IdHttpProxyServer.pas

Install it as you would any component and that may solve all of your problems. I played with it quite a bit and I think there is a demo somewhere in the Indy stuff as well.

It may help.

0
 
LVL 2

Author Comment

by:Molando
Comment Utility
The http proxy solves half the problem.
using the onbeforecommand? event I can get the url requested. with athread.writeln (or buffer writes) I can send back the responce I want on a bad page. But how do I end the connection.
if I athread.free or athread.terminate after, then my responce does not reach the browser.
if I athread.connection.free then both my responce and the page I am trying to stop reaches the browser.

What I am aiming for is this.

we get the web page request.

if pos('WWW.CHEESE.COM',uppercase(DATA)) > 0 then begin
  athread.connection.writeln('my responce');
  //somehow end the connection so that my responce reaches the browser, but www.cheese.com does not follow it.
  end;
0
 
LVL 2

Author Comment

by:Molando
Comment Utility
points awardeed as no other comments on question. the comment solves half of my problem
0
 
LVL 18

Expert Comment

by:Johnjces
Comment Utility
Sorry that I ahd no further ideas. I do have another component that uses Francois Pettite's ICS components that will do what you need. The comp itself is OK and works and will do alot of neat stuff.

Check this link for the component but remember you need ICS.

http://www.delphipages.com/edit/count.cfm?ID=3489

This may help you a bit more. I plyed with it more extensively. The comp needs a bit of refinement and I never got around to it, but maybe this helps more and may redeem my lack of response!
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now