Hannes Gouws
2008-06-19 21:05:46 UTC
Hi - I advance - sorry for the loooonnnngggg message, but the more info I
give you, the better you will understand what my app is supposed to do.!
I have create a captive portal application using the winpkfilter library and
Indy 10 with D7 Enterprise.
The pc this software will be running on will be configured as an internet
gateway with 2 network adapters. 1 for internet and 1 for internal network
(LAN)
My application executes 2 threads
Thread1 listens on a specific network adapter (LAN) via winpkfilter's NDIS
intermediate driver. From Thread1, I can monitor all inbound and outbound
network packets. I am specifically interested in outbound HTTP packets
(destined to port 80), which I then redirect to 192.168.0.1:80 by directly
modifying the raw TCP and IP packets.
Thread2 checks for incomming http request on my local pc (192.168.0.1:80)
and blocks all outbound internet traffic by first server a web page for
authentication (basic logon page). When the user logs on, I get a POST
command back with the username and password params, which I then parse and
validate. If not valid username and password, same login page gets served
again with message that login is not valid.
Now when the user logs in and authentication is sucessful, my TidHttpServer
must serve as a internet gateway.
My problem is with the gateway side of it, I've tried a couple of thing but
as soon as the user logs in sucessfully and I then redirect him to the
original reguested page, it does load, but the images are lost...
here is some code I used for the http redirection in Thread2:
First I validate if the logon details and if sucess I call this function
from my main IdHTTPServer1CommandGet event.
This procedure serve only the actaul HTML text....
procedure TdmHttpServer.RedirUserToWWW(AContext: TIdContext; ARequestInfo:
TIdHTTPRequestInfo; AResponseInfo: TIdHTTPResponseInfo);
var
lsResponse: String;
begin
lsResponse := idHttpClient.Get(ARequestInfo.Referer);
AResponseInfo.ContentText := lsResponse;
AResponseInfo.WriteContent;
end;
Now I get a request back again into my main IdHTTPServer1CommandGet event
for the rest of the content like images etc...
The following code serves the rest of the html document like images etc..
var
lsHost: String;
lStream: TMemoryStream;
lsFileName: String;
begin
lsHost := 'http://'+ARequestInfo.Host;
lsFileName := lsHost+ARequestInfo.Document;
lStream := TMemoryStream.Create;
try
idHttpClient.Get(lsFileName, lStream);
AResponseInfo.ContentStream := lStream;
AResponseInfo.WriteContent;
finally
AResponseInfo.ContentStream.Free;
AResponseInfo.ContentStream := nil;
end;
end;
Any help/input/comment/criticism here would be appreciated
give you, the better you will understand what my app is supposed to do.!
I have create a captive portal application using the winpkfilter library and
Indy 10 with D7 Enterprise.
The pc this software will be running on will be configured as an internet
gateway with 2 network adapters. 1 for internet and 1 for internal network
(LAN)
My application executes 2 threads
Thread1 listens on a specific network adapter (LAN) via winpkfilter's NDIS
intermediate driver. From Thread1, I can monitor all inbound and outbound
network packets. I am specifically interested in outbound HTTP packets
(destined to port 80), which I then redirect to 192.168.0.1:80 by directly
modifying the raw TCP and IP packets.
Thread2 checks for incomming http request on my local pc (192.168.0.1:80)
and blocks all outbound internet traffic by first server a web page for
authentication (basic logon page). When the user logs on, I get a POST
command back with the username and password params, which I then parse and
validate. If not valid username and password, same login page gets served
again with message that login is not valid.
Now when the user logs in and authentication is sucessful, my TidHttpServer
must serve as a internet gateway.
My problem is with the gateway side of it, I've tried a couple of thing but
as soon as the user logs in sucessfully and I then redirect him to the
original reguested page, it does load, but the images are lost...
here is some code I used for the http redirection in Thread2:
First I validate if the logon details and if sucess I call this function
from my main IdHTTPServer1CommandGet event.
This procedure serve only the actaul HTML text....
procedure TdmHttpServer.RedirUserToWWW(AContext: TIdContext; ARequestInfo:
TIdHTTPRequestInfo; AResponseInfo: TIdHTTPResponseInfo);
var
lsResponse: String;
begin
lsResponse := idHttpClient.Get(ARequestInfo.Referer);
AResponseInfo.ContentText := lsResponse;
AResponseInfo.WriteContent;
end;
Now I get a request back again into my main IdHTTPServer1CommandGet event
for the rest of the content like images etc...
The following code serves the rest of the html document like images etc..
var
lsHost: String;
lStream: TMemoryStream;
lsFileName: String;
begin
lsHost := 'http://'+ARequestInfo.Host;
lsFileName := lsHost+ARequestInfo.Document;
lStream := TMemoryStream.Create;
try
idHttpClient.Get(lsFileName, lStream);
AResponseInfo.ContentStream := lStream;
AResponseInfo.WriteContent;
finally
AResponseInfo.ContentStream.Free;
AResponseInfo.ContentStream := nil;
end;
end;
Any help/input/comment/criticism here would be appreciated