Proxy Server
Author |
Message |
frank26080115
|
Posted: Thu Nov 01, 2007 8:10 pm Post subject: Proxy Server |
|
|
I've written a half functional proxy server, it has many bugs to work out, but it will take data sent from the browser, process the request slightly to extract the domain and URL of the target location, request the target from the domain, redirect all other data from the browser to the server, and then redirect all the data from the server to the browser.
so far, i can go to yahoo (it won't recognize the browser), but it proves that html works
there is still malformed stuff going between the computers
images can't be loaded by the proxy because of the stupid "illegal character in string" errors
code: | var netAddressB, netURL, netURL2, netDomain, data : string
var netStreamB, netStreamS, domainLength : int
var containSlash : boolean
loop
put "Your IP is: ", Net.LocalAddress
put "to use this proxy, go to:"
put "http://", Net.LocalAddress, "/destination"
put "Waiting for Browser Connection"
put ""
netStreamB := Net.WaitForConnection (80, netAddressB) % wait for connection from browser
if netStreamB > 0 then % netSteam is only > 0 when connected
put "Connected to browser at: ", netAddressB
loop
exit when Net.TokenAvailable (netStreamB) % this loop waits for data
end loop
get : netStreamB, data : 5 % takes away "get /"
get : netStreamB, netURL % takes in the URL
netDomain := "" % clears register
domainLength := 1 % resets register
containSlash := false
if index (netURL, "/") > 0 then
containSlash := true
loop % this extracts domain of server
if netURL (domainLength) not= "/" then
netDomain := netDomain + netURL (domainLength)
domainLength += 1
else
exit
end if
end loop
else
netDomain := netURL
end if
netURL2 := ""
for i : domainLength .. length (netURL)
netURL2 := netURL2 + netURL (i) % take out domain name from request
end for
loop % this is an inefficient patch to add the slash if one is missing at the beginning
if containSlash then
for i : domainLength .. length (netURL)
if netURL (i) not= "/" and i = domainLength then
netURL2 := netURL2 + netURL (i)
end if
end for
else
netURL2 := "/"
end if
if length (netURL2) > 0 then
if netURL2 (1) not= "/" then
netURL2 := "/"
else
exit
end if
else
netURL2 := "/"
end if
end loop
netURL := netURL2
put "Domain: ", netDomain
put "URL: http://", netDomain, netURL
netDomain := Net.HostAddressFromName (netDomain)
netStreamS := Net.OpenConnection (netDomain, 80) % connect to server
if netStreamS > 0 then % only if connected
put : netStreamS, "GET " + netURL + " " % send request to server
loop % relay the rest of the data from the browser to the server
get : netStreamB, data : 1
put : netStreamS, data ..
%put data ..
exit when ~Net.TokenAvailable (netStreamB) % when browser finishes sending, this loop exits
end loop
loop
exit when Net.TokenAvailable (netStreamS) % wait for response from server
end loop
loop % relay data from server to browser
get : netStreamS, data
put : netStreamB, " " ..
put : netStreamB, data ..
%put data ..
exit when ~Net.TokenAvailable (netStreamS) % wait for server to finish
end loop
close : netStreamS % close connection
put "Server Connection Closed"
else
put "Server Connection Failed"
delay (1000)
end if
close : netStreamB % close connection
put "Browser Connection Closed"
else
put "Browser Connection Failed"
delay (1000)
end if
put "Finished Request"
put ""
end loop
|
I still help with forming proper requests to the server, most still won't send actual web pages to me
and I need to process URLs contained inside the html so that all links and such will still stay inside the proxy
I also need to avoid the "illegal character in string" error when loading images
any help appreciated |
|
|
|
|
|
Sponsor Sponsor
|
|
|
darkangel
|
Posted: Fri Nov 02, 2007 2:42 pm Post subject: Re: Proxy Server |
|
|
ok thats frickn' cool
how do you visit sites? all i can do is type in 127.0.0.1 into the url and get my browser settings, thats it. |
|
|
|
|
|
frank26080115
|
Posted: Fri Nov 02, 2007 7:11 pm Post subject: RE:Proxy Server |
|
|
for example
http://127.0.0.1/yahoo.com
or if you run your proxy on one computer and use another computer
http://ip/yahoo,com
yahoo because it looks better than google's error page
i can't use read or write because it returns an incompatibility error |
|
|
|
|
|
darkangel
|
Posted: Wed Nov 07, 2007 8:05 pm Post subject: Re: Proxy Server |
|
|
thanks |
|
|
|
|
|
Nick
|
Posted: Wed Nov 07, 2007 8:11 pm Post subject: RE:Proxy Server |
|
|
i dont think this will work for me because i am on a network
its giving me my network address instead of my IP :S think u could find a way around that? |
|
|
|
|
|
frank26080115
|
|
|
|
|
SNIPERDUDE
|
Posted: Mon Nov 12, 2007 8:45 pm Post subject: Re: Proxy Server |
|
|
I don't really want to take this off-topic, but how did you make it follow the objects in it's path, and make the wheels turn in the appropriate direction? |
|
|
|
|
|
frank26080115
|
|
|
|
|
Sponsor Sponsor
|
|
|
SNIPERDUDE
|
Posted: Thu Nov 15, 2007 12:54 pm Post subject: Re: Proxy Server |
|
|
Thanks man, I made a non-lethal semi-auto (shoots about the same speed as a homemade bow, so it will hurt like a b****) a while back - and I had plans to make it automated and put in front of my room.
: )
I have the equipment too, I just need the blueprints or algorithm of the seeking part. |
|
|
|
|
|
Dannyd534
|
Posted: Wed Nov 28, 2007 10:53 am Post subject: RE:Proxy Server |
|
|
this would be sick if it worked at my school....to bad the dam board blocks everything |
|
|
|
|
|
|
|