Implementing a simple transparent proxy with filtering

This is a discussion on Implementing a simple transparent proxy with filtering within the C Programming forums, part of the General Programming Boards category; Hello, My question is mainly about networks. I wan to implement a simple transparent proxy in C, which will filter ...

  1. #1
    Registered User
    Join Date
    Feb 2014
    Posts
    5

    Question Implementing a simple transparent proxy with filtering

    Hello,

    My question is mainly about networks.
    I wan to implement a simple transparent proxy in C, which will filter the browsed sites according to URL blacklist (check before sending the HTTP request) and keywords in content (check the <meta> in the HTML that was responded).
    How can I do this? Listen in a local socket (ex. 8080), set the proxy in my browser and according to the requests that the browser sends to me open a socket with the server, forward the browser's request to the server and forward the server's response to the browser? (Of course by applying filters in the stages where needed)

    I would be glad if you could give me some example code to understand it and have something to start with.

    Thank you!

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,434
    Is there something missing from this?
    https://www.google.co.uk/search?q=simple+c+proxy+server
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    Registered User
    Join Date
    Feb 2014
    Posts
    5
    Quote Originally Posted by Salem View Post
    Is there something missing from this?
    https://www.google.co.uk/search?q=simple+c+proxy+server
    My bad. I didn't mention that I did my homework and googled but I found nothing interesting than the micro_proxy, which is not a very good example. It's undocumented, written in '99 and does not support POST/TRACE etc. and does not answer to my question.
    Also I think I need a transparent proxy, am I right?
    I don't have to parse all the request data and process them, I just want the server address/ip and then forward them. No hassle with GET/POST/etc.

  4. #4
    Registered User
    Join Date
    May 2009
    Posts
    2,506
    So you changed your mind between your second and first post on what you need.
    Please post again when you are finished changing your mind.

    Edit: Your second post implies to me that you need an DNS with a way to whitelist and blacklist sites.

    Tim S.
    Last edited by stahta01; 02-09-2014 at 04:28 PM.
    "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to produce bigger and better idiots. So far, the Universe is winning." Rick Cook

  5. #5
    Registered User
    Join Date
    Feb 2014
    Posts
    5
    I fail to see what changed from the first to the second post...

    Hm, a DNS is a good solution too!
    But will I be able to check the content of the webpages?

  6. #6
    Registered User
    Join Date
    Feb 2014
    Posts
    5
    After giving some thought to DNS, I think it can work.
    I can check the content of the asked URL and then approve it, or block it and cache it to a database, so that the timings are not too bad.

    My problem is how can I block an ip, if I find that the page is bad (the program will run on windows)?
    Also, I will not be able to check IP addresses that I have not blocked.
    So, if someone navigates to a webpage with its IP for the first time, he will pass.

  7. #7
    Registered User
    Join Date
    May 2009
    Posts
    2,506
    I suggest looking at IP filtering and see if any results are good.

    FYI: You do know that a single IP address can be used for hundreds of web-sites.
    If you block by IP you could be blocking more than one web-site per IP address.

    Tim S.
    "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to produce bigger and better idiots. So far, the Universe is winning." Rick Cook

  8. #8
    Registered User
    Join Date
    Feb 2014
    Posts
    5
    I want to create something on my own. I don't really need it, but it would be nice to have it. The main purpose is to test my skills in C.

    Oh, I haven't thought of it. You're right.
    Too many problems... :/

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. simple proxy
    By trooper in forum C Programming
    Replies: 7
    Last Post: 03-24-2011, 11:41 AM
  2. proxy.pac (proxy auto config) question
    By boreder in forum C Programming
    Replies: 2
    Last Post: 01-20-2009, 02:13 AM
  3. Implementing a simple transfer protocol
    By _izua_ in forum Networking/Device Communication
    Replies: 6
    Last Post: 09-04-2007, 04:50 PM
  4. Simple Proxy
    By Lina in forum C Programming
    Replies: 0
    Last Post: 04-01-2007, 12:36 PM
  5. Implementing simple vector graphics capability
    By bigjoke in forum C Programming
    Replies: 2
    Last Post: 05-06-2006, 10:40 PM

Tags for this Thread


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21