@@ -20,20 +20,20 @@ var hashMaps = mutableListOf(protocolVersionHashMap, maxPlayerHashMap, protocolH
2020
2121fun main (args : Array <String >) {
2222 try {
23- println (" Trying mode ${args[1 ]} with file ${args[0 ]} " )
24- copenJSParser(args[0 ], args[1 ].toInt())
23+ println (" Starting mode ${args[1 ]} with file ${args[0 ]} " )
24+ copenJSParser(args[0 ], args[1 ].toInt(), args[ 2 ] )
2525 } catch (e: Exception ) {
2626 println (" No input file/mode specified using sample file and starting scanner mode: copenJS" )
2727 copenJSParser(Paths .get(" " ).toAbsolutePath().parent.toString() + " /scan.json" , 0 )
2828 }
2929}
3030
3131@Suppress(" ClassName" )
32- class copenJSParser (fileLocation : String , mode : Int ) {
32+ class copenJSParser (fileLocation : String , mode : Int , extra : String? = " null " ) {
3333 init {
3434 when (mode) {
3535 0 -> {
36- ServerReader (fileLocation)
36+ ServerReader (fileLocation, extra )
3737 }
3838 1 -> {
3939 GraphReader (fileLocation)
@@ -44,8 +44,9 @@ class copenJSParser (fileLocation: String, mode: Int) {
4444 }
4545 }
4646 @Suppress(" FunctionName" )
47- private fun ServerReader (args : String ) {
47+ private fun ServerReader (args : String , startFrom : String? ) {
4848 var count = 0
49+ var startStatus = false
4950 try {
5051 val client = Socket (" localhost" , 9532 )
5152 println (" Reading file: $args " + LocalDateTime .now().toString())
@@ -55,9 +56,14 @@ class copenJSParser (fileLocation: String, mode: Int) {
5556 json.forEach { data ->
5657 count++
5758 val ip = data.split(' "' )[0 ]
58- println (" Current IP: $ip " )
59- client.outputStream.write(ip.toByteArray())
60- TimeUnit .MILLISECONDS .sleep(50 )
59+ if (startFrom == ip) {
60+ startStatus = true
61+ }
62+ else if (startStatus) {
63+ println (" Current IP: $ip " )
64+ client.outputStream.write(ip.toByteArray())
65+ TimeUnit .MILLISECONDS .sleep(5 )
66+ }
6167 }
6268 println (" $count IP's processed. " + LocalDateTime .now().toString())
6369 }
0 commit comments