Navigation X
ALERT
Click here to register with a few steps and explore all our cool stuff we have to offer!



   2478

[C# .Net Framework] [HELP] Proxy type differentiation?

by 4PEX - 01 August, 2020 - 01:43 PM
This post is by a banned member (Suspect) - Unhide
Suspect  
Registered
75
Posts
2
Threads
5 Years of service
#9
(This post was last modified: 20 August, 2020 - 02:08 AM by Suspect.)
This should be a start. 
Code:
 
JObject jobject = JObject.Parse(new WebClient().DownloadString("http://ip-api.com/json/" + proxy.Split(':')[0]));

//The WebClient class implements IDisposable, which means it should be disposed after it has been used. Currently you aren't disposing //of your WebClient which can cause issues later on.
//You can also make use of string Interpolation which is a lot cleaner in my opinion, more so it useful if you adding or calling more //than 1 function or variable within a string. - it is marked with the '$' symbol before the quotes for your string.
//It's also good practice to make sure a value is assigned to that variable before doing anything with it.

string response;
using (var webClient = new WebClient())
{
    response = webClient.DownloadString($"http://ip-api.com/json/{proxy.Split(':')[0]}");     
} // the webclient will automatically dispose here as its using the 'using' keyword. Any class which implements IDisposable should be used as such, avoid doing anything in the using block which doesn't require the class being used.

if (!string.IsNullOrEmpty(response)) // if the string is not null or empty
{
   dynamic jObject = JObject.Parse(response);
  // string country = (string)jObject["regionName"]; // becomes below.
  // when parsing JSON you can mark the variable you are trying to get as dynamic
             dynamic means that you don't have to set the type statically, it will be resolved at runtime.
    
   var country = jObject.regionName.ToString();
   var validity = jObject.status.ToString();
}

//I wont rewrite your whole code because that is useless. You won't learn anything just by copying me.
//The switch is a good addition much better than If else a bunch of times.

//Another thing I would like to discuss is your empty Catch block, this is completely useless as it's just Pokemon gotta catch em all. 
//Instead you should be handling your exceptions correctly. perhaps even log them to a .txt file, I have a class for this if you want //it just let me know and I'll share it.

 
This post is by a banned member (DevilEggs) - Unhide
DevilEggs  
Registered
11
Posts
5
Threads
4 Years of service
#10
(This post was last modified: 22 August, 2020 - 09:26 AM by DevilEggs.)
HTTP/S-Proxy´s
Standartports 80,8080, 3128

Socks-Proxys 
Standardports 1080, 1081.
 


the fastest way is through the ports, how exactly this science is I'm not sure ... but google for "proxy type port"  ;)

To find out the HTTP / S anonymity proxies level there are several possibilities the easiest / most used is a proxy judge google it just ...
or you use an open API!
(make sure that you can ask infinitely so whether it is really free!)

.... I have put a proxy checker (source code) publicly there you can have a look if you feel like it ... have fun with Proggen: D
This post is by a banned member (DevilEggs) - Unhide
DevilEggs  
Registered
11
Posts
5
Threads
4 Years of service
#11
(This post was last modified: 10 September, 2020 - 12:45 PM by DevilEggs.)
Hello, You can only roughly differentiate between proxies using the Socks or Http / sProxy ports in order to see exactly that you need to test the proxies! Check out (Nuget) for a good API, I'll finally have vacation in 1-2 weeks. I think if nothing comes between I will do a very detailed proxy video tutorial and probably because it is needed for proxy detection a TCP / UDP (Socket) tutorial (chat / advice) is also needed all different Proxy versions! > socks4, (sock4a), Socks5, (Socks5h) and http, https, http1.0. What is in brackets is also contained in brackets. Because it's just a small change to the bytes, the handshake, etc. (for them that you need. To know exactly that you need Wikipedia, read what you need to do there and then build it up according to Tcpclient bytes If you go right (you got it right) give values ​​to your program (right! Just like advice!) Sorry I'm looking for someone who can translate better for me and once I get vacation I'll be myself sitting down with the videos I'll write it in detail, I'm also thinking about if I could do a real scrapper, but I have to see that I only have two weeks vacation and after that, one way or another, I'm back at the keyboard will, Go Away ✌️

and gradually with proxy type http ... you check the http version, and whether it is http / s (httpstatus, requeststatus) is heard with it! There are additional customers in the system.net or system.socket ... and then you can make the anonymity prefixes by reading them from a proxy judge
This post is by a banned member (Suspect) - Unhide
Suspect  
Registered
75
Posts
2
Threads
5 Years of service
#12
Wouldn't bother helping this guy personally, He won't thank you or anything just one of those people with no manners. His code is complete trash and when you help him with it he's in denial and doesn't thank you for your time spent. Manners are free they don't cost a thing.

 
This post is by a banned member (4PEX) - Unhide

Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
or
Sign in
Already have an account? Sign in here.


Forum Jump:


Users browsing this thread: 1 Guest(s)