Skip to content

Commit

Permalink
minor improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
dkoukoul committed May 14, 2020
1 parent 3b25837 commit fa19f68
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 15 deletions.
25 changes: 15 additions & 10 deletions app/src/main/java/co/anode/anodevpn/AnodeClient.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import java.io.BufferedWriter
import java.io.File
import java.io.IOException
import java.io.OutputStreamWriter
import java.lang.Exception
import java.net.HttpURLConnection
import java.net.URL
import java.time.Instant
Expand All @@ -26,16 +27,20 @@ object AnodeClient {

@Throws(IOException::class, JSONException::class)
fun httpPost(myUrl: String, type: String, message: String?): String {
val apiKey = "hthiP3Gx.TLJRcZGpsHh8ImjtBCjpB7soD87qsaDb"
val url = URL(myUrl)
val conn = url.openConnection() as HttpsURLConnection
conn.requestMethod = "POST"
conn.setRequestProperty("Content-Type", "application/json; charset=utf-8")
//conn.setRequestProperty("Authorization", "Api-Key $apiKey")
val jsonObject = errorJsonObj(type, message)
setPostRequestContent(conn, jsonObject)
conn.connect()
return conn.responseMessage + ""
try {
val apiKey = "hthiP3Gx.TLJRcZGpsHh8ImjtBCjpB7soD87qsaDb"
val url = URL(myUrl)
val conn = url.openConnection() as HttpsURLConnection
conn.requestMethod = "POST"
conn.setRequestProperty("Content-Type", "application/json; charset=utf-8")
//conn.setRequestProperty("Authorization", "Api-Key $apiKey")
val jsonObject = errorJsonObj(type, message)
setPostRequestContent(conn, jsonObject)
conn.connect()
return conn.responseMessage + ""
}catch (e:Exception) {
return "Error: $e"
}
}

fun checkNetworkConnection() =
Expand Down
6 changes: 3 additions & 3 deletions app/src/main/java/co/anode/anodevpn/AnodeUtil.kt
Original file line number Diff line number Diff line change
Expand Up @@ -196,10 +196,10 @@ class AnodeUtil(private val context: Context?) {

fun logFile() {
val filename: String = "$CJDNS_PATH/anodevpn.log"
if (File("$CJDNS_PATH/last_anodevpn.log").exists()) {
Files.delete(Paths.get("$CJDNS_PATH/last_anodevpn.log"))
}
if (File(filename).exists()) {
if (File("$CJDNS_PATH/last_anodevpn.log").exists()) {
Files.delete(Paths.get("$CJDNS_PATH/last_anodevpn.log"))
}
Files.move(Paths.get(filename),Paths.get("$CJDNS_PATH/last_anodevpn.log"))
}
val command = "logcat -f $filename -v time co.anode.anodevpn:V"
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/co/anode/anodevpn/FirstFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -253,10 +253,10 @@ object ConnectingThread: Runnable {
var tries = 0
logText.post(Runnable { logText.text = "Connecting..." })
//Check for ip address given by cjdns try for 20 times, 10secs
while (!iconnected && (tries < 20)) {
while (!iconnected && (tries < 10)) {
iconnected = CjdnsSocket.getCjdnsRoutes()
tries++
Thread.sleep(500)
Thread.sleep(2000)
}
if (iconnected) {
//Restart Service
Expand Down

0 comments on commit fa19f68

Please sign in to comment.