PDA

View Full Version : Need help incorperating SOCKS5 Proxies into C++ program


x2Dread2x
Jan6-11, 09:15 PM
Hi there. I've been trying to incorporate Proxies into a program I am currently making.

It's basically a c++ Chat bot that will load proxies from a list and connect from them into a chat, but I'm having a bit of trouble.


I've found a SOCKS 5 Wrapper, but I'm having trouble with that as well.


Any help would be appreciated greatly.

chiro
Jan6-11, 10:58 PM
Hi there. I've been trying to incorporate Proxies into a program I am currently making.

It's basically a c++ Chat bot that will load proxies from a list and connect from them into a chat, but I'm having a bit of trouble.


I've found a SOCKS 5 Wrapper, but I'm having trouble with that as well.


Any help would be appreciated greatly.

Just a bit of advice: I would setup your network code to be as event-driven as possible. Since you're assuming the socket has a minimum version of 2.0 you should be able to setup a non-blocking socket function quite easily.

If you want cross platform, one method might be to have a thread class that is system specific, but use the select method (which i'm sure is universal for standardized socket libraries on linux, unix, and mac).

Even if you only have 2 people chatting, it is worth making the effort to do the above.

Have some OS class that does all of your OS specific initialization which will include you starting and shutting down OS specific stuff (WSAStartup and include the function to release the library handle!)

Then build your network classes with client and server classes. Track all of your system variables and make sure your Network Manager class shuts everything down properly.

It might seem like I'm having a dig but I'm not: I think you have to get into the routine of seeing where to encapsulate functionality and especially where centralized flow control can and should be used: as a rule of thumb any system resource should be tracked by specific manager classes as well as OS classes. When you do something to an object, post an event message that any class can subscribe to. If something is destroyed one class can get messages and update things like pointer lists and so on.

Like I said, it might not be what you want to hear, but if you do this most of your problems will be solved when you think about the design and do so in a way that is optimal for what you want to do.

x2Dread2x
Jan7-11, 12:47 AM
Just a bit of advice: I would setup your network code to be as event-driven as possible. Since you're assuming the socket has a minimum version of 2.0 you should be able to setup a non-blocking socket function quite easily.

If you want cross platform, one method might be to have a thread class that is system specific, but use the select method (which i'm sure is universal for standardized socket libraries on linux, unix, and mac).

Even if you only have 2 people chatting, it is worth making the effort to do the above.

Have some OS class that does all of your OS specific initialization which will include you starting and shutting down OS specific stuff (WSAStartup and include the function to release the library handle!)

Then build your network classes with client and server classes. Track all of your system variables and make sure your Network Manager class shuts everything down properly.

It might seem like I'm having a dig but I'm not: I think you have to get into the routine of seeing where to encapsulate functionality and especially where centralized flow control can and should be used: as a rule of thumb any system resource should be tracked by specific manager classes as well as OS classes. When you do something to an object, post an event message that any class can subscribe to. If something is destroyed one class can get messages and update things like pointer lists and so on.

Like I said, it might not be what you want to hear, but if you do this most of your problems will be solved when you think about the design and do so in a way that is optimal for what you want to do.


Yes, I get where you are going with this.. I've been working on a separate project, and it seems that all of it works much better and outputs with a better network code and event driven environment.

Would it be possible to use inFile to actually use a list text file with the proxies?.. I just can't wrap my head around it.

I suppose I can't say I've had too much experience with this.

chiro
Jan7-11, 01:43 AM
There is no reason why you couldn't do that. I would probably make sure the structure is correct before you accept it though. Basically every line you get tokenize the data using . as the separator and check that the values are numbers only (ie ascii value lies in range) and then use something like atoi to check the values.

Some advice for you is to kind of "super-analyze" everything. Think of the bounds of your variables, the structural definition in your class or struct defs, and make modular code that is as thorough as you can get: decompose everything into its tiniest data structure, check it, and build up your checking and testing from the lowest structure up.

Even if you have to get a blank paper out and draw it like a tree diagram to help you visualize it.

But yeah sorry to answer your question, no reason why you can't do that, just make sure you handle all the anomalies.