Sep 15, 2017 02:32 AM
(This post was last modified: Sep 15, 2017 03:04 AM by Rhinemann.)
So this problem has been bugging me for awhile & I can't seem to solve it on my own after many attempts so I'm resorting to the mean but helpful HF community. If anyone would be so kind 🤝
So basically my project takes two .txt files (combo lists + proxy lists) & each must be split accordingly (user-name & passwords + ip & port) & I decided to do this via a parallel for-each loop to keep it as a continuous process going through the list. This actually worked great until it came time to add proxies which is where my problem began. I'm attempting to split the lists & send them to my login system which uses HTTPWebRequests, I do not need help with the actual process, only the proxy list.
Please understand that I've attempted this myself & failed horribly, I'm not just leeching for help. I keep running into problems when I try add proxies to the mix, I cannot seem to split and send them to the requests as I simply do not know how I would go about it when I'm already splitting the combo list upon starting, the loop sends accounts one by one & I don't know how to add proxies to this in order to pass them over.
Code private void Start()
{
Task.Run(() =>
{
ParallelOptions options = new ParallelOptions
{
MaxDegreeOfParallelism = (int)(nudThreads.Value)
};
Parallel.ForEach(_accounts, options, (account) =>
{
string[] split = account.Split(new char[] { ':' }, 2);
var username = split[0];
var password = split[1];
PostLogin(username, password);
});
});
}
The proxy list is called "_proxies", if anyone could assist me in adding proxies to the above code or giving me a way to implement & pass both to the request that would be great.
Thanks in advance, I really appreciate it. 🤝
Little confused to where you're stuck.
You have a _proxies variable with a list of proxies.
Create a method to grab a random proxy from that list or go in order depending on what you want to do. Make sure to lock things when needed.
Send that proxy to the PostLogin method with the other arguments.
Sep 15, 2017 03:07 AM
(This post was last modified: Sep 15, 2017 03:10 AM by Rhinemann.)
(Sep 15, 2017 02:53 AM)SL x TnT Wrote: Little confused to where you're stuck.
You have a _proxies variable with a list of proxies.
Create a method to grab a random proxy from that list or go in order depending on what you want to do. Make sure to lock things when needed.
Send that proxy to the PostLogin method with the other arguments.
I guess I didn't quite get my point across because you basically just wrote what my code says in terms of combo list. I cannot seem to split the proxies list at the same time as username to send them all at once to requests. Either I just enter a contious loop of splitting or something errors out.
As I said I'm in no way a good C# programmer, what seems basic to you could not be to me. As for what you said I know, I just don't know how to make both work at once. Also what do you mean by lock things?
(Sep 15, 2017 03:07 AM)Rhinemann Wrote: I guess I didn't quite get my point across because you basically just wrote what my code says in terms of combo list. I cannot seem to split the proxies list at the same time as username to send them all at once to requests. Either I just enter a contious loop of splitting or something errors out.
As I said I'm in no way a good C# programmer, what seems basic to you could not be to me. As for what you said I know, I just don't know how to make both work at once. Also what do you mean by lock things?
Quote:Create a method to grab a random proxy from that list or go in order depending on what you want to do. Make sure to lock things when needed.
PHP Code
<?php private Random _rand = new Random(); //Class level private object _lock = new object();
//Will require at least 1 proxy in the _proxies list private string GetRandomProxy() { //Both the _rand and _proxies variables aren't thread safe, so it needs the lock. Could get away without locking the _proxies, if you don't plan on adding/removing from the list while it's running. lock(_lock) { return _proxies[_rand.Next(_proxies.Count)]; } }
I'm guessing it's a list of strings in IP:PORT format.
It'll be better to send only 1 proxy to the PostLogin method at a time. You could even have it retry multiple times with different proxies, but that fully depends on your program. If you want to send them all, send the list over.
Sep 15, 2017 03:52 AM
(This post was last modified: Sep 15, 2017 04:02 AM by Rhinemann.)
(Sep 15, 2017 03:45 AM)SL x TnT Wrote: PHP Code
<?php private Random _rand = new Random(); //Class level private object _lock = new object();
//Will require at least 1 proxy in the _proxies list private string GetRandomProxy() { //Both the _rand and _proxies variables aren't thread safe, so it needs the lock. Could get away without locking the _proxies, if you don't plan on adding/removing from the list while it's running. lock(_lock) { return _proxies[_rand.Next(_proxies.Count)]; } }
That code helps me understand what you were saying but I'm still left with my initial problem, is it me not getting my point across correctly?
I know how to load the proxy list, split it & send it to the request I just can't figure out how I do it all at once along with combo lists, my foreach loop is used for combo lists, i tried nesting a second loop but after about 5 minutes I figured out that was a mistake.
I take it the proxy lock is used in the request, which is after ive solved my problem here. It would be helpful for a quick comment on 1-2 things but I'm sure I can figure the lock out myself. I understand its purpose.
(Sep 15, 2017 03:52 AM)Rhinemann Wrote: That code helps me understand what you were saying but I'm still left with my initial problem, is it me not getting my point across correctly?
Most likely.
"I'm attempting to split the lists & send them to my login system which uses HTTPWebRequests, I do not need help with the actual process, only the proxy list"
Not sure what you mean by "split the lists." You said you don't need help with the actual process, so I tried helping send a single proxy over to the method.
"The proxy list is called "_proxies""
Inferring you already have read the proxy file and it's in a list called _proxies with a format of IP:PORT.
From there, all you need to do is get a proxy from the list and send it over to the method. In the method, request.Proxy = new WebProxy(proxy). Shouldn't need to split it.
Sep 15, 2017 04:09 AM
(This post was last modified: Sep 15, 2017 04:13 AM by Rhinemann.)
(Sep 15, 2017 04:03 AM)SL x TnT Wrote: Not sure what you mean by "split the lists." You said you don't need help with the actual process, so I tried helping send a single proxy over to the method.
I was under the impression webproxy required both ip & port to be defined, just ip:port did not work.
(Sep 15, 2017 04:03 AM)SL x TnT Wrote: From there, all you need to do is get a proxy from the list and send it over to the method. In the method, request.Proxy = new WebProxy(proxy). Shouldn't need to split it.
I know, this isn't the problem.
I'm gong to close this now as I'm 100% sure it's me not getting my point across correctly. Partly due to a lack of knowledge. Most of the things you said (besides the lock) I already know and have implemented. If you look at the screen shot I'm sending the combo list as a parallel loop to the request & I simply wanted to add proxies to this equation to send them with the account to use in request. I could not accomplish this, simply saying "get a proxy from the list & send it over" was exactly my problem.
Thank you for the help, I'm going to give up now. Been trying to add proxies for quite some time in C# and no dice.
Sep 15, 2017 04:12 AM
(This post was last modified: Sep 15, 2017 04:12 AM by SL x TnT.)
(Sep 15, 2017 04:09 AM)Rhinemann Wrote: I was under the impression webproxy required both ip & port to be defined, just ip:port did not work.
I'm gong to close this now as I'm 100% sure it's me not getting my point across correctly. Partly due to a lack of knowledge. Most of the things you said (besides the lock) I already know and have implemented. If you look at the screenshot I'm sending the combo list as a parallel loop to the request & I simply wanted to add proxies to this equation to send them with the account to use in request. I could not accomplish this, simply saying "get a proxy from the list & send it over" was exactly my problem.
Thank you for the help, I'm going to leave it for now.
If you need to split them ...
string[] parts = proxy.Split(':');
string ip = parts[0];
int port = Int32.Parse(parts[1]); //I'm ignoring exceptions here. Should be a TryParse (and Int16 instead), unless you're 100% sure it'll always be correct.
Quote: I could not accomplish this, simply saying "get a proxy from the list & send it over" was exactly my problem.
I gave you a method that will pull a random proxy from your _proxies list.
Sep 15, 2017 04:14 AM
(This post was last modified: Sep 15, 2017 04:15 AM by Rhinemann.)
(Sep 15, 2017 04:12 AM)SL x TnT Wrote: If you need to split them ...
string[] parts = proxy.Split(':');
string ip = parts[0];
int port = Int32.Parse(parts[1]); //I'm ignoring exceptions here. Should be a TryParse (and Int16 instead), unless you're 100% sure it'll always be correct.
(Sep 15, 2017 04:12 AM)SL x TnT Wrote: I gave you a method that will pull a random proxy from your _proxies list. I know how to pull a random proxy from a list.
Again, not my problem. Look at the screenshot I'm already splitting the combo lists, I know how to do this.
Closing, clearly having mis-communication here on every post.
|