473,651 Members | 2,790 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Forcing a socket connection via a proxy

I'm trying to create a proxy server - one that will modify requests
made through it.

I've started with Tiny HTTP Proxy by SUZUKI Hisao which is built on
BaseHTTPServer - and I'm starting to get somewhere.

It listens on local ports and tells you whats goign through it.
I'm in a slightly unusual situation though - all internet traffic goes
through a proxy - I have to set the proxy settings to dav-serv:8080 to
work.

What I *want* to do is to point my browser at 127.0.0.1:8000 and have
Tiny Proxy pointed at dav-serv and also modifying requests made
through it. However - when I change my browser proxy settings to
127.0.0.1, the python code no longer knows that it needs to go via
dav-serv:8080

What I need to do is to force it to use our proxy. Now I know various
protocols allow you to explicitly state the proxy settings... but I'm
struggling to find it.

As far as I can tell Tiny Proxy creates a ProxyHandler with methods
that actually implement the fetches.

For example there are two methods in the ProxyHandler class (which is
a subclass of BaseHTTPServer. BaseHTTPRequest Handler) :
def do_CONNECT(self ):
soc = socket.socket(s ocket.AF_INET, socket.SOCK_STR EAM)
try:
if self._connect_t o(self.path, soc):
self.log_reques t(200)
self.wfile.writ e(self.protocol _version +
" 200 Connection established\r\n ")
self.wfile.writ e("Proxy-agent: %s\r\n" %
self.version_st ring())
self.wfile.writ e("\r\n")
self._read_writ e(soc, 300)
finally:
print "\t" "bye"
soc.close()
self.connection .close()

def do_GET(self):
(scm, netloc, path, params, query, fragment) =
urlparse.urlpar se(
self.path, 'http')
if scm != 'http' or fragment or not netloc:
self.send_error (400, "bad url %s" % self.path)
return
soc = socket.socket(s ocket.AF_INET, socket.SOCK_STR EAM)

Which look like they implement GET and CONNECT requests (good at this
aren't I !! - actually I'm way out of my depth). They both get the URL
from self.path and use socket.socket to make connection. I need to get
this connection to be made via a proxy server. (I also want to modify
that URL - but I can handle that myself !!).

Anyone got any pointers for me ?

Regards,

Fuzzyman

http://www.voidspace.org.uk/atlantib...thonutils.html
Jul 18 '05 #1
0 2398

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
5549
by: b_prikls | last post by:
Hi all, i need your help, here is code, that makes http connection to a website throu a proxy server, and it works fine: ========================================== $proxy = "111.111.111.111"; $port = "8080"; $url = "http://www.myhost.com/folder/script.dll?variable=hello";
4
17690
by: Fuzzyman | last post by:
In a nutshell - the question I'm asking is, how do I make a socket conenction go via a proxy server ? All our internet traffic has to go through a proxy-server at location 'dav-serv:8080' and I need to make a socket connection through it. The reason (with code example) is as follows : I am hacking "Tiny HTTP Proxy" by SUZUKI Hisao to make an http proxy that modifies URLs. I haven't got very far - having started from zero knowledge of...
7
5132
by: Adam Clauss | last post by:
I am trying to work-around a firewall which limits me to only being able to accept inbound connections on port 80. Unfortunately, I need to two different applications to be able to accept connections. I know of no "standard" way to make this work (and, its quite possible that I am on the totally wrong track here and there just isn't a way to do this). I am trying to determine if it would be possible to write a 'gateway' program that...
0
1777
by: Marc Bogaard | last post by:
Hello all! I am trying to develop some kind of proxy which filters the data the browser sents to a webserver (www.google.de, www.gmx.net, ...). For this reason I set a Proxy Connection in my IE 6.0 Settings at port 8000 (e.g) and the server to localhost (the proxy that runs local). Now I use the TCPListener which listens and recieves data after I typed in and pressed the send button from the browser. After this I take the data and send...
8
41377
by: Claire | last post by:
I'm trying to debug my network application ie I want to check my error handling when the connection is broken. Im using 127.0.0.1 as the connection address. Unfortunately, the client socket goes into a CLOSE_WAIT state ad infinitum and never closes fully until my client and server applications shut down. Ive disabled lingeroptions. Is there anything else easy that i can do to force the loopback to close immediately?
7
2926
by: | last post by:
Hi all, I have a simple .aspx page running on net 2.0 that is trying to do a http post to a remote server. Here is the code Private Function ProcessRequests(ByVal strbody As String) As String Dim returnstr As String Dim URL As String = "http://www.dydomain.com/test.asp"
13
2640
by: coloradowebdev | last post by:
i am working on basically a proxy server that handles requests via remoting from clients and executes transactions against a third-party server via TCP. the remoting site works like a champ. my problem is executing the transactions against the remote server and returning the response to the remoting client. i can open the socket fine and, if i am executing one transaction at a time, everything works great. it's when my proxy server...
2
2440
by: vasu1308 | last post by:
Hi all I am working on a socket program in Perl. Main goal is to develop a proxy server. Here is the code attached. An error is encountered. Anyone Please help me out. #!/usr/bin/perl -w # server1.pl - a simple server use strict; use Socket;
11
1735
by: Jon Mcleod | last post by:
I'm trying to wrap my ming around C#/CLR garbage collection. In an ASP.NET project, I'm having a problem because an object destructor is being called by another thread, long after my code is done. I'm wanting to know if I can force it to happen immediately (when the object goes out of scope) without going back and adding all of the required Dispose() calls.. public Method() { CustomClass o = new CustomClass(..);
0
8357
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8277
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8581
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7298
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6158
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5612
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
2701
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1910
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1588
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.