Skip to content

Commit 7f307e4

Browse files
committed
author block-code and description added to each class
1 parent 32619ac commit 7f307e4

File tree

15 files changed

+74
-11
lines changed

15 files changed

+74
-11
lines changed

src/main/kotlin/plugin/httpclient/checkerproxy/CheckerProxy.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ class CheckerProxy : Plugin, ProxyWebsite {
5454
logger.error { ex.message }
5555
}
5656

57-
return false
57+
return true
5858
}
5959

6060
override fun thenConnect() {

src/main/kotlin/plugin/httpclient/freeproxyapi/FreeProxyApi.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ class FreeProxyApi : Plugin, ProxyWebsite {
5858
logger.error { ex.message }
5959
}
6060

61-
return false
61+
return true
6262
}
6363

6464
override fun thenConnect() {

src/main/kotlin/plugin/httpclient/geonode/GeoNode.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ class GeoNode : Plugin, ProxyWebsite {
9191
logger.error { ex.message }
9292
}
9393

94-
return false
94+
return true
9595
}
9696

9797
override fun thenConnect() {

src/main/kotlin/plugin/httpclient/openproxylist/OpenProxyList.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ class OpenProxyList : Plugin, ProxyWebsite {
5757
logger.error { ex.message }
5858
}
5959

60-
return false
60+
return true
6161
}
6262

6363
override fun thenConnect() {

src/main/kotlin/plugin/httpclient/proxyscrape/ProxyScrape.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ class ProxyScrape : Plugin, ProxyWebsite {
5959
logger.error { ex.message }
6060
}
6161

62-
return false
62+
return true
6363
}
6464

6565
override fun thenConnect() {

src/main/kotlin/scraper/Main.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@ import java.nio.file.Path
1010
import kotlin.io.path.exists
1111
import kotlin.system.exitProcess
1212

13+
/**
14+
* Main - 12/02/2023
15+
* @author Kai
16+
*
17+
* Description: Main class, runs the application
18+
**/
1319
class Main {
1420

1521
private val logger = KotlinLogging.logger { }

src/main/kotlin/scraper/net/ChromeWebDriver.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@ import org.openqa.selenium.devtools.Command
1212
import org.openqa.selenium.devtools.DevTools
1313
import org.openqa.selenium.devtools.v109.network.Network
1414

15+
/**
16+
* ChromeWebDriver - 12/02/2023
17+
* @author Kai
18+
*
19+
* Description: Used for more complex proxy sites, ones that require JavaScript & obfuscate their data
20+
**/
1521
class ChromeWebDriver {
1622

1723
private val options = ChromeOptions()

src/main/kotlin/scraper/net/CoroutinesHttpClient.kt

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,21 @@ import java.net.http.HttpResponse
99
import java.net.http.HttpTimeoutException
1010
import java.time.Duration
1111

12-
12+
/**
13+
* CoroutinesHttpClient - 12/02/2023
14+
* @author Kai
15+
*
16+
* Description: Used for simple web calls, such as sending GET/POST data for text content (JSON etc)
17+
**/
1318
class CoroutinesHttpClient {
1419

1520
companion object {
1621

22+
val timeout : Duration = Duration.ofSeconds(15)
23+
1724
private val httpClient : HttpClient = HttpClient.newBuilder()
18-
.version(HttpClient.Version.HTTP_1_1)
19-
.connectTimeout(Duration.ofSeconds(30))
25+
.version(HttpClient.Version.HTTP_2)
26+
.connectTimeout(timeout)
2027
.build()
2128

2229
}
@@ -31,7 +38,7 @@ class CoroutinesHttpClient {
3138
val request : HttpRequest = if(postData == null) {
3239
HttpRequest.newBuilder()
3340
.uri(URI.create(url))
34-
.timeout(Duration.ofSeconds(30))
41+
.timeout(timeout)
3542
.headers(*userAgent)
3643
.headers(*accept)
3744
.headers(*acceptLanguage)
@@ -42,7 +49,7 @@ class CoroutinesHttpClient {
4249
} else {
4350
HttpRequest.newBuilder()
4451
.uri(URI.create(url))
45-
.timeout(Duration.ofSeconds(30))
52+
.timeout(timeout)
4653
.headers(*userAgent)
4754
.headers(*accept)
4855
.headers(*acceptLanguage)

src/main/kotlin/scraper/plugin/Plugin.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
package scraper.plugin
22

3+
/**
4+
* Plugin - 12/02/2023
5+
* @author Kai
6+
*
7+
* Description: Interface for Plugin, this will append the class to a List within PluginFactory
8+
**/
39
interface Plugin {
410

511
fun register()

src/main/kotlin/scraper/plugin/PluginFactory.kt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@ import org.reflections.Reflections
55
import scraper.plugin.hook.ProxyWebsite
66
import java.lang.reflect.Modifier
77

8+
/**
9+
* PluginFactory - 12/02/2023
10+
* @author Kai
11+
*
12+
* Description: This is used for loading the Proxy Website Plugins from /src/main/kotlin/plugins/
13+
* Makes it easier for APIs to be added / removed
14+
**/
815
object PluginFactory {
916

1017
private val logger = KotlinLogging.logger { }

src/main/kotlin/scraper/plugin/hook/ProxyWebsite.kt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@ package scraper.plugin.hook
22

33
import scraper.util.data.ProxyData
44

5+
/**
6+
* ProxyWebsite - 12/02/2023
7+
* @author Kai
8+
*
9+
* Description: Interface for the Website Plugins within /src/main/kotlin/plugin/
10+
* Plugins will follow this interface format
11+
**/
512
interface ProxyWebsite {
613

714
val proxies : MutableList<ProxyData>

src/main/kotlin/scraper/util/NetworkUtils.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@ package scraper.util
22

33
import java.util.regex.Pattern
44

5+
/**
6+
* NetworkUtils - 17/02/2023
7+
* @author Kai
8+
*
9+
* Description: Any reusable network functions are in this class
10+
**/
511
object NetworkUtils {
612

713
fun isValidIpAddress(ipAddress : String) : Boolean {

src/main/kotlin/scraper/util/ScraperExecutor.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@ package scraper.util
33
import java.util.concurrent.ExecutorService
44
import java.util.concurrent.Executors
55

6+
/**
7+
* ScraperExecutor - 17/02/2023
8+
* @author Kai
9+
*
10+
* Description: This is used for multi-threading to speed up the application
11+
**/
612
object ScraperExecutor {
713

814
private val PROCESSORS = Runtime.getRuntime().availableProcessors() + 1

src/main/kotlin/scraper/util/ScraperThreadFactory.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@ package scraper.util
33
import java.util.concurrent.ThreadFactory
44
import java.util.concurrent.atomic.AtomicInteger
55

6+
/**
7+
* ScraperThreadFactory - 12/02/2023
8+
* @author Kai
9+
*
10+
* Description: This is used for multi-threading to speed up the application
11+
**/
612
class ScraperThreadFactory(private val name : String) : ThreadFactory {
713
private val threadCount = AtomicInteger()
814
override fun newThread(r : Runnable): Thread {

src/main/kotlin/scraper/util/scripts/GetAllCheckerProxies.kt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@ import java.time.format.DateTimeFormatter
1818
import kotlin.io.path.exists
1919
import kotlin.system.exitProcess
2020

21+
/**
22+
* GetAllCheckerProxies - 17/02/2023
23+
* @author Kai
24+
*
25+
* Description: Quick and easy script for getting all the proxies from CheckerProxy's API
26+
**/
2127
private const val endpoint = "https://checkerproxy.net/api/archive/"
2228

2329
private val proxies : MutableList<ProxyData> = mutableListOf()
@@ -26,7 +32,7 @@ fun main() {
2632
loopThroughDates()
2733
}
2834

29-
fun loopThroughDates() {
35+
private fun loopThroughDates() {
3036
val format = DateTimeFormatter.ofPattern("yyyy-MM-dd")
3137
val fromDate = LocalDate.parse("2023-01-18", format)
3238
val toDate = LocalDate.parse("2023-02-17", format)

0 commit comments

Comments
 (0)